RFR: 8325362: Allow to create a simple in-memory input JavaFileObject

Jaikiran Pai jpai at openjdk.org
Thu Mar 7 10:51:59 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

src/java.compiler/share/classes/javax/tools/SimpleJavaFileObject.java line 228:

> 226: 
> 227:     /**
> 228:      * Creates a {@link JavaFileObject} which will be represents the given source content.

Hello Jan, should this have been `which represents the given source content.` ?

src/java.compiler/share/classes/javax/tools/SimpleJavaFileObject.java line 235:

> 233:      *
> 234:      * <p>All other methods will behave as described in the documentation in this class,
> 235:      * if the constructor is called with {@code uri} and {@code Kind.SOURCE}.

Should this have been `as if the constructor ...`

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

PR Review Comment: https://git.openjdk.org/jdk/pull/18149#discussion_r1515949515
PR Review Comment: https://git.openjdk.org/jdk/pull/18149#discussion_r1515949948


More information about the compiler-dev mailing list