Commit 6d225ea9 authored by Lubomir Bulej's avatar Lubomir Bulej

Use the classInfo field of the InstrumentClassRequest

parent cd2aecda
...@@ -4,6 +4,7 @@ import ch.usi.dag.disl.DiSL; ...@@ -4,6 +4,7 @@ import ch.usi.dag.disl.DiSL;
import ch.usi.dag.disl.DiSL.CodeOption; import ch.usi.dag.disl.DiSL.CodeOption;
import ch.usi.dag.disl.DiSLException; import ch.usi.dag.disl.DiSLException;
import ch.usi.dag.disl.JavaNames; import ch.usi.dag.disl.JavaNames;
import ch.usi.dag.dislserver.Protocol.ClassInfo;
import ch.usi.dag.dislserver.Protocol.InstrumentClassRequest; import ch.usi.dag.dislserver.Protocol.InstrumentClassRequest;
import ch.usi.dag.dislserver.Protocol.InstrumentClassResponse; import ch.usi.dag.dislserver.Protocol.InstrumentClassResponse;
import ch.usi.dag.util.Strings; import ch.usi.dag.util.Strings;
...@@ -46,14 +47,16 @@ final class RequestProcessor { ...@@ -46,14 +47,16 @@ final class RequestProcessor {
public InstrumentClassResponse process (final InstrumentClassRequest request) { public InstrumentClassResponse process (final InstrumentClassRequest request) {
final byte [] classBytes = request.getClassBytes ().toByteArray (); final byte [] classBytes = request.getClassBytes ().toByteArray ();
final String className = __getClassName (request.getClassNameBytes ().toByteArray (), classBytes); final ClassInfo classInfo = request.getClassInfo ();
final String className = __getClassName (classInfo.getClassName (), classBytes);
final Set <CodeOption> options = CodeOption.setOf (request.getFlags ()); final Set <CodeOption> options = CodeOption.setOf (request.getFlags ());
"instrumenting class %s [%d bytes, %s]",
if (__log.debugIsLoggable ()) { if (__log.debugIsLoggable ()) {
__log.debug ( __log.debug (
"processing class %s of classloader %d [%d bytes, %s]",
className.isEmpty () ? "<unknown>" : className, className.isEmpty () ? "<unknown>" : className,
classBytes.length, Strings.join ("+", options) classInfo.getClassLoaderTag (), classBytes.length,
Strings.join ("+", options)
); );
} }
...@@ -112,21 +115,18 @@ final class RequestProcessor { ...@@ -112,21 +115,18 @@ final class RequestProcessor {
private static String __getClassName ( private static String __getClassName (
final byte [] nameBytes, final byte [] classBytes final String name, final byte [] classBytes
) { ) {
String result = Strings.EMPTY_STRING; if (!name.isEmpty ()) {
if (nameBytes.length > 0) { return name;
result = new String (nameBytes); } else {
} String result = JavaNames.getClassNameFromBytes (classBytes);
if (result.isEmpty ()) {
result = JavaNames.getClassNameFromBytes (classBytes);
if (result == null || result.isEmpty ()) { if (result == null || result.isEmpty ()) {
result = UUID.randomUUID ().toString (); result = UUID.randomUUID ().toString ();
} }
}
return result; return result;
}
} }
......
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