RFR: 8325362: Allow to create a simple in-memory input JavaFileObject [v2]
Jaikiran Pai
jpai at openjdk.org
Fri Mar 8 04:06:53 UTC 2024
On Thu, 7 Mar 2024 23:13:06 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:
>> There are many subtypes of `SimpleJavaFileObject` scattered through various codebases, majority of them looking like:
>>
>>
>> private static class JavaSource extends SimpleJavaFileObject {
>>
>> private String code;
>>
>> public JavaSource(String code) {
>> super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
>> this.code = code;
>> }
>>
>> @Override
>> public CharSequence getCharContent(boolean ignoreEncodingErrors) {
>> return code;
>> }
>> }
>>
>>
>> The proposal herein is a to add a factory method that would return an implementation of `SimpleJavaFileObject` based on the provided `URI` and source content.
>>
>> The CSR for this change is available for review here:
>> https://bugs.openjdk.org/browse/JDK-8327536
>
> Jan Lahoda has updated the pull request incrementally with six additional commits since the last revision:
>
> - Removing trailing whitespaces.
> - Updating tests to use the new SimpleJavaFileObject.forSource
> - Not using schema in the URI.
> - Using URI.create instead of new URI in the sample.
> - Reflecting review comments.
> - Adding a sample code snippet.
Thank you Jan for the updates. The javadoc changes look good to me.
-------------
PR Review: https://git.openjdk.org/jdk/pull/18149#pullrequestreview-1923986147
More information about the compiler-dev
mailing list