RFR: 8325362: Allow to create a simple in-memory input JavaFileObject
Jim Laskey
jlaskey at openjdk.org
Thu Mar 7 08:53:52 UTC 2024
On Thu, 7 Mar 2024 08:34:32 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
Should consider including an end to end compile a text block example. I for one am always hunting around for the model when I need it.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/18149#issuecomment-1982993882
More information about the compiler-dev
mailing list