/** * Accounts the bytecode size of analyzed method for statistics. * * @param mtd Analyzed method. */ private static void accountCodeBytes(IMethod mtd) { // Get method bytecode size if (mtd instanceof ShrikeCTMethod) { analyzedBytes += ((ShrikeCTMethod) mtd).getBytecodes().length; } }
int[][] map = null; try { map = getBCInfo().localVariableMap; } catch (InvalidClassFileException e1) { return null; if (localNumber > getMaxLocals()) { throw new IllegalArgumentException("illegal local number: " + localNumber + ", method " + getDeclaringClass().getName() + '.' + getName() + " uses at most " + getMaxLocals()); } else { try { return getClassReader().getCP().getCPUtf8(nameIndex); } catch (InvalidClassFileException e) { e.printStackTrace();
int numAnnotatedParams = isStatic() ? getNumberOfParameters() : getNumberOfParameters() - 1; @SuppressWarnings("unchecked") Collection<Annotation>[] result = new Collection[numAnnotatedParams]; ClassLoaderReference reference = getDeclaringClass().getClassLoader().getReference(); AnnotationsReader r = getAnnotationsReader(AnnotationType.RuntimeInvisibleParameterAnnotations); Collection<Annotation>[] paramAnnots = Annotation.getParameterAnnotationsFromReader(r, reference); if (paramAnnots != null) { r = getAnnotationsReader(AnnotationType.RuntimeVisibleParameterAnnotations); paramAnnots = Annotation.getParameterAnnotationsFromReader(r, reference); if (paramAnnots != null) {
@Override public Collection<Annotation> getAnnotations(boolean runtimeInvisible) throws InvalidClassFileException { AnnotationsReader r = getAnnotationsReader(runtimeInvisible ? AnnotationType.RuntimeInvisibleAnnotations : AnnotationType.RuntimeVisibleAnnotations); return Annotation.getAnnotationsFromReader(r, getDeclaringClass().getClassLoader().getReference()); }
/** * read the runtime-visible annotations from the class file */ public Collection<Annotation> getRuntimeVisibleAnnotations() throws InvalidClassFileException { return getAnnotations(false); }
private static List<TypeReference> getArraysWrittenFromShrikeBT(ShrikeCTMethod M) throws InvalidClassFileException { // TODO move the logic here from ShrikeCTMethodWrapper List<TypeReference> result = new LinkedList<>(); for (TypeReference tr : Iterator2Iterable.make(M.getArraysWritten())) { result.add(tr); } return result; }
/** * Clear all optional cached data associated with this class */ public void clearSoftCaches() { // toss optional information from each method. if (methodMap != null) { for (IMethod iMethod : getDeclaredMethods()) { ShrikeCTMethod m = (ShrikeCTMethod) iMethod; m.clearCaches(); } } // clear the methodMap cache // SJF: don't do this!!! makes it hard to clear caches on methods. // methodMap = null; inheritCache = null; // clear the cached interfaces allInterfaces = null; // toss away the Shrike reader reader.clear(); }
/** * TODO: cache? * * @return raw "Signature" attribute from the bytecode */ private String getGenericsSignature() throws InvalidClassFileException { return computeGenericsSignature(); }
private static boolean hasShrikeBTObjectArrayLoad(ShrikeCTMethod M) throws InvalidClassFileException { for (TypeReference tr : Iterator2Iterable.make(M.getArraysRead())) { if (tr.isReferenceType()) { return true; } } return false; }
private static Iterator<TypeReference> iterateShrikeBTCastTypes(ShrikeCTMethod wrapper) throws InvalidClassFileException { return wrapper.getCastTypes(); }
/** * initialize the declared methods array */ @Override protected ShrikeCTMethod[] computeDeclaredMethods() throws InvalidClassFileException { int methodCount = reader.get().getMethodCount(); ShrikeCTMethod[] result = new ShrikeCTMethod[methodCount]; for (int i = 0; i < methodCount; i++) { ShrikeCTMethod m = new ShrikeCTMethod(this, i); if (DEBUG) { System.err.println(("Register method " + m + " for class " + this)); } result[i] = m; } return result; }
int[][] map = null; try { map = getBCInfo().localVariableMap; } catch (InvalidClassFileException e1) { return null; if (localNumber > getMaxLocals()) { throw new IllegalArgumentException("illegal local number: " + localNumber + ", method " + getDeclaringClass().getName() + '.' + getName() + " uses at most " + getMaxLocals()); } else { try { return getClassReader().getCP().getCPUtf8(nameIndex); } catch (InvalidClassFileException e) { e.printStackTrace();
int numAnnotatedParams = isStatic() ? getNumberOfParameters() : getNumberOfParameters() - 1; @SuppressWarnings("unchecked") Collection<Annotation>[] result = new Collection[numAnnotatedParams]; ClassLoaderReference reference = getDeclaringClass().getClassLoader().getReference(); AnnotationsReader r = getAnnotationsReader(AnnotationType.RuntimeInvisibleParameterAnnotations); Collection<Annotation>[] paramAnnots = Annotation.getParameterAnnotationsFromReader(r, reference); if (paramAnnots != null) { r = getAnnotationsReader(AnnotationType.RuntimeVisibleParameterAnnotations); paramAnnots = Annotation.getParameterAnnotationsFromReader(r, reference); if (paramAnnots != null) {
@Override public Collection<Annotation> getAnnotations(boolean runtimeInvisible) throws InvalidClassFileException { AnnotationsReader r = getAnnotationsReader(runtimeInvisible ? AnnotationType.RuntimeInvisibleAnnotations : AnnotationType.RuntimeVisibleAnnotations); return Annotation.getAnnotationsFromReader(r, getDeclaringClass().getClassLoader().getReference()); }
/** * read the runtime-visible annotations from the class file */ public Collection<Annotation> getRuntimeVisibleAnnotations() throws InvalidClassFileException { return getAnnotations(false); }
private static List<TypeReference> getArraysWrittenFromShrikeBT(ShrikeCTMethod M) throws InvalidClassFileException { // TODO move the logic here from ShrikeCTMethodWrapper List<TypeReference> result = new LinkedList<>(); for (TypeReference tr : Iterator2Iterable.make(M.getArraysWritten())) { result.add(tr); } return result; }
/** * Clear all optional cached data associated with this class */ public void clearSoftCaches() { // toss optional information from each method. if (methodMap != null) { for (IMethod iMethod : getDeclaredMethods()) { ShrikeCTMethod m = (ShrikeCTMethod) iMethod; m.clearCaches(); } } // clear the methodMap cache // SJF: don't do this!!! makes it hard to clear caches on methods. // methodMap = null; inheritCache = null; // clear the cached interfaces allInterfaces = null; // toss away the Shrike reader reader.clear(); }
/** * TODO: cache? * * @return raw "Signature" attribute from the bytecode */ private String getGenericsSignature() throws InvalidClassFileException { return computeGenericsSignature(); }
private static boolean hasShrikeBTObjectArrayLoad(ShrikeCTMethod M) throws InvalidClassFileException { for (TypeReference tr : Iterator2Iterable.make(M.getArraysRead())) { if (tr.isReferenceType()) { return true; } } return false; }
private static Iterator<TypeReference> iterateShrikeBTCastTypes(ShrikeCTMethod wrapper) throws InvalidClassFileException { return wrapper.getCastTypes(); }