Skip to content

Commit

Permalink
Fix incorrect handling of getPackageName in ClassModel
Browse files Browse the repository at this point in the history
`getPackageName` is available only from java version 9, thus it has a dedicated test. It seems tests on a specific java version are not executed in the CI pipeline, thus we didn't spot the mistake
  • Loading branch information
capoz authored and JorenHannes committed Jan 13, 2025
1 parent 8339ae6 commit 71ef057
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ MethodResult getCanonicalName(ModelHelper.MethodExecutionContext context) {
MethodResult getPackageName(ModelHelper.MethodExecutionContext context) {
if (clazz == null) return MethodResult.invalidResult();
return ModelHelper.createDefaultReturnResult(
context, ClassUtil.externalPackageName(clazz.getName()));
context, ClassUtil.externalPackageName(ClassUtil.externalClassName(clazz.getName())));
}

/** Models {@link Class#getTypeName()}. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import proguard.classfile.visitor.NamedMethodVisitor
import proguard.evaluation.ExecutingInvocationUnit
import proguard.evaluation.PartialEvaluator
import proguard.evaluation.ParticularReferenceValueFactory
import proguard.evaluation.executor.model.ClassModelExecutor
import proguard.evaluation.value.ArrayReferenceValueFactory
import proguard.evaluation.value.ParticularValueFactory
import proguard.evaluation.value.`object`.model.ClassModel
Expand Down Expand Up @@ -59,6 +60,7 @@ class Java9ReflectionApiExecutorTest : BehaviorSpec({
.setEnableSameInstanceIdApproximation(true)
.useDefaultStringReflectionExecutor(true)
.addExecutor(JavaReflectionApiExecutor.Builder(programClassPool, libraryClassPool))
.addExecutor(ClassModelExecutor.Builder(programClassPool, libraryClassPool))
.build(particularValueFactory),
)
.setEvaluateAllCode(true)
Expand Down

0 comments on commit 71ef057

Please sign in to comment.