35 import java.lang.reflect.Constructor; |
35 import java.lang.reflect.Constructor; |
36 import java.lang.reflect.Field; |
36 import java.lang.reflect.Field; |
37 import java.lang.reflect.Modifier; |
37 import java.lang.reflect.Modifier; |
38 import java.security.AccessController; |
38 import java.security.AccessController; |
39 import java.security.PrivilegedAction; |
39 import java.security.PrivilegedAction; |
40 import java.security.ProtectionDomain; |
|
41 import java.util.ArrayList; |
40 import java.util.ArrayList; |
42 import java.util.Collections; |
41 import java.util.Collections; |
43 import java.util.List; |
42 import java.util.List; |
44 import java.util.Objects; |
43 import java.util.Objects; |
45 import java.util.concurrent.ConcurrentHashMap; |
44 import java.util.concurrent.ConcurrentHashMap; |
576 |
575 |
577 // load class |
576 // load class |
578 InvokerBytecodeGenerator.maybeDump(classBCName(className), classFile); |
577 InvokerBytecodeGenerator.maybeDump(classBCName(className), classFile); |
579 Class<?> speciesCode; |
578 Class<?> speciesCode; |
580 |
579 |
581 ClassLoader cl = topClass().getClassLoader(); |
580 MethodHandles.Lookup lookup = IMPL_LOOKUP.in(topClass()); |
582 ProtectionDomain pd = null; |
581 speciesCode = AccessController.doPrivileged(new PrivilegedAction<>() { |
583 if (cl != null) { |
582 @Override |
584 pd = AccessController.doPrivileged( |
583 public Class<?> run() { |
585 new PrivilegedAction<>() { |
584 try { |
586 @Override |
585 return lookup.defineClass(classFile); |
587 public ProtectionDomain run() { |
586 } catch (Exception ex) { |
588 return topClass().getProtectionDomain(); |
587 throw newInternalError(ex); |
589 } |
588 } |
590 }); |
589 } |
591 } |
590 }); |
592 try { |
|
593 speciesCode = UNSAFE.defineClass(className, classFile, 0, classFile.length, cl, pd); |
|
594 } catch (Exception ex) { |
|
595 throw newInternalError(ex); |
|
596 } |
|
597 |
|
598 return speciesCode.asSubclass(topClass()); |
591 return speciesCode.asSubclass(topClass()); |
599 } |
592 } |
600 |
593 |
601 // These are named like constants because there is only one per specialization scheme: |
594 // These are named like constants because there is only one per specialization scheme: |
602 private final String SPECIES_DATA = classBCName(metaType); |
595 private final String SPECIES_DATA = classBCName(metaType); |