Commit 74d75809 authored by Lubomir Bulej's avatar Lubomir Bulej

Another batch of cosmetic changes to make upcoming changes less confusing.

parent 48a590fe
......@@ -9,25 +9,25 @@ import ch.usi.dag.dislreserver.DiSLREServerFatalException;
public class ArrayShadowClass extends ShadowClass {
private final Type type;
private final Type __type;
private final ShadowClass superClass;
private final ShadowClass __superClass;
private final ShadowClass arrayComponentClass;
private final ShadowClass __componentClass;
//
ArrayShadowClass (
final long netReference, final ShadowObject classLoader,
final ShadowClass superClass, final ShadowClass arrayComponentClass,
final ShadowClass superClass, final ShadowClass componentClass,
final Type type
) {
super (netReference, classLoader);
this.type = type;
this.superClass = superClass;
this.arrayComponentClass = arrayComponentClass;
__type = type;
__superClass = superClass;
__componentClass = componentClass;
}
......@@ -38,7 +38,7 @@ public class ArrayShadowClass extends ShadowClass {
public int getArrayDimensions () {
return type.getDimensions ();
return __type.getDimensions ();
}
......@@ -50,20 +50,20 @@ public class ArrayShadowClass extends ShadowClass {
@Override
public boolean isInstance (ShadowObject obj) {
public boolean isInstance (final ShadowObject obj) {
return equals (obj.getShadowClass ());
}
@Override
public boolean isAssignableFrom (ShadowClass klass) {
public boolean isAssignableFrom (final ShadowClass klass) {
return
equals (klass)
||
(
(klass instanceof ArrayShadowClass)
&&
arrayComponentClass.isAssignableFrom (klass.getComponentType ())
__componentClass.isAssignableFrom (klass.getComponentType ())
);
}
......@@ -100,13 +100,13 @@ public class ArrayShadowClass extends ShadowClass {
@Override
public String getName () {
return type.getDescriptor ().replace ('/', '.');
return __type.getDescriptor ().replace ('/', '.');
}
@Override
public String getCanonicalName () {
return type.getClassName ();
return __type.getClassName ();
}
......@@ -124,7 +124,7 @@ public class ArrayShadowClass extends ShadowClass {
@Override
public ShadowClass getSuperclass () {
return superClass;
return __superClass;
}
......@@ -135,8 +135,8 @@ public class ArrayShadowClass extends ShadowClass {
@Override
public FieldInfo getField (String fieldName) throws NoSuchFieldException {
throw new NoSuchFieldException (type.getClassName () + "." + fieldName);
public FieldInfo getField (final String fieldName) throws NoSuchFieldException {
throw new NoSuchFieldException (__type.getClassName () + "." + fieldName);
}
......@@ -147,10 +147,10 @@ public class ArrayShadowClass extends ShadowClass {
@Override
public MethodInfo getMethod (String methodName, String [] argumentNames)
public MethodInfo getMethod (final String methodName, final String [] argumentNames)
throws NoSuchMethodException {
for (MethodInfo methodInfo : superClass.getMethods ()) {
for (final MethodInfo methodInfo : __superClass.getMethods ()) {
if (methodName.equals (methodInfo.getName ())
&& Arrays.equals (argumentNames, methodInfo.getParameterTypes ())
) {
......@@ -159,7 +159,7 @@ public class ArrayShadowClass extends ShadowClass {
}
throw new NoSuchMethodException (
type.getClassName () + "." + methodName + argumentNamesToString (argumentNames)
__type.getClassName () + "." + methodName + argumentNamesToString (argumentNames)
);
}
......@@ -177,9 +177,9 @@ public class ArrayShadowClass extends ShadowClass {
@Override
public FieldInfo getDeclaredField (String fieldName)
public FieldInfo getDeclaredField (final String fieldName)
throws NoSuchFieldException {
throw new NoSuchFieldException (type.getClassName () + "." + fieldName);
throw new NoSuchFieldException (__type.getClassName () + "." + fieldName);
}
......@@ -190,11 +190,11 @@ public class ArrayShadowClass extends ShadowClass {
@Override
public MethodInfo getDeclaredMethod (String methodName,
String [] argumentNames)
public MethodInfo getDeclaredMethod (final String methodName,
final String [] argumentNames)
throws NoSuchMethodException {
throw new NoSuchMethodException (
type.getClassName () + "." + methodName + argumentNamesToString (argumentNames)
__type.getClassName () + "." + methodName + argumentNamesToString (argumentNames)
);
}
......
......@@ -8,45 +8,46 @@ public class FieldInfo {
// TODO ! is this implementation of methods really working ??
private FieldNode fieldNode;
private final FieldNode __fieldNode;
private int modifiers;
private final int __modifiers;
private String name;
private final String __name;
private String type;
private final String __type;
//
public FieldInfo (FieldNode fieldNode) {
this.fieldNode = fieldNode;
name = fieldNode.name;
type = fieldNode.desc;
modifiers = fieldNode.access;
public FieldInfo (final FieldNode fieldNode) {
__fieldNode = fieldNode;
__name = fieldNode.name;
__type = fieldNode.desc;
__modifiers = fieldNode.access;
}
public FieldNode getFieldNode () {
return fieldNode;
return __fieldNode;
}
public String getName () {
return name;
return __name;
}
public int getModifiers () {
return modifiers;
return __modifiers;
}
public String getType () {
return type;
return __type;
}
public boolean isPublic () {
return (modifiers & Opcodes.ACC_PUBLIC) != 0;
return (__modifiers & Opcodes.ACC_PUBLIC) != 0;
}
}
......@@ -11,70 +11,70 @@ public class MethodInfo {
// TODO ! is this implementation of methods really working ??
private MethodNode methodNode;
private final MethodNode __methodNode;
private int modifiers;
private final int __modifiers;
private String name;
private final String __name;
private String returnType;
private final String __returnType;
private String [] parameterTypes;
private final String [] __parameterTypes;
private String [] exceptionTypes;
private final String [] __exceptionTypes;
public MethodInfo (MethodNode methodNode) {
this.methodNode = methodNode;
name = methodNode.name;
modifiers = methodNode.access;
returnType = methodNode.desc.substring (methodNode.desc.indexOf (')') + 1);
public MethodInfo (final MethodNode methodNode) {
__methodNode = methodNode;
__name = methodNode.name;
__modifiers = methodNode.access;
__returnType = methodNode.desc.substring (methodNode.desc.indexOf (')') + 1);
Type [] parameters = Type.getArgumentTypes (methodNode.desc);
int size = parameters.length;
parameterTypes = new String [size];
final Type [] parameters = Type.getArgumentTypes (methodNode.desc);
final int size = parameters.length;
__parameterTypes = new String [size];
for (int i = 0; i < size; i++) {
parameterTypes [i] = parameters [i].getDescriptor ();
__parameterTypes [i] = parameters [i].getDescriptor ();
}
// to have "checked" array :(
exceptionTypes = methodNode.exceptions.toArray (new String [0]);
__exceptionTypes = methodNode.exceptions.toArray (new String [0]);
}
public MethodNode getMethodNode () {
return methodNode;
return __methodNode;
}
public String getName () {
return name;
return __name;
}
public int getModifiers () {
return modifiers;
return __modifiers;
}
public String getReturnType () {
return returnType;
return __returnType;
}
public String [] getParameterTypes () {
return Arrays.copyOf (parameterTypes, parameterTypes.length);
return Arrays.copyOf (__parameterTypes, __parameterTypes.length);
}
public String [] getExceptionTypes () {
return Arrays.copyOf (exceptionTypes, exceptionTypes.length);
return Arrays.copyOf (__exceptionTypes, __exceptionTypes.length);
}
public boolean isPublic () {
return (modifiers & Opcodes.ACC_PUBLIC) != 0;
return (__modifiers & Opcodes.ACC_PUBLIC) != 0;
}
}
......@@ -19,22 +19,23 @@ class ObjectShadowClass extends ShadowClass {
// TODO ! is this implementation of methods really working ??
private ShadowClass superClass;
private final ShadowClass __superClass;
private ClassNode classNode;
private ClassNode __classNode;
private int access;
private int __access;
private String name;
private String __name;
ObjectShadowClass (
long net_ref, String classSignature, ShadowObject classLoader,
ShadowClass superClass, byte [] classCode
final long netReference, final String classSignature,
final ShadowObject classLoader, final ShadowClass superClass,
final byte [] classCode
) {
super (net_ref, classLoader);
super (netReference, classLoader);
this.superClass = superClass;
__superClass = superClass;
if (classCode == null || classCode.length == 0) {
throw new DiSLREServerFatalException (
"Creating class info for "+ classSignature + " with no code provided"
......@@ -56,18 +57,18 @@ class ObjectShadowClass extends ShadowClass {
private List <String> innerclasses;
private void initializeClassInfo (byte [] classCode) {
ClassReader classReader = new ClassReader (classCode);
classNode = new ClassNode (Opcodes.ASM4);
classReader.accept (classNode, ClassReader.SKIP_DEBUG | ClassReader.EXPAND_FRAMES);
private void initializeClassInfo (final byte [] classCode) {
final ClassReader classReader = new ClassReader (classCode);
__classNode = new ClassNode (Opcodes.ASM4);
classReader.accept (__classNode, ClassReader.SKIP_DEBUG | ClassReader.EXPAND_FRAMES);
access = classNode.access;
name = classNode.name.replace ('/', '.');
__access = __classNode.access;
__name = __classNode.name.replace ('/', '.');
methods = new ArrayList <MethodInfo> (classNode.methods.size ());
methods = new ArrayList <MethodInfo> (__classNode.methods.size ());
public_methods = new LinkedList <MethodInfo> ();
for (MethodNode methodNode : classNode.methods) {
MethodInfo methodInfo = new MethodInfo (methodNode);
for (final MethodNode methodNode : __classNode.methods) {
final MethodInfo methodInfo = new MethodInfo (methodNode);
methods.add (methodInfo);
if (methodInfo.isPublic ()) {
......@@ -75,10 +76,10 @@ class ObjectShadowClass extends ShadowClass {
}
}
fields = new ArrayList <FieldInfo> (classNode.fields.size ());
fields = new ArrayList <FieldInfo> (__classNode.fields.size ());
public_fields = new LinkedList <FieldInfo> ();
for (FieldNode fieldNode : classNode.fields) {
FieldInfo fieldInfo = new FieldInfo (fieldNode);
for (final FieldNode fieldNode : __classNode.fields) {
final FieldInfo fieldInfo = new FieldInfo (fieldNode);
fields.add (fieldInfo);
if (fieldInfo.isPublic ()) {
......@@ -87,17 +88,17 @@ class ObjectShadowClass extends ShadowClass {
}
if (getSuperclass () != null) {
for (MethodInfo methodInfo : getSuperclass ().getMethods ()) {
for (final MethodInfo methodInfo : getSuperclass ().getMethods ()) {
public_methods.add (methodInfo);
}
for (FieldInfo fieldInfo : getSuperclass ().getFields ()) {
for (final FieldInfo fieldInfo : getSuperclass ().getFields ()) {
public_fields.add (fieldInfo);
}
}
innerclasses = new ArrayList <String> (classNode.innerClasses.size ());
for (InnerClassNode innerClassNode : classNode.innerClasses) {
innerclasses = new ArrayList <String> (__classNode.innerClasses.size ());
for (final InnerClassNode innerClassNode : __classNode.innerClasses) {
innerclasses.add (innerClassNode.name);
}
}
......@@ -116,14 +117,14 @@ class ObjectShadowClass extends ShadowClass {
@Override
public boolean isInstance (ShadowObject obj) {
public boolean isInstance (final ShadowObject obj) {
// return equals(obj.getSClass());
throw new DiSLREServerFatalException ("ShadowCommonClass.isInstance not implemented");
}
@Override
public boolean isAssignableFrom (ShadowClass klass) {
public boolean isAssignableFrom (final ShadowClass klass) {
// while (klass != null) {
//
// if (klass.equals(this)) {
......@@ -140,7 +141,7 @@ class ObjectShadowClass extends ShadowClass {
@Override
public boolean isInterface () {
return (access & Opcodes.ACC_INTERFACE) != 0;
return (__access & Opcodes.ACC_INTERFACE) != 0;
}
......@@ -152,25 +153,25 @@ class ObjectShadowClass extends ShadowClass {
@Override
public boolean isAnnotation () {
return (access & Opcodes.ACC_ANNOTATION) != 0;
return (__access & Opcodes.ACC_ANNOTATION) != 0;
}
@Override
public boolean isSynthetic () {
return (access & Opcodes.ACC_SYNTHETIC) != 0;
return (__access & Opcodes.ACC_SYNTHETIC) != 0;
}
@Override
public boolean isEnum () {
return (access & Opcodes.ACC_ENUM) != 0;
return (__access & Opcodes.ACC_ENUM) != 0;
}
@Override
public String getName () {
return name;
return __name;
}
......@@ -182,15 +183,15 @@ class ObjectShadowClass extends ShadowClass {
@Override
public String [] getInterfaces () {
return classNode.interfaces.toArray (new String [0]);
return __classNode.interfaces.toArray (new String [0]);
}
@Override
public String getPackage () {
int i = name.lastIndexOf ('.');
final int i = __name.lastIndexOf ('.');
if (i != -1) {
return name.substring (0, i);
return __name.substring (0, i);
} else {
return null;
......@@ -200,41 +201,45 @@ class ObjectShadowClass extends ShadowClass {
@Override
public ShadowClass getSuperclass () {
return superClass;
return __superClass;
}
@Override
public FieldInfo [] getFields () {
// to have "checked" array :(
return public_fields.toArray (new FieldInfo [0]);
}
public FieldInfo getField (String fieldName) throws NoSuchFieldException {
for (FieldInfo fieldInfo : fields) {
@Override
public FieldInfo getField (final String fieldName) throws NoSuchFieldException {
for (final FieldInfo fieldInfo : fields) {
if (fieldInfo.isPublic () && fieldInfo.getName ().equals (fieldName)) {
return fieldInfo;
}
}
if (getSuperclass () == null) {
throw new NoSuchFieldException (name + "." + fieldName);
throw new NoSuchFieldException (__name + "." + fieldName);
}
return getSuperclass ().getField (fieldName);
}
@Override
public MethodInfo [] getMethods () {
// to have "checked" array :(
return public_methods.toArray (new MethodInfo [0]);
}
@Override
public MethodInfo getMethod (
String methodName, String [] argumentNames
final String methodName, final String [] argumentNames
) throws NoSuchMethodException {
for (MethodInfo methodInfo : public_methods) {
for (final MethodInfo methodInfo : public_methods) {
if (methodName.equals (methodInfo.getName ()) &&
Arrays.equals (argumentNames, methodInfo.getParameterTypes ())
) {
......@@ -243,43 +248,48 @@ class ObjectShadowClass extends ShadowClass {
}
throw new NoSuchMethodException (
name + "." + methodName + argumentNamesToString (argumentNames)
__name + "." + methodName + argumentNamesToString (argumentNames)
);
}
@Override
public FieldInfo [] getDeclaredFields () {
return fields.toArray (new FieldInfo [0]);
}
public FieldInfo getDeclaredField (String fieldName)
@Override
public FieldInfo getDeclaredField (final String fieldName)
throws NoSuchFieldException {
for (FieldInfo fieldInfo : fields) {
for (final FieldInfo fieldInfo : fields) {
if (fieldInfo.getName ().equals (fieldName)) {
return fieldInfo;
}
}
throw new NoSuchFieldException (name + "." + fieldName);
throw new NoSuchFieldException (__name + "." + fieldName);
}
@Override
public MethodInfo [] getDeclaredMethods () {
return methods.toArray (new MethodInfo [methods.size ()]);
}
@Override
public String [] getDeclaredClasses () {
return innerclasses.toArray (new String [innerclasses.size ()]);
}
@Override
public MethodInfo getDeclaredMethod (
String methodName, String [] argumentNames
final String methodName, final String [] argumentNames
) throws NoSuchMethodException {
for (MethodInfo methodInfo : methods) {
for (final MethodInfo methodInfo : methods) {
if (methodName.equals (methodInfo.getName ()) &&
Arrays.equals (argumentNames, methodInfo.getParameterTypes ())
) {
......@@ -288,7 +298,7 @@ class ObjectShadowClass extends ShadowClass {
}
throw new NoSuchMethodException (
name + "." + methodName + argumentNamesToString (argumentNames)
__name + "." + methodName + argumentNamesToString (argumentNames)
);
}
......
......@@ -5,14 +5,18 @@ import org.objectweb.asm.Type;
public class PrimitiveShadowClass extends ShadowClass {
private Type t;
private final Type __type;
//
PrimitiveShadowClass (long net_ref, ShadowObject classLoader, Type t) {
super (net_ref, classLoader);
this.t = t;
PrimitiveShadowClass (
final long netReference, final ShadowObject classLoader, final Type type
) {
super (netReference, classLoader);
__type = type;
}
//
@Override
public boolean isArray () {
......@@ -27,13 +31,13 @@ public class PrimitiveShadowClass extends ShadowClass {
@Override
public boolean isInstance (ShadowObject obj) {
public boolean isInstance (final ShadowObject obj) {
return false;
}
@Override
public boolean isAssignableFrom (ShadowClass klass) {
public boolean isAssignableFrom (final ShadowClass klass) {
return equals (klass);
}
......@@ -70,7 +74,7 @@ public class PrimitiveShadowClass extends ShadowClass {
@Override
public String getName () {
return t.getClassName ();
return __type.getClassName ();
}
......@@ -105,8 +109,8 @@ public class PrimitiveShadowClass extends ShadowClass {
@Override
public FieldInfo getField (String fieldName) throws NoSuchFieldException {
throw new NoSuchFieldException (t.getClassName () + "." + fieldName);
public FieldInfo getField (final String fieldName) throws NoSuchFieldException {
throw new NoSuchFieldException (__type.getClassName () + "." + fieldName);
}
......@@ -118,10 +122,10 @@ public class PrimitiveShadowClass extends ShadowClass {
@Override
public MethodInfo getMethod (
String methodName, String [] argumentNames
final String methodName, final String [] argumentNames
) throws NoSuchMethodException {
throw new NoSuchMethodException (
t.getClassName () + "." + methodName + argumentNamesToString (argumentNames)
__type.getClassName () + "." + methodName + argumentNamesToString (argumentNames)
);
}
......@@ -139,9 +143,8 @@ public class PrimitiveShadowClass extends ShadowClass {
@Override
public FieldInfo getDeclaredField (String fieldName)
throws NoSuchFieldException {
throw new NoSuchFieldException (t.getClassName () + "." + fieldName);
public FieldInfo getDeclaredField (final String fieldName) throws NoSuchFieldException {
throw new NoSuchFieldException (__type.getClassName () + "." + fieldName);
}
......@@ -153,10 +156,10 @@ public class PrimitiveShadowClass extends ShadowClass {
@Override
public MethodInfo getDeclaredMethod (
String methodName, String [] argumentNames
final String methodName, final String [] argumentNames
) throws NoSuchMethodException {
throw new NoSuchMethodException (
t.getClassName () + "." + methodName + argumentNamesToString (argumentNames)
__type.getClassName () + "." + methodName + argumentNamesToString (argumentNames)
);
}
......
......@@ -5,10 +5,7 @@ import java.util.Formatter;
public abstract class ShadowClass extends ShadowObject {
private final int classId;
private final ShadowObject classLoader;
private final ShadowObject __classLoader;
//
......@@ -16,9 +13,7 @@ public abstract class ShadowClass extends ShadowObject {
final long netReference, final ShadowObject classLoader
) {
super (netReference, null);
this.classId = NetReferenceHelper.get_class_id (netReference);
this.classLoader = classLoader;
__classLoader = classLoader;
}
//
......@@ -27,12 +22,12 @@ public abstract class ShadowClass extends ShadowObject {
// No need to expose the interface to user