reg = builder.getPackageRegistry( pkgDescr.getName() ).getDialectCompiletimeRegistry();
Dialect dialect = reg.getDialect( dialectName );
final Field compilerField = dialect.getClass().getDeclaredField( "compiler" );
compilerField.setAccessible( true );
JavaCompiler compiler = (JavaCompiler) compilerField.get( dialect );
assertSame( EclipseJavaCompiler.class,
compiler.getClass() );
// test JANINO with property settings
PackageBuilderConfiguration conf = new PackageBuilderConfiguration();
JavaDialectConfiguration javaConf = (JavaDialectConfiguration) conf.getDialectConfiguration( "java" );
javaConf.setCompiler( JavaDialectConfiguration.JANINO );
builder = new PackageBuilder( conf );
builder.addPackage( pkgDescr );
dialectName = (String) dialectField.get( builder );
reg = builder.getPackageRegistry( pkgDescr.getName() ).getDialectCompiletimeRegistry();
dialect = reg.getDialect( dialectName );
compiler = (JavaCompiler) compilerField.get( dialect );
assertSame( JaninoJavaCompiler.class,
compiler.getClass() );
// test eclipse jdt core with property settings and default source level
conf = new PackageBuilderConfiguration();
javaConf = (JavaDialectConfiguration) conf.getDialectConfiguration( "java" );
javaConf.setCompiler( JavaDialectConfiguration.ECLIPSE );
builder = new PackageBuilder( conf );
builder.addPackage( pkgDescr );
dialectName = (String) dialectField.get( builder );
reg = builder.getPackageRegistry( pkgDescr.getName() ).getDialectCompiletimeRegistry();
dialect = reg.getDialect( dialectName );
compiler = (JavaCompiler) compilerField.get( dialect );
assertSame( EclipseJavaCompiler.class,
compiler.getClass() );
}