Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,21 @@ public static String[] buildCompilerArguments( CompilerConfiguration config, Str
args.add( buffer.toString() );
}
if ( config.getProcessorPathEntries() != null && !config.getProcessorPathEntries().isEmpty() ) {
args.add( "-processorpath" );

if(!isPreJava9(config) && Arrays.asList(sourceFiles).contains("module-info.java")){
args.add( "--processor-module-path" );

} else {
args.add( "-processorpath" );

}
args.add( getPathString( config.getProcessorPathEntries() ) );
}

}



if ( config.isOptimize() )
{
args.add( "-O" );
Expand Down Expand Up @@ -432,29 +441,59 @@ private static boolean isPreJava14( CompilerConfiguration config )
*/
private static boolean isPreJava16( CompilerConfiguration config )
{
String v = config.getCompilerVersion();
String v = config.getReleaseVersion();

if ( v == null )
{
//mkleint: i haven't completely understood the reason for the
//compiler version parameter, checking source as well, as most projects will have this one set, not the compiler
String s = config.getSourceVersion();
if ( s == null )
{
//now return true, as the 1.6 version is not the default - 1.4 is.
return true;
}
return s.startsWith( "1.5" ) || s.startsWith( "1.4" ) || s.startsWith( "1.3" ) || s.startsWith( "1.2" )
|| s.startsWith( "1.1" ) || s.startsWith( "1.0" );
v = config.getCompilerVersion();
}

return v.startsWith( "1.5" ) || v.startsWith( "1.4" ) || v.startsWith( "1.3" ) || v.startsWith( "1.2" )
if ( v == null )
{
v = config.getSourceVersion();
}

if ( v == null )
{
return true;
}

return v.startsWith( "5" ) || v.startsWith( "1.5" ) || v.startsWith( "1.4" ) || v.startsWith( "1.3" ) || v.startsWith( "1.2" )
|| v.startsWith( "1.1" ) || v.startsWith( "1.0" );
}

private static boolean isPreJava18( CompilerConfiguration config )
{
String v = config.getCompilerVersion();
String v = config.getReleaseVersion();

if ( v == null )
{
v = config.getCompilerVersion();
}

if ( v == null )
{
v = config.getSourceVersion();
}

if ( v == null )
{
return true;
}

return v.startsWith( "7" ) || v.startsWith( "1.7" ) || v.startsWith( "6" ) ||v.startsWith( "1.6" ) || v.startsWith( "1.5" ) || v.startsWith( "1.4" )
|| v.startsWith( "1.3" ) || v.startsWith( "1.2" ) || v.startsWith( "1.1" ) || v.startsWith( "1.0" );
}

private static boolean isPreJava9( CompilerConfiguration config )
{

String v = config.getReleaseVersion();

if ( v == null )
{
v = config.getCompilerVersion();
}

if ( v == null )
{
Expand All @@ -466,7 +505,7 @@ private static boolean isPreJava18( CompilerConfiguration config )
return true;
}

return v.startsWith( "1.7" ) || v.startsWith( "1.6" ) || v.startsWith( "1.5" ) || v.startsWith( "1.4" )
return v.startsWith( "8" ) || v.startsWith( "1.8" ) || v.startsWith( "7" ) || v.startsWith( "1.7" ) || v.startsWith( "1.6" ) || v.startsWith( "1.5" ) || v.startsWith( "1.4" )
|| v.startsWith( "1.3" ) || v.startsWith( "1.2" ) || v.startsWith( "1.1" ) || v.startsWith( "1.0" );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,13 @@ protected Collection<String> expectedOutputFiles()
"org/codehaus/foo/Person.class", "org/codehaus/foo/ReservedWord.class" } );
}

public void internalTest( CompilerConfiguration compilerConfiguration, List<String> expectedArguments )
public void internalTest(CompilerConfiguration compilerConfiguration, List<String> expectedArguments) {
internalTest(compilerConfiguration, expectedArguments, new String[0]);
}

public void internalTest(CompilerConfiguration compilerConfiguration, List<String> expectedArguments, String[] sources)
{
String[] actualArguments = JavacCompiler.buildCompilerArguments( compilerConfiguration, new String[0] );
String[] actualArguments = JavacCompiler.buildCompilerArguments( compilerConfiguration, sources );

assertEquals( "The expected and actual argument list sizes differ.", expectedArguments.size(),
actualArguments.length );
Expand Down Expand Up @@ -261,6 +265,40 @@ public void testJRuntimeArguments()
internalTest( compilerConfiguration, expectedArguments );
}

public void testModulePathAnnotations() throws Exception
{
List<String> expectedArguments = new ArrayList<>();

CompilerConfiguration compilerConfiguration = new CompilerConfiguration();

final String[] source = {"module-info.java"};

// outputLocation
compilerConfiguration.setOutputLocation( "/output" );
expectedArguments.add( "-d" );
expectedArguments.add( new File( "/output" ).getAbsolutePath() );

// failOnWarning
compilerConfiguration.setModulepathEntries( Arrays.asList( "/repo/a/b/1.0/b-1.0.jar",
"/repo/c/d/1.0/d-1.0.jar" ) );
expectedArguments.add( "--module-path" );
expectedArguments.add( "/repo/a/b/1.0/b-1.0.jar" + File.pathSeparator +
"/repo/c/d/1.0/d-1.0.jar" + File.pathSeparator );

compilerConfiguration.setProcessorPathEntries(Arrays.asList("/repo/a/b/1.0/annotations-1.0.jar",
"/repo/f/a/1.0/annotations-4.0.jar"));
expectedArguments.add( "--processor-module-path" );
expectedArguments.add("/repo/a/b/1.0/annotations-1.0.jar" + File.pathSeparator +
"/repo/f/a/1.0/annotations-4.0.jar" + File.pathSeparator );

// releaseVersion
compilerConfiguration.setReleaseVersion( "9" );
expectedArguments.add( "--release" );
expectedArguments.add( "9" );

internalTest( compilerConfiguration, expectedArguments, source);
}

public void testModulePath() throws Exception
{
List<String> expectedArguments = new ArrayList<>();
Expand Down