< prev index next >

src/java.base/share/classes/java/lang/reflect/Proxy.java

Print this page




 691             return DEBUG.equals(flag);
 692         }
 693     }
 694 
 695     /**
 696      * Builder for a proxy class.
 697      *
 698      * If the module is not specified in this ProxyBuilder constructor,
 699      * it will map from the given loader and interfaces to the module
 700      * in which the proxy class will be defined.
 701      */
 702     private static final class ProxyBuilder {
 703         final ClassLoader loader;
 704         final List<Class<?>> interfaces;
 705         final Module module;
 706         ProxyBuilder(ClassLoader loader, List<Class<?>> interfaces) {
 707             if (!VM.isModuleSystemInited()) {
 708                 throw new InternalError("Proxy is not supported until module system is fully initialzed");
 709             }
 710             if (interfaces.size() > 65535) {
 711                 throw new IllegalArgumentException("interface limit exceeded");
 712             }
 713 
 714             Set<Class<?>> refTypes = referencedTypes(loader, interfaces);
 715 
 716             // IAE if violates any restrictions specified in newProxyInstance
 717             validateProxyInterfaces(loader, interfaces, refTypes);
 718 
 719             this.loader = loader;
 720             this.interfaces = interfaces;
 721             this.module = mapToModule(loader, interfaces, refTypes);
 722             assert getLoader(module) == loader;
 723         }
 724 
 725         /**
 726          * Generate a proxy class.  If the target module does not have any
 727          * to any interface types, IllegalAccessError will be thrown by the VM
 728          * at defineClass time.
 729          *
 730          * Must call the checkProxyAccess method to perform permission checks
 731          * before calling this.




 691             return DEBUG.equals(flag);
 692         }
 693     }
 694 
 695     /**
 696      * Builder for a proxy class.
 697      *
 698      * If the module is not specified in this ProxyBuilder constructor,
 699      * it will map from the given loader and interfaces to the module
 700      * in which the proxy class will be defined.
 701      */
 702     private static final class ProxyBuilder {
 703         final ClassLoader loader;
 704         final List<Class<?>> interfaces;
 705         final Module module;
 706         ProxyBuilder(ClassLoader loader, List<Class<?>> interfaces) {
 707             if (!VM.isModuleSystemInited()) {
 708                 throw new InternalError("Proxy is not supported until module system is fully initialzed");
 709             }
 710             if (interfaces.size() > 65535) {
 711                 throw new IllegalArgumentException("interface limit exceeded: " + interfaces.size());
 712             }
 713 
 714             Set<Class<?>> refTypes = referencedTypes(loader, interfaces);
 715 
 716             // IAE if violates any restrictions specified in newProxyInstance
 717             validateProxyInterfaces(loader, interfaces, refTypes);
 718 
 719             this.loader = loader;
 720             this.interfaces = interfaces;
 721             this.module = mapToModule(loader, interfaces, refTypes);
 722             assert getLoader(module) == loader;
 723         }
 724 
 725         /**
 726          * Generate a proxy class.  If the target module does not have any
 727          * to any interface types, IllegalAccessError will be thrown by the VM
 728          * at defineClass time.
 729          *
 730          * Must call the checkProxyAccess method to perform permission checks
 731          * before calling this.


< prev index next >