# HG changeset patch # User attila # Date 1409058260 -7200 # Node ID 2c3db3ce0b06804ea2ffef1272dae0d1c9b63127 # Parent 7cf80b2dc39b4a8399a3211bbf0d2449e08e51f7 8055954: Do not parallelize class installation Reviewed-by: jlaskey, sundar diff -r 7cf80b2dc39b -r 2c3db3ce0b06 src/jdk/nashorn/internal/runtime/Context.java --- a/src/jdk/nashorn/internal/runtime/Context.java Tue Aug 26 11:45:36 2014 +0200 +++ b/src/jdk/nashorn/internal/runtime/Context.java Tue Aug 26 15:04:20 2014 +0200 @@ -163,39 +163,26 @@ @Override public void initialize(final Collection> classes, final Source source, final Object[] constants) { - // do these in parallel, this significantly reduces class installation overhead - // however - it still means that every thread needs a separate doPrivileged - final Global global = currentGlobal.get(); - classes.parallelStream().forEach( - new Consumer>() { + try { + AccessController.doPrivileged(new PrivilegedExceptionAction() { @Override - public void accept(final Class clazz) { - // Global threadlocal may be needed by StructureLoader during in field lookup. - currentGlobal.set(global); - try { - AccessController.doPrivileged(new PrivilegedExceptionAction() { - @Override - public Void run() { - try { - //use reflection to write source and constants table to installed classes - final Field sourceField = clazz.getDeclaredField(SOURCE.symbolName()); - sourceField.setAccessible(true); - sourceField.set(null, source); + public Void run() throws Exception { + for (final Class clazz : classes) { + //use reflection to write source and constants table to installed classes + final Field sourceField = clazz.getDeclaredField(SOURCE.symbolName()); + sourceField.setAccessible(true); + sourceField.set(null, source); - final Field constantsField = clazz.getDeclaredField(CONSTANTS.symbolName()); - constantsField.setAccessible(true); - constantsField.set(null, constants); - } catch (final IllegalAccessException | NoSuchFieldException e) { - throw new RuntimeException(e); - } - return null; - } - }); - } catch (final PrivilegedActionException e) { - throw new RuntimeException(e); + final Field constantsField = clazz.getDeclaredField(CONSTANTS.symbolName()); + constantsField.setAccessible(true); + constantsField.set(null, constants); } + return null; } }); + } catch (final PrivilegedActionException e) { + throw new RuntimeException(e); + } } @Override