< prev index next >

src/java.base/share/classes/jdk/internal/access/JavaLangAccess.java

Print this page
rev 58565 : 8238358: Implementation of JEP 371: Hidden Classes
Reviewed-by: duke
Contributed-by: mandy.chung@oracle.com, lois.foltan@oracle.com, david.holmes@oracle.com, harold.seigel@oracle.com, serguei.spitsyn@oracle.com, alex.buckley@oracle.com, jamsheed.c.m@oracle.com


   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package jdk.internal.access;
  27 
  28 import java.lang.annotation.Annotation;



  29 import java.lang.module.ModuleDescriptor;
  30 import java.lang.reflect.Executable;
  31 import java.lang.reflect.Method;
  32 import java.net.URI;
  33 import java.nio.charset.CharacterCodingException;
  34 import java.nio.charset.Charset;
  35 import java.security.AccessControlContext;
  36 import java.security.ProtectionDomain;
  37 import java.util.List;
  38 import java.util.Map;
  39 import java.util.Set;
  40 import java.util.concurrent.ConcurrentHashMap;
  41 import java.util.stream.Stream;
  42 
  43 import jdk.internal.module.ServicesCatalog;
  44 import jdk.internal.reflect.ConstantPool;
  45 import sun.reflect.annotation.AnnotationType;
  46 import sun.nio.ch.Interruptible;
  47 
  48 public interface JavaLangAccess {


 131      */
 132     Thread newThreadWithAcc(Runnable target, AccessControlContext acc);
 133 
 134     /**
 135      * Invokes the finalize method of the given object.
 136      */
 137     void invokeFinalize(Object o) throws Throwable;
 138 
 139     /**
 140      * Returns the ConcurrentHashMap used as a storage for ClassLoaderValue(s)
 141      * associated with the given class loader, creating it if it doesn't already exist.
 142      */
 143     ConcurrentHashMap<?, ?> createOrGetClassLoaderValueMap(ClassLoader cl);
 144 
 145     /**
 146      * Defines a class with the given name to a class loader.
 147      */
 148     Class<?> defineClass(ClassLoader cl, String name, byte[] b, ProtectionDomain pd, String source);
 149 
 150     /**








 151      * Returns a class loaded by the bootstrap class loader.
 152      */
 153     Class<?> findBootstrapClassOrNull(ClassLoader cl, String name);
 154 
 155     /**
 156      * Define a Package of the given name and module by the given class loader.
 157      */
 158     Package definePackage(ClassLoader cl, String name, Module module);
 159 
 160     /**
 161      * Invokes Long.fastUUID
 162      */
 163     String fastUUID(long lsb, long msb);
 164 
 165     /**
 166      * Record the non-exported packages of the modules in the given layer
 167      */
 168     void addNonExportedPackages(ModuleLayer layer);
 169 
 170     /**


 294      * @param len the number of bytes to decode
 295      * @return the newly created string
 296      * @throws IllegalArgumentException for malformed or unmappable bytes.
 297      */
 298     String newStringUTF8NoRepl(byte[] bytes, int off, int len);
 299 
 300     /**
 301      * Encode the given string into a sequence of bytes using utf8.
 302      *
 303      * @param s the string to encode
 304      * @return the encoded bytes in utf8
 305      * @throws IllegalArgumentException for malformed surrogates
 306      */
 307     byte[] getBytesUTF8NoRepl(String s);
 308 
 309     /**
 310      * Set the cause of Throwable
 311      * @param cause set t's cause to new value
 312      */
 313     void setCause(Throwable t, Throwable cause);

















 314 }


   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package jdk.internal.access;
  27 
  28 import java.lang.annotation.Annotation;
  29 import java.lang.invoke.MethodHandle;
  30 import java.lang.invoke.MethodHandles;
  31 import java.lang.invoke.MethodType;
  32 import java.lang.module.ModuleDescriptor;
  33 import java.lang.reflect.Executable;
  34 import java.lang.reflect.Method;
  35 import java.net.URI;
  36 import java.nio.charset.CharacterCodingException;
  37 import java.nio.charset.Charset;
  38 import java.security.AccessControlContext;
  39 import java.security.ProtectionDomain;
  40 import java.util.List;
  41 import java.util.Map;
  42 import java.util.Set;
  43 import java.util.concurrent.ConcurrentHashMap;
  44 import java.util.stream.Stream;
  45 
  46 import jdk.internal.module.ServicesCatalog;
  47 import jdk.internal.reflect.ConstantPool;
  48 import sun.reflect.annotation.AnnotationType;
  49 import sun.nio.ch.Interruptible;
  50 
  51 public interface JavaLangAccess {


 134      */
 135     Thread newThreadWithAcc(Runnable target, AccessControlContext acc);
 136 
 137     /**
 138      * Invokes the finalize method of the given object.
 139      */
 140     void invokeFinalize(Object o) throws Throwable;
 141 
 142     /**
 143      * Returns the ConcurrentHashMap used as a storage for ClassLoaderValue(s)
 144      * associated with the given class loader, creating it if it doesn't already exist.
 145      */
 146     ConcurrentHashMap<?, ?> createOrGetClassLoaderValueMap(ClassLoader cl);
 147 
 148     /**
 149      * Defines a class with the given name to a class loader.
 150      */
 151     Class<?> defineClass(ClassLoader cl, String name, byte[] b, ProtectionDomain pd, String source);
 152 
 153     /**
 154      * Defines a class with the given name to a class loader with
 155      * the given flags and class data.
 156      *
 157      * @see java.lang.invoke.MethodHandles.Lookup#defineClass
 158      */
 159     Class<?> defineClass(ClassLoader cl, Class<?> lookup, String name, byte[] b, ProtectionDomain pd, boolean initialize, int flags, Object classData);
 160 
 161     /**
 162      * Returns a class loaded by the bootstrap class loader.
 163      */
 164     Class<?> findBootstrapClassOrNull(ClassLoader cl, String name);
 165 
 166     /**
 167      * Define a Package of the given name and module by the given class loader.
 168      */
 169     Package definePackage(ClassLoader cl, String name, Module module);
 170 
 171     /**
 172      * Invokes Long.fastUUID
 173      */
 174     String fastUUID(long lsb, long msb);
 175 
 176     /**
 177      * Record the non-exported packages of the modules in the given layer
 178      */
 179     void addNonExportedPackages(ModuleLayer layer);
 180 
 181     /**


 305      * @param len the number of bytes to decode
 306      * @return the newly created string
 307      * @throws IllegalArgumentException for malformed or unmappable bytes.
 308      */
 309     String newStringUTF8NoRepl(byte[] bytes, int off, int len);
 310 
 311     /**
 312      * Encode the given string into a sequence of bytes using utf8.
 313      *
 314      * @param s the string to encode
 315      * @return the encoded bytes in utf8
 316      * @throws IllegalArgumentException for malformed surrogates
 317      */
 318     byte[] getBytesUTF8NoRepl(String s);
 319 
 320     /**
 321      * Set the cause of Throwable
 322      * @param cause set t's cause to new value
 323      */
 324     void setCause(Throwable t, Throwable cause);
 325 
 326     /**
 327      * Get protection domain of the given Class
 328      */
 329     ProtectionDomain protectionDomain(Class<?> c);
 330 
 331     /**
 332      * Get a method handle of string concat helper method
 333      */
 334     MethodHandle stringConcatHelper(String name, MethodType methodType);
 335 
 336     /*
 337      * Get the class data associated with the given class.
 338      * @param c the class
 339      * @see java.lang.invoke.MethodHandles.Lookup#defineHiddenClass(byte[], boolean, MethodHandles.Lookup.ClassOption...)
 340      */
 341     Object classData(Class<?> c);
 342 }
< prev index next >