List of usage examples for org.objectweb.asm Opcodes ACC_PROTECTED
int ACC_PROTECTED
To view the source code for org.objectweb.asm Opcodes ACC_PROTECTED.
Click Source Link
From source file:org.evosuite.instrumentation.AccessibleClassAdapter.java
License:Open Source License
/** * {@inheritDoc}/*from www.j a va 2 s. c o m*/ * * Change fields to public */ @Override public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) { if (!exclude && (access & Opcodes.ACC_PRIVATE) != Opcodes.ACC_PRIVATE && (access & Opcodes.ACC_PROTECTED) != Opcodes.ACC_PROTECTED) { access = access | Opcodes.ACC_PUBLIC; // access = access & ~Opcodes.ACC_PROTECTED; //System.out.println("Setting field to public: "+name); } return super.visitField(access, name, desc, signature, value); }
From source file:org.evosuite.instrumentation.AccessibleClassAdapter.java
License:Open Source License
/** * {@inheritDoc}/*w w w . j a v a 2 s . co m*/ * * Change methods to public */ @Override public MethodVisitor visitMethod(int access, String name, String desc, String signature, final String[] exceptions) { int skipMask = Opcodes.ACC_NATIVE | Opcodes.ACC_BRIDGE; if (!exclude && ((access & Opcodes.ACC_PRIVATE) != Opcodes.ACC_PRIVATE) && ((access & skipMask) == 0)) { access = access | Opcodes.ACC_PUBLIC; access = access & ~Opcodes.ACC_PROTECTED; } MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions); return mv; }
From source file:org.evosuite.instrumentation.AccessibleClassAdapter.java
License:Open Source License
/** {@inheritDoc} */ @Override//from w w w.j a v a 2s . c o m public void visitInnerClass(String name, String outerName, String innerName, int access) { if (!exclude && (access & Opcodes.ACC_PRIVATE) != Opcodes.ACC_PRIVATE) { access = access | Opcodes.ACC_PUBLIC; access = access & ~Opcodes.ACC_PROTECTED; } super.visitInnerClass(name, outerName, innerName, access); }
From source file:org.evosuite.symbolic.instrument.AccessFlags.java
License:Open Source License
static boolean isProtected(int access) { return is(access, Opcodes.ACC_PROTECTED); }
From source file:org.evosuite.testcarver.instrument.Instrumenter.java
License:Open Source License
@SuppressWarnings("unchecked") public void transformClassNode(ClassNode cn, final String internalClassName) { if (!TransformerUtil.isClassConsideredForInstrumentation(internalClassName)) { logger.debug("Class {} has not been instrumented because its name is on the blacklist", internalClassName);//from w ww . j av a 2s .co m return; } // consider only public and protected classes which are not interfaces if ((cn.access & Opcodes.ACC_INTERFACE) != 0) { return; } // No private if ((cn.access & Opcodes.ACC_PRIVATE) != 0) { // TODO: Why is this not detecting $DummyIntegrator? logger.debug("Ignoring private class {}", cn.name); return; } String packageName = internalClassName.replace('/', '.'); if (packageName.contains(".")) packageName = packageName.substring(0, packageName.lastIndexOf('.')); // ASM has some problem with the access of inner classes // so we check if the inner class name is the current class name // and if so, check if the inner class is actually accessible List<InnerClassNode> in = cn.innerClasses; for (InnerClassNode inc : in) { if (cn.name.equals(inc.name)) { logger.info("ASM Bug: Inner class equals class."); if ((inc.access & Opcodes.ACC_PROTECTED) == Opcodes.ACC_PROTECTED) { if (!Properties.CLASS_PREFIX.equals(packageName)) { return; } } if ((inc.access & Opcodes.ACC_PRIVATE) == Opcodes.ACC_PRIVATE) { return; } logger.debug("Can use inner class {}", inc.name); } } logger.info("Checking package {} for class {}", packageName, cn.name); // Protected/default only if in same package if ((cn.access & Opcodes.ACC_PUBLIC) == 0) { if (!Properties.CLASS_PREFIX.equals(packageName)) { logger.info("Not using protected/default class because package name does not match"); return; } else { logger.info("Using protected/default class because package name matches"); } } /* if( (cn.access & Opcodes.ACC_PUBLIC) == 0 && (cn.access & Opcodes.ACC_PROTECTED) == 0) { return; } */ final ArrayList<MethodNode> wrappedMethods = new ArrayList<MethodNode>(); MethodNode methodNode; final Iterator<MethodNode> methodIter = cn.methods.iterator(); while (methodIter.hasNext()) { methodNode = methodIter.next(); // consider only public methods which are not abstract or native if (!TransformerUtil.isPrivate(methodNode.access) && !TransformerUtil.isAbstract(methodNode.access) && !TransformerUtil.isNative(methodNode.access) && !methodNode.name.equals("<clinit>")) { if (!TransformerUtil.isPublic(methodNode.access)) { //if(!Properties.CLASS_PREFIX.equals(packageName)) { transformWrapperCalls(methodNode); continue; //} } if (methodNode.name.equals("<init>")) { if (TransformerUtil.isAbstract(cn.access)) { // We cannot invoke constructors of abstract classes directly continue; } this.addFieldRegistryRegisterCall(methodNode); } this.instrumentPUTXXXFieldAccesses(cn, internalClassName, methodNode); this.instrumentGETXXXFieldAccesses(cn, internalClassName, methodNode); this.instrumentMethod(cn, internalClassName, methodNode, wrappedMethods); } else { transformWrapperCalls(methodNode); } } final int numWM = wrappedMethods.size(); for (int i = 0; i < numWM; i++) { cn.methods.add(wrappedMethods.get(i)); } TraceClassVisitor tcv = new TraceClassVisitor(new PrintWriter(System.err)); cn.accept(tcv); }
From source file:org.evosuite.testcarver.instrument.TransformerUtil.java
License:Open Source License
public static int modifyVisibility(int access, final int targetAccess) { access &= ~Opcodes.ACC_PRIVATE;/* w w w . j a v a 2s . c om*/ access &= ~Opcodes.ACC_PROTECTED; access &= ~Opcodes.ACC_PUBLIC; return access |= targetAccess; }
From source file:org.evosuite.testcarver.instrument.TransformerUtil.java
License:Open Source License
public static boolean isClassAccessible(final ClassNode cn) { return (cn.access & Opcodes.ACC_INTERFACE) == 0 && (((cn.access & Opcodes.ACC_PUBLIC) != 0) || ((cn.access & Opcodes.ACC_PROTECTED) != 0)); }
From source file:org.fehrman.jcm.find.Find.java
License:CDDL license
@SuppressWarnings("unchecked") private String processMethod(MethodNode methodNode) throws Exception //---------------------------------------------------------------- { StringBuilder methodDescription = new StringBuilder(); String className = null;//ww w.j ava 2s . c om Type returnType = Type.getReturnType(methodNode.desc); Type[] argumentTypes = Type.getArgumentTypes(methodNode.desc); List<String> thrownInternalClassNames = methodNode.exceptions; _logger.entering(CLASS, Thread.currentThread().getStackTrace()[1].getMethodName()); if ((methodNode.access & Opcodes.ACC_PUBLIC) != 0) { methodDescription.append("public "); } if ((methodNode.access & Opcodes.ACC_PRIVATE) != 0) { methodDescription.append("private "); } if ((methodNode.access & Opcodes.ACC_PROTECTED) != 0) { methodDescription.append("protected "); } if ((methodNode.access & Opcodes.ACC_STATIC) != 0) { methodDescription.append("static "); } if ((methodNode.access & Opcodes.ACC_ABSTRACT) != 0) { methodDescription.append("abstract "); } if ((methodNode.access & Opcodes.ACC_SYNCHRONIZED) != 0) { methodDescription.append("synchronized "); } className = returnType.getClassName(); if (className != null && className.startsWith(JAVA_LANG)) { methodDescription.append(className.substring(JAVA_LANG.length())); } else { methodDescription.append(className); } methodDescription.append(" "); methodDescription.append(methodNode.name); methodDescription.append("("); for (int i = 0; i < argumentTypes.length; i++) { Type argumentType = argumentTypes[i]; if (i > 0) { methodDescription.append(", "); } className = argumentType.getClassName(); if (className != null && className.startsWith(JAVA_LANG)) { methodDescription.append(className.substring(JAVA_LANG.length())); } else { methodDescription.append(className); } } methodDescription.append(")"); if (!thrownInternalClassNames.isEmpty()) { methodDescription.append(" throws "); int i = 0; for (String thrownInternalClassName : thrownInternalClassNames) { if (i > 0) { methodDescription.append(", "); } className = Type.getObjectType(thrownInternalClassName).getClassName(); if (className != null && className.startsWith(JAVA_LANG)) { methodDescription.append(className.substring(JAVA_LANG.length())); } else { methodDescription.append(className); } i++; } } _logger.exiting(CLASS, Thread.currentThread().getStackTrace()[1].getMethodName()); return methodDescription.toString(); }
From source file:org.freud.analysed.classbytecode.parser.asm.AsmElement.java
License:Apache License
@Override public boolean isProtected() { return isAccessModifier(Opcodes.ACC_PROTECTED); }
From source file:org.gradle.language.base.internal.tasks.apigen.ApiStubGenerator.java
License:Apache License
private boolean isProtected(int access) { return (access & Opcodes.ACC_PROTECTED) == Opcodes.ACC_PROTECTED; }