From f29ba9f108b3e46afa4cbc57c28a93279f64eb9c Mon Sep 17 00:00:00 2001 From: Markus Schmidt Date: Mon, 9 Oct 2023 13:10:48 +0200 Subject: [PATCH] fix signature check of java9 with modules --- .../sootup/java/bytecode/frontend/AsmClassSource.java | 2 +- .../java/bytecode/frontend/AsmJavaClassProvider.java | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/sootup.java.bytecode/src/main/java/sootup/java/bytecode/frontend/AsmClassSource.java b/sootup.java.bytecode/src/main/java/sootup/java/bytecode/frontend/AsmClassSource.java index 3eb790769ef..e16269fcfde 100644 --- a/sootup.java.bytecode/src/main/java/sootup/java/bytecode/frontend/AsmClassSource.java +++ b/sootup.java.bytecode/src/main/java/sootup/java/bytecode/frontend/AsmClassSource.java @@ -168,7 +168,7 @@ public Optional resolveSuperclass() { if (classNode.superName == null) { return Optional.empty(); } - return Optional.ofNullable(AsmUtil.toJimpleClassType(classNode.superName)); + return Optional.of(AsmUtil.toJimpleClassType(classNode.superName)); } @Nonnull diff --git a/sootup.java.bytecode/src/main/java/sootup/java/bytecode/frontend/AsmJavaClassProvider.java b/sootup.java.bytecode/src/main/java/sootup/java/bytecode/frontend/AsmJavaClassProvider.java index 3c59658dd48..a2ececc5e70 100644 --- a/sootup.java.bytecode/src/main/java/sootup/java/bytecode/frontend/AsmJavaClassProvider.java +++ b/sootup.java.bytecode/src/main/java/sootup/java/bytecode/frontend/AsmJavaClassProvider.java @@ -59,13 +59,15 @@ public Optional> createClassSource( SootClassNode classNode = new SootClassNode(analysisInputLocation); try { - final String actualClassSignature = AsmUtil.initAsmClassSource(sourcePath, classNode); - if (!actualClassSignature.replace('/', '.').equals(classType.toString())) { + final String actualClassSignatureStr = + AsmUtil.initAsmClassSource(sourcePath, classNode).replace('/', '.'); + if (!actualClassSignatureStr.equals( + classType.getFullyQualifiedName())) { // in >Java9 omit the module part of the signature throw new IllegalArgumentException( "The given Classtype '" + classType + "' did not match the found ClassType in the compilation unit '" - + actualClassSignature + + actualClassSignatureStr + "'. Possibly the AnalysisInputLocation points to a subfolder already including the PackageName directory while the ClassType you wanted to retrieve is missing a PackageName."); } } catch (IOException | IllegalArgumentException exception) {