Skip to content

Commit

Permalink
block injection at method layer for LogNothing mode
Browse files Browse the repository at this point in the history
  • Loading branch information
kartikeytewari-ul committed Aug 27, 2024
1 parent c050204 commit 3886516
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/main/java/io/unlogged/core/bytecode/ClassTransformer.java
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public void visit(int version, int access, String name, String signature,
className = name.substring(index + 1);
}

this.addHashMap = ProbeFlagUtil.getAddHashMap(access);
this.addHashMap = ProbeFlagUtil.getAddHashMap(this.unloggedProcessorConfig, access);
super.visit(version, access, name, signature, superName, interfaces);
}

Expand Down Expand Up @@ -233,7 +233,7 @@ public MethodVisitor visitMethod(int access, String name, String desc, String si

// calculate probe flag at method level
Boolean alwaysProbeMethodFlag = !this.addHashMap || ProbeFlagUtil.getAlwaysProbeMethodFlag(name, access, desc);
Boolean neverProbeMethodFlag = ProbeFlagUtil.getNeverProbeMethodFlag(name, access);
Boolean neverProbeMethodFlag = ProbeFlagUtil.getNeverProbeMethodFlag(this.unloggedProcessorConfig, name, access);

if (name.equals("<clinit>")) {
// early exit for clinit. It is already defined in class with initial method
Expand Down
18 changes: 14 additions & 4 deletions src/main/java/io/unlogged/util/ProbeFlagUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,25 @@

import org.objectweb.asm.Opcodes;

import io.unlogged.UnloggedMode;
import io.unlogged.core.processor.UnloggedProcessorConfig;

public class ProbeFlagUtil {

public static boolean getAddHashMap(int access) {
public static boolean getAddHashMap(UnloggedProcessorConfig unloggedProcessorConfig, int access) {
// TODO: remove this filter
// decide if a Hashmap is to be added in static call of the class
// always probe a default method in interface, because we cannot add a hashmap to the interface

if (((access & Opcodes.ACC_INTERFACE) != 0)
if (unloggedProcessorConfig.getUnloggedMode() == UnloggedMode.LogNothing) {
return false;
}
else if (((access & Opcodes.ACC_INTERFACE) != 0)
|| ((access & Opcodes.ACC_ENUM) != 0)){
// do not add a hash map
return false;
}

return true;
}

Expand All @@ -30,9 +37,12 @@ public static boolean getAlwaysProbeMethodFlag(String methodName, int access, St
return false;
}

public static Boolean getNeverProbeMethodFlag (String methodName, int access) {
public static Boolean getNeverProbeMethodFlag (UnloggedProcessorConfig unloggedProcessorConfig, String methodName, int access) {

if (methodName.equals("equals")
if (unloggedProcessorConfig.getUnloggedMode() == UnloggedMode.LogNothing) {
return true;
}
else if (methodName.equals("equals")
|| methodName.equals("hashCode")
|| methodName.equals("onNext")
|| methodName.equals("onSubscribe")
Expand Down

0 comments on commit 3886516

Please sign in to comment.