Skip to content

Commit 0fe1087

Browse files
committed
update for JAVA9 compliance
1 parent 3db821f commit 0fe1087

File tree

2 files changed

+27
-32
lines changed

2 files changed

+27
-32
lines changed

Diff for: processor/src/main/java/org/bsc/maven/plugin/processor/AnnotationProcessorCompiler.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -414,14 +414,12 @@ public void setLocale(Locale locale) {
414414
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
415415
}
416416

417-
// from JDK9
418-
//@Override
417+
@Override
419418
public void addModules(Iterable<String> moduleNames) {
420419
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
421420
}
422421

423-
// from JDK9
424-
//@Override
422+
@Override
425423
public Boolean call() {
426424
try {
427425
return execute(options, compilationUnits, out);

Diff for: test/src/main/java/org/bsc/maven/plugin/processor/test/TESTWikiProcessor.java

+25-28
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,27 @@
77

88
import org.bsc.processor.BaseAbstractProcessor;
99

10-
import java.io.IOException;
11-
import java.util.Set;
12-
13-
import javax.annotation.processing.*;
10+
import javax.annotation.processing.Filer;
11+
import javax.annotation.processing.RoundEnvironment;
12+
import javax.annotation.processing.SupportedAnnotationTypes;
13+
import javax.annotation.processing.SupportedSourceVersion;
1414
import javax.lang.model.SourceVersion;
1515
import javax.lang.model.element.Element;
1616
import javax.lang.model.element.ElementKind;
1717
import javax.lang.model.element.TypeElement;
18-
import javax.tools.Diagnostic.Kind;
1918
import javax.tools.FileObject;
2019
import javax.tools.StandardLocation;
20+
import java.io.IOException;
21+
import java.util.Set;
2122

2223
/**
2324
*
2425
* @author softphone
2526
*
2627
*
2728
*/
28-
//@SupportedSourceVersion(SourceVersion.RELEASE_9)
29-
@SupportedSourceVersion(SourceVersion.RELEASE_8)
29+
//@SupportedSourceVersion(SourceVersion.RELEASE_8)
30+
@SupportedSourceVersion(SourceVersion.RELEASE_9)
3031
@SupportedAnnotationTypes( "*" )
3132
//@SupportedOptions( {"subfolder", "filepath", "templateUri"})
3233
//@SupportedAnnotationTypes( {"javax.ws.rs.GET", "javax.ws.rs.PUT", "javax.ws.rs.POST", "javax.ws.rs.DELETE"})
@@ -39,50 +40,46 @@ public class TESTWikiProcessor extends BaseAbstractProcessor {
3940
* @throws IOException
4041
*/
4142
protected FileObject getResourceFormClassPath(Filer filer, final String resource, final String packageName) throws IOException {
42-
FileObject f = filer.getResource(StandardLocation.CLASS_PATH, packageName, resource);
43+
final FileObject f = filer.getResource(StandardLocation.CLASS_PATH, packageName, resource);
4344

4445
//java.io.Reader r = f.openReader(true); // ignoreEncodingErrors
45-
java.io.InputStream is = f.openInputStream();
46+
try(java.io.InputStream is = f.openInputStream()) {
4647

47-
if( is==null ) {
48-
warn( String.format("resource [%s] not found!", resource) );
49-
return null;
48+
if (is == null) {
49+
warn("resource [%s] not found!", resource);
50+
return null;
51+
}
5052
}
51-
5253
return f;
5354
}
5455

56+
/**
57+
*
58+
* @param annotations
59+
* @param roundEnv
60+
* @return
61+
*/
5562
@Override
5663
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
5764
if (roundEnv.processingOver()) return false;
5865

59-
6066
final java.util.Map<String,String> optionMap = processingEnv.getOptions();
6167

62-
System.out.println( "====> PROCESSOR RUN");
63-
for( java.util.Map.Entry<String,String> k : optionMap.entrySet() )
64-
System.out.printf( "\t[%s] = [%s]\n", k.getKey(), k.getValue());
65-
68+
info( "====> PROCESSOR RUN");
69+
optionMap.entrySet().forEach( k -> info( "\t[%s] = [%s]", k.getKey(), k.getValue()));
70+
6671
for( TypeElement e : annotations ) {
6772

68-
for (Element re : roundEnv.getElementsAnnotatedWith(e)) {
73+
for (Element re : roundEnv.getElementsAnnotatedWith(e)) {
6974

7075
if( re.getKind()==ElementKind.METHOD) {
7176

72-
info( String.format("[%s], Element [%s] is [%s] ", re.getEnclosingElement(), re.getKind(), re.getSimpleName()));
77+
info( "[%s], Element [%s] is [%s]", re.getEnclosingElement(), re.getKind(), re.getSimpleName() );
7378

7479
}
7580
}
7681
}
7782

78-
//final Filer filer = processingEnv.getFiler();
79-
80-
//FileObject res = getOutputFile(filer, subfolder, filePath);
81-
82-
//java.io.Writer w = res.openWriter();
83-
84-
//w.close();
85-
8683
return true;
8784
}
8885

0 commit comments

Comments
 (0)