From 98835d700158fe908b5075ff39c37bd65012abe5 Mon Sep 17 00:00:00 2001 From: Swapnil Rustagi Date: Sat, 15 May 2021 17:09:58 +0530 Subject: [PATCH 1/2] Revert "More specifically matches lambda proxy class names." This reverts commit a0f1272cb2bd205bde3082ad73c82fdb5ae6a43d. --- .../tamiflex/playout/rt/ReflLogger.java | 25 +++++++------------ 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/PlayOutAgent/rtlib/de/bodden/tamiflex/playout/rt/ReflLogger.java b/PlayOutAgent/rtlib/de/bodden/tamiflex/playout/rt/ReflLogger.java index 48a7cd9..96c640d 100644 --- a/PlayOutAgent/rtlib/de/bodden/tamiflex/playout/rt/ReflLogger.java +++ b/PlayOutAgent/rtlib/de/bodden/tamiflex/playout/rt/ReflLogger.java @@ -160,24 +160,17 @@ public static void constructorMethodInvoke(Constructor c, Kind constructorMet try { StackTraceElement frame = getInvokingFrame(); String[] paramTypes = classesToTypeNames(c.getParameterTypes()); - String className = c.getDeclaringClass().getName(); - // If this is a lambda proxy class the className comes out in the form: - // ".$$Lambda$/", - // however, when we take its byte code to generate the class name (as happens when we - // dump the classes to disk) the name does not contain the "/". - // This logic below is to remove the hash code so the reflection log entries match - // the classes that are dumped and soot can process them. - if (className.contains("$$Lambda$")) + String declareClassName = c.getDeclaringClass().getName(); + // Lambda's declaring class name comes out as: ".$$Lambda$/", + // however we write out the lambda class as ".$$Lambda$.class" + // We need to remove "/" so the reflection log entry matches the class file name. + if (declareClassName.contains("$$Lambda$")) { - String slashHashCode = "/" + c.getDeclaringClass().hashCode(); - if (!className.endsWith(slashHashCode)) { - System.err.println("unexpected lambda proxy class: " + className); - } - else { - className = className.substring(0, className.length() - slashHashCode.length()); - } + int ignoreStart = declareClassName.lastIndexOf('/'); + if (ignoreStart != -1) + declareClassName = declareClassName.substring(0, ignoreStart); } - logAndIncrementTargetMethodEntry(frame.getClassName()+"."+frame.getMethodName(),frame.getLineNumber(),constructorMethodKind,className,"void","", c.isAccessible(), paramTypes); + logAndIncrementTargetMethodEntry(frame.getClassName()+"."+frame.getMethodName(),frame.getLineNumber(),constructorMethodKind,declareClassName,"void","", c.isAccessible(), paramTypes); } finally { leavingReflectionAPI(); From 97bc3e72db4bc37defaef81664aa0ab147fa7b3b Mon Sep 17 00:00:00 2001 From: Swapnil Rustagi Date: Sat, 15 May 2021 17:16:16 +0530 Subject: [PATCH 2/2] Generate stackMapTable for transformed classes --- .../src/de/bodden/tamiflex/playout/ReflectionMonitor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PlayOutAgent/src/de/bodden/tamiflex/playout/ReflectionMonitor.java b/PlayOutAgent/src/de/bodden/tamiflex/playout/ReflectionMonitor.java index f789f16..2d25780 100644 --- a/PlayOutAgent/src/de/bodden/tamiflex/playout/ReflectionMonitor.java +++ b/PlayOutAgent/src/de/bodden/tamiflex/playout/ReflectionMonitor.java @@ -77,7 +77,7 @@ public byte[] transform(ClassLoader loader, String className, try { final ClassReader creader = new ClassReader(classfileBuffer); - final ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS); + final ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES); ClassVisitor visitor = writer; for (AbstractTransformation transformation : transformations)