Merge pull request #287 from pierlauro/master

Protected visibility for JavaSourceLoaderImpl's internal methods and classes
This commit is contained in:
Julian Dolby 2018-04-13 17:02:24 -04:00 committed by GitHub
commit 883b7282f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 28 additions and 28 deletions

View File

@ -91,7 +91,7 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
/** /**
* WALA representation of a Java class residing in a source file * WALA representation of a Java class residing in a source file
* *
* @author rfuhrer * @author rfuhrer
*/ */
public class JavaClass extends AstClass { public class JavaClass extends AstClass {
@ -100,7 +100,7 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
protected final Collection<TypeName> superTypeNames; protected final Collection<TypeName> superTypeNames;
private final Collection<Annotation> annotations; private final Collection<Annotation> annotations;
public JavaClass(String typeName, Collection<TypeName> superTypeNames, CAstSourcePositionMap.Position position, Collection<CAstQualifier> qualifiers, public JavaClass(String typeName, Collection<TypeName> superTypeNames, CAstSourcePositionMap.Position position, Collection<CAstQualifier> qualifiers,
JavaSourceLoaderImpl loader, IClass enclosingClass, Collection<Annotation> annotations) { JavaSourceLoaderImpl loader, IClass enclosingClass, Collection<Annotation> annotations) {
super(position, TypeName.string2TypeName(typeName), loader, (short) mapToInt(qualifiers), new HashMap<Atom, IField>(), new HashMap<Selector, IMethod>()); super(position, TypeName.string2TypeName(typeName), loader, (short) mapToInt(qualifiers), new HashMap<Atom, IField>(), new HashMap<Selector, IMethod>());
@ -141,11 +141,11 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
/** END Custom change: Common superclass is optional */ /** END Custom change: Common superclass is optional */
Assertions.UNREACHABLE("Cannot find super class for " + this + " in " + superTypeNames); Assertions.UNREACHABLE("Cannot find super class for " + this + " in " + superTypeNames);
} }
if (excludedSupertype){ if (excludedSupertype){
System.err.println("Not tracking calls through excluded superclass of " + getName() + " extends " + superTypeNames); System.err.println("Not tracking calls through excluded superclass of " + getName() + " extends " + superTypeNames);
} }
return null; return null;
} }
@ -165,17 +165,17 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
return result; return result;
} }
private void addMethod(CAstEntity methodEntity, IClass owner, AbstractCFG<?, ?> cfg, SymbolTable symtab, boolean hasCatchBlock, protected void addMethod(CAstEntity methodEntity, IClass owner, AbstractCFG<?, ?> cfg, SymbolTable symtab, boolean hasCatchBlock,
Map<IBasicBlock<SSAInstruction>, TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo) { Map<IBasicBlock<SSAInstruction>, TypeReference[]> caughtTypes, boolean hasMonitorOp, AstLexicalInformation lexicalInfo, DebuggingInformation debugInfo) {
declaredMethods.put(Util.methodEntityToSelector(methodEntity), new ConcreteJavaMethod(methodEntity, owner, cfg, symtab, declaredMethods.put(Util.methodEntityToSelector(methodEntity), new ConcreteJavaMethod(methodEntity, owner, cfg, symtab,
hasCatchBlock, caughtTypes, hasMonitorOp, lexicalInfo, debugInfo)); hasCatchBlock, caughtTypes, hasMonitorOp, lexicalInfo, debugInfo));
} }
private void addMethod(CAstEntity methodEntity, IClass owner) { protected void addMethod(CAstEntity methodEntity, IClass owner) {
declaredMethods.put(Util.methodEntityToSelector(methodEntity), new AbstractJavaMethod(methodEntity, owner)); declaredMethods.put(Util.methodEntityToSelector(methodEntity), new AbstractJavaMethod(methodEntity, owner));
} }
private void addField(CAstEntity fieldEntity) { protected void addField(CAstEntity fieldEntity) {
declaredFields.put(Util.fieldEntityToAtom(fieldEntity), new JavaField(fieldEntity, JavaSourceLoaderImpl.this, this, JavaSourceLoaderImpl.this.getAnnotations(fieldEntity))); declaredFields.put(Util.fieldEntityToAtom(fieldEntity), new JavaField(fieldEntity, JavaSourceLoaderImpl.this, this, JavaSourceLoaderImpl.this.getAnnotations(fieldEntity)));
} }
@ -199,7 +199,7 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
} }
} }
private Collection<Annotation> getAnnotations(CAstEntity e) { protected Collection<Annotation> getAnnotations(CAstEntity e) {
Collection<CAstAnnotation> annotations = e.getAnnotations(); Collection<CAstAnnotation> annotations = e.getAnnotations();
if (annotations == null || annotations.isEmpty()) { if (annotations == null || annotations.isEmpty()) {
return null; return null;
@ -221,14 +221,14 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
return result; return result;
} }
} }
/** /**
* WALA representation of a field on a Java type that resides in a source file * WALA representation of a field on a Java type that resides in a source file
* *
* @author rfuhrer * @author rfuhrer
*/ */
private class JavaField extends AstField { protected class JavaField extends AstField {
private JavaField(CAstEntity fieldEntity, IClassLoader loader, IClass declaringClass, Collection<Annotation> annotations) { protected JavaField(CAstEntity fieldEntity, IClassLoader loader, IClass declaringClass, Collection<Annotation> annotations) {
super(FieldReference.findOrCreate(declaringClass.getReference(), Atom.findOrCreateUnicodeAtom(fieldEntity.getName()), super(FieldReference.findOrCreate(declaringClass.getReference(), Atom.findOrCreateUnicodeAtom(fieldEntity.getName()),
TypeReference.findOrCreate(loader.getReference(), TypeName.string2TypeName(fieldEntity.getType().getName()))), TypeReference.findOrCreate(loader.getReference(), TypeName.string2TypeName(fieldEntity.getType().getName()))),
fieldEntity.getQualifiers(), declaringClass, declaringClass.getClassHierarchy(), annotations); fieldEntity.getQualifiers(), declaringClass, declaringClass.getClassHierarchy(), annotations);
@ -238,10 +238,10 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
/** /**
* Generic DOMO representation of a method on a Java type that resides in a * Generic DOMO representation of a method on a Java type that resides in a
* source file * source file
* *
* @author rfuhrer * @author rfuhrer
*/ */
private abstract class JavaEntityMethod extends AstMethod { protected abstract class JavaEntityMethod extends AstMethod {
private final TypeReference[] parameterTypes; private final TypeReference[] parameterTypes;
private final TypeReference[] exceptionTypes; private final TypeReference[] exceptionTypes;
@ -276,7 +276,7 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
return parameterTypes[i]; return parameterTypes[i];
} }
private TypeReference[] computeParameterTypes(CAstEntity methodEntity) { protected TypeReference[] computeParameterTypes(CAstEntity methodEntity) {
TypeReference[] types; TypeReference[] types;
CAstType.Function type = (Function) methodEntity.getType(); CAstType.Function type = (Function) methodEntity.getType();
int argCount = type.getArgumentTypes().size(); int argCount = type.getArgumentTypes().size();
@ -303,7 +303,7 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
return exceptionTypes; return exceptionTypes;
} }
private TypeReference[] computeExceptionTypes(CAstEntity methodEntity) { protected TypeReference[] computeExceptionTypes(CAstEntity methodEntity) {
CAstType.Function fType = (Function) methodEntity.getType(); CAstType.Function fType = (Function) methodEntity.getType();
Collection<CAstType> exceptionTypes = fType.getExceptionTypes(); Collection<CAstType> exceptionTypes = fType.getExceptionTypes();
@ -326,10 +326,10 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
/** /**
* DOMO representation of an abstract (body-less) method on a Java type that * DOMO representation of an abstract (body-less) method on a Java type that
* resides in a source file * resides in a source file
* *
* @author rfuhrer * @author rfuhrer
*/ */
private class AbstractJavaMethod extends JavaEntityMethod { protected class AbstractJavaMethod extends JavaEntityMethod {
public AbstractJavaMethod(CAstEntity methodEntity, IClass owner) { public AbstractJavaMethod(CAstEntity methodEntity, IClass owner) {
super(methodEntity, owner); super(methodEntity, owner);
} }
@ -360,7 +360,7 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
/** /**
* DOMO representation of a concrete method (which has a body) on a Java type * DOMO representation of a concrete method (which has a body) on a Java type
* that resides in a source file * that resides in a source file
* *
* @author rfuhrer * @author rfuhrer
*/ */
public class ConcreteJavaMethod extends JavaEntityMethod { public class ConcreteJavaMethod extends JavaEntityMethod {
@ -483,7 +483,7 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
super(loaderRef, cha.getScope().getArrayClassLoader(), parent, cha.getScope().getExclusions(), cha); super(loaderRef, cha.getScope().getArrayClassLoader(), parent, cha.getScope().getExclusions(), cha);
this.existsCommonSuperclass = existsCommonSuperClass; this.existsCommonSuperclass = existsCommonSuperClass;
} }
public JavaSourceLoaderImpl(ClassLoaderReference loaderRef, IClassLoader parent, IClassHierarchy cha) { public JavaSourceLoaderImpl(ClassLoaderReference loaderRef, IClassLoader parent, IClassHierarchy cha) {
// standard case: we have a common super class // standard case: we have a common super class
this(true, loaderRef, parent, cha); this(true, loaderRef, parent, cha);
@ -503,7 +503,7 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
/** BEGIN Custom change: Optional deletion of fTypeMap */ /** BEGIN Custom change: Optional deletion of fTypeMap */
public static volatile boolean deleteTypeMapAfterInit = true; public static volatile boolean deleteTypeMapAfterInit = true;
/** END Custom change: Optional deletion of fTypeMap */ /** END Custom change: Optional deletion of fTypeMap */
@Override @Override
public void init(List<Module> modules) throws IOException { public void init(List<Module> modules) throws IOException {
@ -528,10 +528,10 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
((JavaClass) owner).addField(n); ((JavaClass) owner).addField(n);
} }
private static TypeName toWALATypeName(CAstType type) { protected static TypeName toWALATypeName(CAstType type) {
return TypeName.string2TypeName(type.getName()); return TypeName.string2TypeName(type.getName());
} }
public IClass defineType(CAstEntity type, String typeName, CAstEntity owner) { public IClass defineType(CAstEntity type, String typeName, CAstEntity owner) {
Collection<TypeName> superTypeNames = new ArrayList<>(); Collection<TypeName> superTypeNames = new ArrayList<>();
for (CAstType superType : type.getType().getSupertypes()) { for (CAstType superType : type.getType().getSupertypes()) {
@ -544,7 +544,7 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
if (getParent().lookupClass(javaClass.getName()) != null) { if (getParent().lookupClass(javaClass.getName()) != null) {
return null; return null;
} }
fTypeMap.put(type, javaClass); fTypeMap.put(type, javaClass);
loadedClasses.put(javaClass.getName(), javaClass); loadedClasses.put(javaClass.getName(), javaClass);
return javaClass; return javaClass;
@ -554,7 +554,7 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
public String toString() { public String toString() {
return "Java Source Loader (classes " + loadedClasses.values() + ")"; return "Java Source Loader (classes " + loadedClasses.values() + ")";
} }
public static class InstructionFactory extends JavaInstructionFactory implements AstJavaInstructionFactory { public static class InstructionFactory extends JavaInstructionFactory implements AstJavaInstructionFactory {
@Override @Override
@ -658,9 +658,9 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
return new AstLexicalWrite(iindex, definer, globalName, type, rhs); return new AstLexicalWrite(iindex, definer, globalName, type, rhs);
} }
} }
private static final InstructionFactory insts = new InstructionFactory(); protected static final InstructionFactory insts = new InstructionFactory();
@Override @Override
public InstructionFactory getInstructionFactory() { public InstructionFactory getInstructionFactory() {
return insts; return insts;