Unverified Commit a5025816 authored by Felix Bergmann's avatar Felix Bergmann Committed by GitHub

Making the Classloader threadsafe

parent 2433a7e8
...@@ -8,6 +8,8 @@ import java.io.IOException; ...@@ -8,6 +8,8 @@ import java.io.IOException;
import java.security.SecureClassLoader; import java.security.SecureClassLoader;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import static javax.tools.JavaFileObject.Kind; import static javax.tools.JavaFileObject.Kind;
...@@ -34,8 +36,8 @@ public class ClassFileManager extends ForwardingJavaFileManager<StandardJavaFile ...@@ -34,8 +36,8 @@ public class ClassFileManager extends ForwardingJavaFileManager<StandardJavaFile
} }
private class DynamicClassLoader extends SecureClassLoader { private class DynamicClassLoader extends SecureClassLoader {
private final Map<String, JavaClassObject> clsMap = new HashMap<>(); private final Map<String, JavaClassObject> clsMap = new ConcurrentHashMap<>();
private final Map<String, Class<?>> clsCache = new HashMap<>(); private final Map<String, Class<?>> clsCache = new ConcurrentHashMap<>();
@Override @Override
protected Class<?> findClass(String name) throws ClassNotFoundException { protected Class<?> findClass(String name) throws ClassNotFoundException {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment