From f139b8e2c134b86ac3bacfaf6578039709edd430 Mon Sep 17 00:00:00 2001 From: "M.Schmidt" Date: Wed, 31 Jan 2024 17:21:49 +0100 Subject: [PATCH] incorporate PR feedback --- .../java/sootup/core/IdentifierFactory.java | 4 +++- .../bytecode/frontend/AsmMethodSourceTest.java | 3 ++- .../sootup/java/core/JavaIdentifierFactory.java | 17 ++++++++++------- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/sootup.core/src/main/java/sootup/core/IdentifierFactory.java b/sootup.core/src/main/java/sootup/core/IdentifierFactory.java index eb3447d4b7d..ceb8c1256c9 100644 --- a/sootup.core/src/main/java/sootup/core/IdentifierFactory.java +++ b/sootup.core/src/main/java/sootup/core/IdentifierFactory.java @@ -246,7 +246,9 @@ FieldSignature getFieldSignature( boolean isStaticInitializerSubSignature(@Nonnull MethodSubSignature methodSubSignature); - boolean isConstructorSubSignature(@Nonnull MethodSignature methodSignature); + boolean isConstructorSignature(@Nonnull MethodSignature methodSignature); + + boolean isConstructorSubSignature(@Nonnull MethodSubSignature methodSubSignature); boolean isMainSubSignature(@Nonnull MethodSubSignature methodSubSignature); } diff --git a/sootup.java.bytecode/src/test/java/sootup/java/bytecode/frontend/AsmMethodSourceTest.java b/sootup.java.bytecode/src/test/java/sootup/java/bytecode/frontend/AsmMethodSourceTest.java index 54104c0e189..9bc9c6e1ec8 100644 --- a/sootup.java.bytecode/src/test/java/sootup/java/bytecode/frontend/AsmMethodSourceTest.java +++ b/sootup.java.bytecode/src/test/java/sootup/java/bytecode/frontend/AsmMethodSourceTest.java @@ -39,7 +39,8 @@ public void testFix_StackUnderrun_convertPutFieldInsn_init() { Arrays.asList( "java.util.concurrent.Executor", "javax.management.MBeanNotificationInfo[]")); - assertTrue(idf.isConstructorSubSignature(mainMethodSignature)); + assertTrue(idf.isConstructorSignature(mainMethodSignature)); + assertTrue(idf.isConstructorSubSignature(mainMethodSignature.getSubSignature())); final SootClass abstractClass = view.getClass(mainClassSignature).get(); diff --git a/sootup.java.core/src/main/java/sootup/java/core/JavaIdentifierFactory.java b/sootup.java.core/src/main/java/sootup/java/core/JavaIdentifierFactory.java index c3286ed3135..f5bd6c16012 100644 --- a/sootup.java.core/src/main/java/sootup/java/core/JavaIdentifierFactory.java +++ b/sootup.java.core/src/main/java/sootup/java/core/JavaIdentifierFactory.java @@ -55,20 +55,23 @@ public class JavaIdentifierFactory implements IdentifierFactory { @Nonnull private static final JavaIdentifierFactory INSTANCE = new JavaIdentifierFactory(); @Nonnull - public final MethodSubSignature STATIC_INITIALIZER = + public static final MethodSubSignature STATIC_INITIALIZER = new MethodSubSignature("", Collections.emptyList(), VoidType.getInstance()); @Override public boolean isStaticInitializerSubSignature(@Nonnull MethodSubSignature methodSubSignature) { - return methodSubSignature.getName().equals("") - && methodSubSignature.getParameterTypes().isEmpty() - && methodSubSignature.getType() == VoidType.getInstance(); + return methodSubSignature.equals(STATIC_INITIALIZER); } @Override - public boolean isConstructorSubSignature(@Nonnull MethodSignature methodSignature) { - return methodSignature.getName().equals("") - && methodSignature.getType() == VoidType.getInstance(); + public boolean isConstructorSignature(@Nonnull MethodSignature methodSignature) { + return isConstructorSubSignature(methodSignature.getSubSignature()); + } + + @Override + public boolean isConstructorSubSignature(@Nonnull MethodSubSignature methodSubSignature) { + return methodSubSignature.getName().equals("") + && methodSubSignature.getType() == VoidType.getInstance(); } @Override