jdk/src/java.instrument/share/classes/java/lang/instrument/Instrumentation.java
changeset 42338 a60f280f803c
parent 39739 5d058d6bd245
child 43712 5dfd0950317c
equal deleted inserted replaced
42148:7a4a59859ac0 42338:a60f280f803c
    25 
    25 
    26 package java.lang.instrument;
    26 package java.lang.instrument;
    27 
    27 
    28 import java.lang.reflect.Module;
    28 import java.lang.reflect.Module;
    29 import java.security.ProtectionDomain;
    29 import java.security.ProtectionDomain;
       
    30 import java.util.List;
       
    31 import java.util.Map;
       
    32 import java.util.Set;
    30 import java.util.jar.JarFile;
    33 import java.util.jar.JarFile;
    31 
    34 
    32 /*
    35 /*
    33  * Copyright 2003 Wily Technology, Inc.
    36  * Copyright 2003 Wily Technology, Inc.
    34  */
    37  */
   658      */
   661      */
   659     void
   662     void
   660     setNativeMethodPrefix(ClassFileTransformer transformer, String prefix);
   663     setNativeMethodPrefix(ClassFileTransformer transformer, String prefix);
   661 
   664 
   662     /**
   665     /**
   663      * Updates a module to read another module.
   666      * Redefine a module to expand the set of modules that it reads, the set of
   664      *
   667      * packages that it exports or opens, or the services that it uses or
   665      * Agents that instrument code in named modules may need to arrange for the
   668      * provides. This method facilitates the instrumentation of code in named
   666      * modules to read other modules. This method is equivalent to code in {@code
   669      * modules where that instrumentation requires changes to the set of modules
   667      * module} calling {@link Module#addReads(Module) addReads} to read {@code
   670      * that are read, the packages that are exported or open, or the services
   668      * other}.
   671      * that are used or provided.
   669      *
   672      *
   670      * @param module the module to update
   673      * <p> This method cannot reduce the set of modules that a module reads, nor
   671      * @param other the module to read
   674      * reduce the set of packages that it exports or opens, nor reduce the set
   672      * @throws NullPointerException if either module is {@code null}
   675      * of services that it uses or provides. This method is a no-op when invoked
   673      *
   676      * to redefine an unnamed module. </p>
       
   677      *
       
   678      * <p> When expanding the services that a module uses or provides then the
       
   679      * onus is on the agent to ensure that the service type will be accessible at
       
   680      * each instrumentation site where the service type is used. This method
       
   681      * does not check if the service type is a member of the module or in a
       
   682      * package exported to the module by another module that it reads. </p>
       
   683      *
       
   684      * <p> The {@code extraExports} parameter is the map of additional packages
       
   685      * to export. The {@code extraOpens} parameter is the map of additional
       
   686      * packages to open. In both cases, the map key is the fully-qualified name
       
   687      * of the package as defined in section 6.5.3 of
       
   688      * <cite>The Java&trade; Language Specification </cite>, for example, {@code
       
   689      * "java.lang"}. The map value is the non-empty set of modules that the
       
   690      * package should be exported or opened to. </p>
       
   691      *
       
   692      * <p> The {@code extraProvides} parameter is the additional service providers
       
   693      * for the module to provide. The map key is the service type. The map value
       
   694      * is the non-empty list of implementation types, each of which is a member
       
   695      * of the module and an implementation of the service. </p>
       
   696      *
       
   697      * <p> This method is safe for concurrent use and so allows multiple agents
       
   698      * to instrument and update the same module at around the same time. </p>
       
   699      *
       
   700      * @param module the module to redefine
       
   701      * @param extraReads the possibly-empty set of additional modules to read
       
   702      * @param extraExports the possibly-empty map of additional packages to export
       
   703      * @param extraOpens the possibly-empty map of additional packages to open
       
   704      * @param extraUses the possibly-empty set of additional services to use
       
   705      * @param extraProvides the possibly-empty map of additional services to provide
       
   706      *
       
   707      * @throws IllegalArgumentException
       
   708      *         If {@code extraExports} or {@code extraOpens} contains a key
       
   709      *         that is not a package in the module; if {@code extraExports} or
       
   710      *         {@code extraOpens} maps a key to an empty set; if a value in the
       
   711      *         {@code extraProvides} map contains a service provider type that
       
   712      *         is not a member of the module or an implementation of the service;
       
   713      *         or {@code extraProvides} maps a key to an empty list
       
   714      * @throws NullPointerException if any of the arguments are {@code null} or
       
   715      *         any of the Sets or Maps contains a {@code null} key or value
   674      * @since 9
   716      * @since 9
   675      * @see Module#canRead(Module)
   717      */
   676      */
   718     void redefineModule(Module module,
   677     void addModuleReads(Module module, Module other);
   719                         Set<Module> extraReads,
       
   720                         Map<String, Set<Module>> extraExports,
       
   721                         Map<String, Set<Module>> extraOpens,
       
   722                         Set<Class<?>> extraUses,
       
   723                         Map<Class<?>, List<Class<?>>> extraProvides);
   678 }
   724 }