Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8325362

Allow to create a simple in-memory input JavaFileObject

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P3 P3
    • 23
    • 23
    • tools
    • b15

      Very commonly, a JavaFileObject is needed as the initial input for compilation using JavaCompiler.getTask. Often, classes like this are created:
      ---

          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;
              }
          }
      ---

      It would be nice to have some more general support to create input-only source JavaFileObject.

            jlahoda Jan Lahoda
            jlahoda Jan Lahoda
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: