From dcc2ac504b013a720dc6520042427d964524cacb Mon Sep 17 00:00:00 2001 From: Markus Schmidt Date: Thu, 23 Nov 2023 21:13:45 +0100 Subject: [PATCH] fixed tests --- .../java/sootup/core/model/SootMethod.java | 4 +--- .../frontend/AsmMethodSourceTest.java | 22 +++++++++---------- .../java/core/views/JavaModuleView.java | 3 +-- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/sootup.core/src/main/java/sootup/core/model/SootMethod.java b/sootup.core/src/main/java/sootup/core/model/SootMethod.java index 155d79ff722..809a7adba6e 100644 --- a/sootup.core/src/main/java/sootup/core/model/SootMethod.java +++ b/sootup.core/src/main/java/sootup/core/model/SootMethod.java @@ -210,9 +210,7 @@ public boolean isSynchronized() { /** @return yes if this is the main method */ public boolean isMain(@Nonnull IdentifierFactory idf) { - return isPublic() - && isStatic() - && idf.isConstructorSubSignature(getSignature().getSubSignature()); + return isPublic() && isStatic() && idf.isMainSubSignature(getSignature().getSubSignature()); } /** We rely on the JDK class recognition to decide if a method is JDK method. */ 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 6e6e3cb0f4a..d5f54b0bacb 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 @@ -1,10 +1,10 @@ package sootup.java.bytecode.frontend; +import static junit.framework.Assert.assertTrue; import static junit.framework.TestCase.fail; import categories.Java8Test; import java.util.Arrays; -import org.junit.Ignore; import org.junit.Test; import org.junit.experimental.categories.Category; import sootup.core.model.SootClass; @@ -21,7 +21,6 @@ public class AsmMethodSourceTest { @Test - @Ignore("FIXME") public void testFix_StackUnderrun_convertPutFieldInsn_init() { double version = Double.parseDouble(System.getProperty("java.specification.version")); @@ -36,17 +35,18 @@ public void testFix_StackUnderrun_convertPutFieldInsn_init() { JavaView view = javaProject.createView(); + final JavaIdentifierFactory idf = JavaIdentifierFactory.getInstance(); JavaClassType mainClassSignature = - JavaIdentifierFactory.getInstance() - .getClassType("javax.management.NotificationBroadcasterSupport"); + idf.getClassType("javax.management.NotificationBroadcasterSupport"); MethodSignature mainMethodSignature = - JavaIdentifierFactory.getInstance() - .getMethodSignature( - mainClassSignature, - "", - "void", - Arrays.asList( - "java.util.concurrent.Executor", "javax.management.MBeanNotificationInfo[]")); + idf.getMethodSignature( + mainClassSignature, + "", + "void", + Arrays.asList( + "java.util.concurrent.Executor", "javax.management.MBeanNotificationInfo[]")); + + assertTrue(idf.isConstructorSubSignature(mainMethodSignature.getSubSignature())); final SootClass abstractClass = view.getClass(mainClassSignature).get(); diff --git a/sootup.java.core/src/main/java/sootup/java/core/views/JavaModuleView.java b/sootup.java.core/src/main/java/sootup/java/core/views/JavaModuleView.java index c434e537f57..95e70adc76d 100644 --- a/sootup.java.core/src/main/java/sootup/java/core/views/JavaModuleView.java +++ b/sootup.java.core/src/main/java/sootup/java/core/views/JavaModuleView.java @@ -31,7 +31,6 @@ import sootup.core.cache.FullCache; import sootup.core.cache.provider.FullCacheProvider; import sootup.core.frontend.AbstractClassSource; -import sootup.core.frontend.ResolveException; import sootup.core.inputlocation.AnalysisInputLocation; import sootup.core.inputlocation.ClassLoadingOptions; import sootup.core.inputlocation.EmptyClassLoadingOptions; @@ -118,7 +117,7 @@ private boolean isPackageVisibleToModule( Optional moduleInfoOpt = getModuleInfo(packageName.getModuleSignature()); if (!moduleInfoOpt.isPresent()) { - throw new ResolveException("ModuleDescriptor not available."); + throw new IllegalStateException("ModuleDescriptor not available."); } JavaModuleInfo moduleInfo = moduleInfoOpt.get();