diff options
Diffstat (limited to 'src/utils/lombok')
-rw-r--r-- | src/utils/lombok/eclipse/Eclipse.java | 7 | ||||
-rw-r--r-- | src/utils/lombok/javac/TreeMirrorMaker.java | 18 | ||||
-rw-r--r-- | src/utils/lombok/javac/java8/CommentCollectingScannerFactory.java | 3 |
3 files changed, 19 insertions, 9 deletions
diff --git a/src/utils/lombok/eclipse/Eclipse.java b/src/utils/lombok/eclipse/Eclipse.java index 8af481b9..0f42ddc6 100644 --- a/src/utils/lombok/eclipse/Eclipse.java +++ b/src/utils/lombok/eclipse/Eclipse.java @@ -224,8 +224,11 @@ public class Eclipse { int highestVersionSoFar = 0; for (Field f : ClassFileConstants.class.getDeclaredFields()) { try { - if (f.getName().startsWith("JDK1_")) { - int thisVersion = Integer.parseInt(f.getName().substring("JDK1_".length())); + if (f.getName().startsWith("JDK")) { + String versionString = f.getName().substring("JDK".length()); + if (versionString.startsWith("1_")) versionString = versionString.substring("1_".length()); + + int thisVersion = Integer.parseInt(versionString); if (thisVersion > highestVersionSoFar) { highestVersionSoFar = thisVersion; latestEcjCompilerVersionConstantCached = (Long) f.get(null); diff --git a/src/utils/lombok/javac/TreeMirrorMaker.java b/src/utils/lombok/javac/TreeMirrorMaker.java index 778e670d..44e26ab6 100644 --- a/src/utils/lombok/javac/TreeMirrorMaker.java +++ b/src/utils/lombok/javac/TreeMirrorMaker.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2015 The Project Lombok Authors. + * Copyright (C) 2010-2021 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -58,14 +58,14 @@ public class TreeMirrorMaker extends TreeCopier<Void> { @Override public <T extends JCTree> T copy(T original) { T copy = super.copy(original); - originalToCopy.put(original, copy); + putIfAbsent(originalToCopy, original, copy); return copy; } @Override public <T extends JCTree> T copy(T original, Void p) { T copy = super.copy(original, p); - originalToCopy.put(original, copy); - return copy; + putIfAbsent(originalToCopy, original, copy); + return copy; } @Override public <T extends JCTree> List<T> copy(List<T> originals) { @@ -73,7 +73,7 @@ public class TreeMirrorMaker extends TreeCopier<Void> { if (originals != null) { Iterator<T> it1 = originals.iterator(); Iterator<T> it2 = copies.iterator(); - while (it1.hasNext()) originalToCopy.put(it1.next(), it2.next()); + while (it1.hasNext()) putIfAbsent(originalToCopy, it1.next(), it2.next()); } return copies; } @@ -83,7 +83,7 @@ public class TreeMirrorMaker extends TreeCopier<Void> { if (originals != null) { Iterator<T> it1 = originals.iterator(); Iterator<T> it2 = copies.iterator(); - while (it1.hasNext()) originalToCopy.put(it1.next(), it2.next()); + while (it1.hasNext()) putIfAbsent(originalToCopy, it1.next(), it2.next()); } return copies; } @@ -137,4 +137,10 @@ public class TreeMirrorMaker extends TreeCopier<Void> { @Override public JCTree visitLabeledStatement(LabeledStatementTree node, Void p) { return node.getStatement().accept(this, p); } + + private <K, V> void putIfAbsent(Map<K, V> map, K key, V value) { + if (!map.containsKey(key)) { + map.put(key, value); + } + } } diff --git a/src/utils/lombok/javac/java8/CommentCollectingScannerFactory.java b/src/utils/lombok/javac/java8/CommentCollectingScannerFactory.java index f29f501b..e625cd8d 100644 --- a/src/utils/lombok/javac/java8/CommentCollectingScannerFactory.java +++ b/src/utils/lombok/javac/java8/CommentCollectingScannerFactory.java @@ -21,6 +21,7 @@ */ package lombok.javac.java8; +import java.nio.Buffer; import java.nio.CharBuffer; import com.sun.tools.javac.parser.Scanner; @@ -79,7 +80,7 @@ public class CommentCollectingScannerFactory extends ScannerFactory { int limit; if (input instanceof CharBuffer && ((CharBuffer) input).hasArray()) { CharBuffer cb = (CharBuffer) input; - cb.compact().flip(); + ((Buffer)cb.compact()).flip(); array = cb.array(); limit = cb.limit(); } else { |