JDK 10 RFR of JDK-8146726: Refactor AbstractProcessor to use Set.of and related methods
joe darcy
joe.darcy at oracle.com
Thu Oct 26 18:17:09 UTC 2017
Hello,
With JDK 9 APIs now available for use in java.compiler, please the patch
below to address
JDK-8146726: Refactor AbstractProcessor to use Set.of and related
methods
Thanks,
-Joe
diff -r fd458b0b7749
src/java.compiler/share/classes/javax/annotation/processing/AbstractProcessor.java
---
a/src/java.compiler/share/classes/javax/annotation/processing/AbstractProcessor.java
Wed Oct 25 10:40:45 2017 -0700
+++
b/src/java.compiler/share/classes/javax/annotation/processing/AbstractProcessor.java
Thu Oct 26 11:15:58 2017 -0700
@@ -80,10 +80,7 @@
*/
public Set<String> getSupportedOptions() {
SupportedOptions so =
this.getClass().getAnnotation(SupportedOptions.class);
- if (so == null)
- return Collections.emptySet();
- else
- return arrayToSet(so.value(), false);
+ return (so == null) ? Collections.emptySet() : Set.of(so.value());
}
/**
@@ -198,15 +195,15 @@
private static Set<String> arrayToSet(String[] array,
boolean stripModulePrefixes) {
assert array != null;
- Set<String> set = new HashSet<>(array.length);
- for (String s : array) {
- if (stripModulePrefixes) {
+ if (stripModulePrefixes) {
+ array = array.clone();
+ for (int i = 0; i < array.length; i++) {
+ String s = array[i];
int index = s.indexOf('/');
if (index != -1)
- s = s.substring(index + 1);
+ array[i] = s.substring(index + 1);
}
- set.add(s);
}
- return Collections.unmodifiableSet(set);
+ return Set.of(array);
}
}
More information about the compiler-dev
mailing list