JDK-8345622 : test/langtools/tools/javac/annotations/parameter/ParameterAnnotations.java should set processorpath to work correctly in the agentvm mode
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 24,25
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2024-12-05
  • Updated: 2024-12-25
  • Resolved: 2024-12-12
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 25
25 b03Fixed
Related Reports
Relates :  
Description
When I was disabling previews for JDK-8334733, I noted in `test/langtools/tools/javac/annotations/parameter/ParameterAnnotations.java`, if the `TestAP` processor is passed as a command line argument like
```
"-processor", TestAP.class.getName(),
```
in options, it succeeds with previews enabled, and fails with previews disabled like:

```
test: testInnerClass
[DIRECT]:
- compiler.err.proc.processor.not.found: ParameterAnnotations$TestAP
- compiler.err.proc.no.explicit.annotation.processing.requested: T$I
2 errors
Exception running test testInnerClass: toolbox.Task$TaskError: Task javac failed: rc=1
toolbox.Task$TaskError: Task javac failed: rc=1
        at toolbox.AbstractTask.checkExit(AbstractTask.java:154)
        at toolbox.JavacTask.run(JavacTask.java:381)
        at toolbox.AbstractTask.run(AbstractTask.java:102)
        at toolbox.JavacTask.run(JavacTask.java:52)
        at toolbox.JavacTask.run(JavacTask.java:321)
        at ParameterAnnotations.doTest(ParameterAnnotations.java:650)
        at ParameterAnnotations.testInnerClass(ParameterAnnotations.java:151)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
        at java.base/java.lang.reflect.Method.invoke(Method.java:565)
        at toolbox.TestRunner.runTests(TestRunner.java:91)
        at ParameterAnnotations.runTests(ParameterAnnotations.java:82)
        at ParameterAnnotations.main(ParameterAnnotations.java:73)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
        at java.base/java.lang.reflect.Method.invoke(Method.java:565)
        at com.sun.javatest.regtest.agent.MainActionHelper$AgentVMRunnable.run(MainActionHelper.java:333)
        at java.base/java.lang.Thread.run(Thread.java:1447)
```

This might be related to our recent tightening of annotation processor policies, but it should not be less strict when preview is on.
Comments
Changeset: 1bdb7b42 Branch: master Author: Jan Lahoda <jlahoda@openjdk.org> Date: 2024-12-12 11:59:45 +0000 URL: https://git.openjdk.org/jdk/commit/1bdb7b4271098b02ee225c101ea7a12a432d0440
12-12-2024

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/22676 Date: 2024-12-11 08:48:21 +0000
11-12-2024

Sorry, I've forgot to write here. This is purely a test configuration issue, where there's a slight difference between running tests in the othervm mode (which is triggered by @enablePreview), and agentvm mode. In the othervm mode, the test is load by an app ClassLoader, and so javac can find the AP using a ServiceLoader that delegates to the app CL. In the agentvm mode, the test is load using a custom ClassLoader, and the (unconfigured) ServiceLoader cannot load classes from it. The solution is to simply use `-processorpath`, or something similar.
10-12-2024

The regression test in question uses a JavacTask to setup and invoke the compiler. It is feasible the is-annotation-processing-explicitly-requested check that interacts with the check in JDK-8321314 (and earlier changes in JDK-8310061) has a bug along the task-based code path.
10-12-2024