Search in sources :

Example 1 with SourceVersion

use of com.google.devtools.j2objc.util.SourceVersion in project j2objc by google.

the class JavacParser method getJavacOptions.

private List<String> getJavacOptions(boolean processAnnotations) {
    List<String> javacOptions = new ArrayList<>();
    String encoding = options.fileUtil().getFileEncoding();
    if (encoding != null) {
        javacOptions.add("-encoding");
        javacOptions.add(encoding);
    }
    SourceVersion javaLevel = options.getSourceVersion();
    if (javaLevel != null) {
        javacOptions.add("-source");
        javacOptions.add(javaLevel.flag());
        javacOptions.add("-target");
        javacOptions.add(javaLevel.flag());
    }
    String lintArgument = options.lintArgument();
    if (lintArgument != null) {
        javacOptions.add(lintArgument);
    }
    String explicitProcessors = options.getProcessors();
    if (explicitProcessors != null) {
        javacOptions.add("-processor");
        javacOptions.add(explicitProcessors);
    }
    if (processAnnotations) {
        javacOptions.add("-proc:only");
    } else {
        javacOptions.add("-proc:none");
    }
    javacOptions.addAll(options.getPlatformModuleSystemOptions());
    return javacOptions;
}
Also used : ArrayList(java.util.ArrayList) SourceVersion(com.google.devtools.j2objc.util.SourceVersion)

Example 2 with SourceVersion

use of com.google.devtools.j2objc.util.SourceVersion in project j2objc by google.

the class Options method postProcessSourceVersion.

private void postProcessSourceVersion() {
    if (sourceVersion == null) {
        sourceVersion = SourceVersion.defaultVersion();
    }
    if (allVersions) {
        // Warn if using known but unsupported version.
        if (sourceVersion.version() > SourceVersion.getMaxSupportedVersion().version()) {
            ErrorUtil.warning("Using unsupported version: " + sourceVersion.version());
        }
    } else {
        SourceVersion maxVersion = SourceVersion.getMaxSupportedVersion();
        if (sourceVersion.version() > maxVersion.version()) {
            ErrorUtil.warning("Java " + sourceVersion.version() + " is not installed, using Java " + maxVersion.version() + " as source version.");
            sourceVersion = maxVersion;
        }
    }
    if (sourceVersion.version() > 8) {
        // Allow the modularized JRE to read the J2ObjC annotations (they are in the unnamed module).
        addPlatformModuleSystemOptions("--add-reads", "java.base=ALL-UNNAMED");
    } else {
        platformModuleSystemOptions.clear();
    }
}
Also used : SourceVersion(com.google.devtools.j2objc.util.SourceVersion)

Aggregations

SourceVersion (com.google.devtools.j2objc.util.SourceVersion)2 ArrayList (java.util.ArrayList)1