Commit a9a2b980 authored by Lubomir Bulej's avatar Lubomir Bulej

Formatting changes to simplify subsequent merges.

parent 7e8d0ef5
......@@ -91,6 +91,11 @@ public final class AnalysisHandler implements RequestHandler {
}
// read argument values data according to argument types
//
// TODO LB: Consider keeping the result of getParameterTypes() in
// the AnalysisMethodHolder -- otherwise the method argument array
// is cloned on each invocation.
//
final Class <?> [] paramTypes = method.getParameterTypes ();
final Object [] args = new Object [paramTypes.length];
......
......@@ -11,28 +11,36 @@ import ch.usi.dag.dislreserver.shadow.ShadowClassTable;
import ch.usi.dag.dislreserver.shadow.ShadowObject;
import ch.usi.dag.dislreserver.shadow.ShadowObjectTable;
public class ClassInfoHandler implements RequestHandler {
public void handle(DataInputStream is, DataOutputStream os, boolean debug)
throws DiSLREServerException {
@Override
public void handle (
DataInputStream is, DataOutputStream os, boolean debug
) throws DiSLREServerException {
try {
long net_ref = is.readLong();
String classSignature = is.readUTF();
String classGenericStr = is.readUTF();
ShadowObject classLoader = ShadowObjectTable.get(is.readLong());
ShadowClass superClass = (ShadowClass) ShadowObjectTable.get(is
.readLong());
ShadowClassTable.newInstance(net_ref, superClass, classLoader,
classSignature, classGenericStr, debug);
long net_ref = is.readLong ();
String classSignature = is.readUTF ();
String classGenericStr = is.readUTF ();
ShadowObject classLoader = ShadowObjectTable.get (is.readLong ());
ShadowClass superClass = (ShadowClass) ShadowObjectTable.get (
is.readLong ()
);
ShadowClassTable.newInstance (
net_ref, superClass, classLoader, classSignature,
classGenericStr, debug
);
} catch (IOException e) {
throw new DiSLREServerException(e);
throw new DiSLREServerException (e);
}
}
public void exit() {
public void exit () {
}
}
......@@ -10,27 +10,29 @@ import ch.usi.dag.dislreserver.shadow.ShadowClassTable;
import ch.usi.dag.dislreserver.shadow.ShadowObject;
import ch.usi.dag.dislreserver.shadow.ShadowObjectTable;
public class NewClassHandler implements RequestHandler {
public void handle(DataInputStream is, DataOutputStream os, boolean debug)
throws DiSLREServerException {
public void handle (DataInputStream is, DataOutputStream os, boolean debug)
throws DiSLREServerException {
try {
String className = is.readUTF();
long oid = is.readLong();
ShadowObject classLoader = ShadowObjectTable.get(oid);
int classCodeLength = is.readInt();
byte[] classCode = new byte[classCodeLength];
is.readFully(classCode);
ShadowClassTable.load(classLoader, className, classCode, debug);
String className = is.readUTF ();
long oid = is.readLong ();
ShadowObject classLoader = ShadowObjectTable.get (oid);
int classCodeLength = is.readInt ();
byte [] classCode = new byte [classCodeLength];
is.readFully (classCode);
ShadowClassTable.load (classLoader, className, classCode, debug);
} catch (IOException e) {
throw new DiSLREServerException(e);
throw new DiSLREServerException (e);
}
}
public void exit() {
public void exit () {
}
......
......@@ -12,26 +12,27 @@ import ch.usi.dag.dislreserver.shadow.ShadowClassTable;
import ch.usi.dag.dislreserver.shadow.ShadowObjectTable;
import ch.usi.dag.dislreserver.shadow.ShadowString;
public class StringInfoHandler implements RequestHandler {
public void handle(DataInputStream is, DataOutputStream os, boolean debug)
throws DiSLREServerException {
public void handle (DataInputStream is, DataOutputStream os, boolean debug)
throws DiSLREServerException {
try {
long net_ref = is.readLong ();
String str = is.readUTF ();
long net_ref = is.readLong();
String str = is.readUTF();
ShadowClass klass = ShadowClassTable.get(NetReferenceHelper
.get_class_id(net_ref));
ShadowString sString = new ShadowString(net_ref, str, klass);
ShadowObjectTable.register(sString, debug);
ShadowClass klass = ShadowClassTable.get (NetReferenceHelper.get_class_id (net_ref));
ShadowString sString = new ShadowString (net_ref, str, klass);
ShadowObjectTable.register (sString, debug);
} catch (IOException e) {
throw new DiSLREServerException(e);
throw new DiSLREServerException (e);
}
}
public void exit() {
public void exit () {
}
......
......@@ -12,29 +12,34 @@ import ch.usi.dag.dislreserver.shadow.ShadowClassTable;
import ch.usi.dag.dislreserver.shadow.ShadowObjectTable;
import ch.usi.dag.dislreserver.shadow.ShadowThread;
public class ThreadInfoHandler implements RequestHandler {
public void handle(DataInputStream is, DataOutputStream os, boolean debug)
throws DiSLREServerException {
public void handle (DataInputStream is, DataOutputStream os, boolean debug)
throws DiSLREServerException {
try {
long net_ref = is.readLong();
String name = is.readUTF();
boolean isDaemon = is.readBoolean();
ShadowClass klass = ShadowClassTable.get(NetReferenceHelper
.get_class_id(net_ref));
ShadowThread sThread = new ShadowThread(net_ref, name, isDaemon,
klass);
ShadowObjectTable.register(sThread, debug);
long net_ref = is.readLong ();
String name = is.readUTF ();
boolean isDaemon = is.readBoolean ();
ShadowClass klass = ShadowClassTable.get (
NetReferenceHelper.get_class_id (net_ref)
);
ShadowThread sThread = new ShadowThread (
net_ref, name, isDaemon, klass
);
ShadowObjectTable.register (sThread, debug);
} catch (IOException e) {
throw new DiSLREServerException(e);
throw new DiSLREServerException (e);
}
}
public void exit() {
public void exit () {
}
}
......@@ -3,40 +3,50 @@ package ch.usi.dag.dislreserver.shadow;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.FieldNode;
public class FieldInfo {
// TODO ! is this implementation of methods really working ??
private FieldNode fieldNode;
private int modifiers;
private String name;
private String type;
public FieldInfo(FieldNode fieldNode) {
public FieldInfo (FieldNode fieldNode) {
this.fieldNode = fieldNode;
name = fieldNode.name;
type = fieldNode.desc;
modifiers = fieldNode.access;
}
public FieldNode getFieldNode() {
public FieldNode getFieldNode () {
return fieldNode;
}
public String getName() {
public String getName () {
return name;
}
public int getModifiers() {
public int getModifiers () {
return modifiers;
}
public String getType() {
public String getType () {
return type;
}
public boolean isPublic() {
public boolean isPublic () {
return (modifiers & Opcodes.ACC_PUBLIC) != 0;
}
}
......@@ -6,62 +6,75 @@ import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.MethodNode;
public class MethodInfo {
// TODO ! is this implementation of methods really working ??
private MethodNode methodNode;
private int modifiers;
private String name;
private String returnType;
private String[] parameterTypes;
private String[] exceptionTypes;
public MethodInfo(MethodNode methodNode) {
private String [] parameterTypes;
private String [] exceptionTypes;
public MethodInfo (MethodNode methodNode) {
this.methodNode = methodNode;
name = methodNode.name;
modifiers = methodNode.access;
returnType = methodNode.desc
.substring(methodNode.desc.indexOf(')') + 1);
returnType = methodNode.desc.substring (methodNode.desc.indexOf (')') + 1);
Type[] parameters = Type.getArgumentTypes(methodNode.desc);
Type [] parameters = Type.getArgumentTypes (methodNode.desc);
int size = parameters.length;
parameterTypes = new String[size];
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() {
public MethodNode getMethodNode () {
return methodNode;
}
public String getName() {
public String getName () {
return name;
}
public int getModifiers() {
public int getModifiers () {
return modifiers;
}
public String getReturnType() {
public String getReturnType () {
return returnType;
}
public String[] getParameterTypes() {
return Arrays.copyOf(parameterTypes, parameterTypes.length);
public String [] getParameterTypes () {
return Arrays.copyOf (parameterTypes, parameterTypes.length);
}
public String[] getExceptionTypes() {
return Arrays.copyOf(exceptionTypes, exceptionTypes.length);
public String [] getExceptionTypes () {
return Arrays.copyOf (exceptionTypes, exceptionTypes.length);
}
public boolean isPublic() {
public boolean isPublic () {
return (modifiers & Opcodes.ACC_PUBLIC) != 0;
}
}
......@@ -2,30 +2,36 @@ package ch.usi.dag.dislreserver.shadow;
import java.util.Formatter;
// TODO ShadowString should better handle if String data are not send
// over network - throw a runtime exception ??
// over network - throw a runtime exception ??
public class ShadowString extends ShadowObject {
private String value;
public ShadowString(long net_ref, String value, ShadowClass klass) {
super(net_ref, klass);
public ShadowString (
long net_ref, String value, ShadowClass klass
) {
super (net_ref, klass);
this.value = value;
}
// TODO warn user that it will return null when the ShadowString is not yet
// sent.
// TODO warn user that it will return null when the ShadowString is not yet sent.
@Override
public String toString() {
public String toString () {
return value;
}
void setValue(String value) {
void setValue (String value) {
this.value = value;
}
@Override
public boolean equals(final Object obj) {
public boolean equals (final Object obj) {
// FIXME LB: This needs a comment!
if (super.equals (obj)) {
if (obj instanceof ShadowString) {
......@@ -39,8 +45,9 @@ public class ShadowString extends ShadowObject {
return false;
}
@Override
public int hashCode() {
public int hashCode () {
//
// If two shadow strings are considered equal by the above equals()
// method, then they certainly have the same hash code, because it
......@@ -53,6 +60,7 @@ public class ShadowString extends ShadowObject {
return super.hashCode ();
}
//
@Override
......
......@@ -3,38 +3,44 @@ package ch.usi.dag.dislreserver.shadow;
import java.util.Formattable;
import java.util.Formatter;
// TODO ShadowTrhead should better handle if String data are not send
// over network - throw a runtime exception ??
// over network - throw a runtime exception ??
public class ShadowThread extends ShadowObject implements Formattable {
private String name;
private String name;
private boolean isDaemon;
public ShadowThread(long net_ref, String name, boolean isDaemon,
ShadowClass klass) {
super(net_ref, klass);
public ShadowThread (
long net_ref, String name, boolean isDaemon, ShadowClass klass
) {
super (net_ref, klass);
this.name = name;
this.isDaemon = isDaemon;
}
// TODO warn user that it will return null when the ShadowThread is not yet
// sent.
public String getName() {
// TODO warn user that it will return null when the ShadowThread is not yet sent.
public String getName () {
return name;
}
// TODO warn user that it will return false when the ShadowThread is not yet
// sent.
public boolean isDaemon() {
// TODO warn user that it will return false when the ShadowThread is not yet sent.
public boolean isDaemon () {
return isDaemon;
}
public void setName(String name) {
public void setName (String name) {
this.name = name;
}
public void setDaemon(boolean isDaemon) {
public void setDaemon (boolean isDaemon) {
this.isDaemon = isDaemon;
}
......@@ -58,7 +64,7 @@ public class ShadowThread extends ShadowObject implements Formattable {
@Override
public int hashCode() {
public int hashCode () {
//
// TODO LB: Check ShadowThread.hashCode() -- it's needed.
//
......@@ -73,13 +79,14 @@ public class ShadowThread extends ShadowObject implements Formattable {
return super.hashCode ();
}
//
@Override
public void formatTo (
final Formatter formatter,
final int flags, final int width, final int precision
) {
) {
super.formatTo (formatter, flags, width, precision);
formatter.format (" <%s>", (name != null) ? name : "unknown");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment