On Fri, 6 Mar 2026 07:55:56 GMT, Jan Lahoda <[email protected]> wrote:

>>> After talking with Jan, this seemed the better option. What would the Filer 
>>> API have simplified here?
>> 
>> After some further consideration, I could give better guidance if I 
>> understood more about the overall architecture about how the annotation 
>> processor was being used in the build process and how the Valhalla build 
>> would be sequenced with this change.
>> 
>> I have not attempted to research how the Valhalla build differs from a 
>> mainline build, but I'm generally aware there is some kind of 
>> post-processing of classes in java.base to make them value classes in the 
>> Valhalla images output.
>> 
>> I think two basic approaches to running an annotation processor to aid the 
>> post processing would be:
>> 
>> 1) As an integrated part of the "base build", have the annotation processor 
>> run and generate the new source files in the chosen directory. (Is these 
>> were completely new files and new not meant to replace existing files in the 
>> output, the compilation of the new files could be handled as part of the 
>> built-in annotation processing compilation machinery).
>> 
>> 2) As a post-pass after the base build, scan over the source (or class 
>> files) in question and find the annotated classes to have replacements be 
>> generated.
>> 
>> For something closer to 1) the Filer has a few facilities to do extra 
>> checking and some infrastructure for concepts like the SOURCE_OUTPUT 
>> location.
>
> My understanding (possibly wrong) here was and is that the goal here is to 
> take the existing primary (non-preview) source for e.g. `java.lang.Byte`, and 
> produce a new source for the same class that adds the `value` keyword. This 
> new source is then compiled in a different/separate compilation. So that 
> there are two separate classfiles produced, one for the original source, and 
> one for the newly generated source. Filer didn't seem like a very good fit 
> for this task.
> 
> In a sense, the annotation processing here is used mostly as a vehicle to get 
> the source code model. Of course, there can be a question whether AP is the 
> right way to do it - we could simply run a Java-based generation task in the 
> Makefiles, like e.g. here: https://github.com/openjdk/jdk/pull/30072

@lahodaj We started with an explicit list of classes and a somewhat fragile 
makefile. 
Two places to update.   An extra pass over the source with fgrep probably could 
have made the list of classes more resiliant but an annotation processor and/or 
a javac plugin were suggested as possibilities.

-------------

PR Review Comment: 
https://git.openjdk.org/valhalla/pull/2180#discussion_r2895788186

Reply via email to