Skip to content

Commit 2bbfd6d

Browse files
committed
ConcurrentModificationException when running with Java 17 #73
1 parent 969463c commit 2bbfd6d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/main/java/net/openhft/compiler/MyJavaFileManager.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class MyJavaFileManager implements JavaFileManager {
4545
private static final long OVERRIDE_OFFSET;
4646

4747
static {
48-
long offset = 0;
48+
long offset;
4949
try {
5050
Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
5151
theUnsafe.setAccessible(true);
@@ -83,7 +83,7 @@ public ClassLoader getClassLoader(Location location) {
8383
return fileManager.getClassLoader(location);
8484
}
8585

86-
public Iterable<JavaFileObject> list(Location location, String packageName, Set<Kind> kinds, boolean recurse) throws IOException {
86+
public synchronized Iterable<JavaFileObject> list(Location location, String packageName, Set<Kind> kinds, boolean recurse) throws IOException {
8787
return fileManager.list(location, packageName, kinds, recurse);
8888
}
8989

@@ -106,7 +106,7 @@ public boolean hasLocation(Location location) {
106106
public JavaFileObject getJavaFileForInput(Location location, String className, Kind kind) throws IOException {
107107

108108
if (location == StandardLocation.CLASS_OUTPUT) {
109-
boolean success = false;
109+
boolean success;
110110
final byte[] bytes;
111111
synchronized (buffers) {
112112
success = buffers.containsKey(className) && kind == Kind.CLASS;
@@ -212,7 +212,7 @@ private <T> T invokeNamedMethodIfAvailable(final Location location, final String
212212
unsafe.putBoolean(method, OVERRIDE_OFFSET, true);
213213
return (T) method.invoke(fileManager, location);
214214
} catch (IllegalAccessException | InvocationTargetException e) {
215-
throw new UnsupportedOperationException("Unable to invoke method " + name);
215+
throw new UnsupportedOperationException("Unable to invoke method " + name, e);
216216
}
217217
}
218218
}

0 commit comments

Comments
 (0)