1 /*
2 * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
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
25
26 package com.sun.jdi;
27
28 import java.util.List;
29
30 /**
31 * A class loader object from the target VM.
32 * A ClassLoaderReference is an {@link ObjectReference} with additional
33 * access to classloader-specific information from the target VM. Instances
34 * ClassLoaderReference are obtained through calls to
35 * {@link ReferenceType#classLoader}
36 *
37 * @see ObjectReference
38 *
39 * @author Gordon Hirsch
40 * @since 1.3
41 */
42 public interface ClassLoaderReference extends ObjectReference {
43
44 /**
45 * Returns a list of all loaded classes that were defined by this
46 * class loader. No ordering of this list guaranteed.
47 * <P>
48 * The returned list will include reference types
49 * loaded at least to the point of preparation and
50 * types (like array) for which preparation is
51 * not defined.
52 *
53 * @return a List of {@link ReferenceType} objects mirroring types
54 * loaded by this class loader. The list has length 0 if no types
55 * have been defined by this classloader.
56 */
57 List<ReferenceType> definedClasses();
58
59 /**
60 * Returns a list of all classes for which this class loader has
61 * been recorded as the initiating loader in the target VM.
62 * The list contains ReferenceTypes defined directly by this loader
63 * (as returned by {@link #definedClasses}) and any types for which
64 * loading was delegated by this class loader to another class loader.
65 * <p>
66 * The visible class list has useful properties with respect to
67 * the type namespace. A particular type name will occur at most
68 * once in the list. Each field or variable declared with that
69 * type name in a class defined by
70 * this class loader must be resolved to that single type.
71 * <p>
72 * No ordering of the returned list is guaranteed.
73 * <p>
74 * See
75 * <cite>The Java™ Virtual Machine Specification</cite>,
76 * section 5.3 - Creation and Loading
77 * for more information on the initiating classloader.
78 * <p>
79 * Note that unlike {@link #definedClasses()}
80 * and {@link VirtualMachine#allClasses()},
81 * some of the returned reference types may not be prepared.
82 * Attempts to perform some operations on unprepared reference types
83 * (e.g. {@link ReferenceType#fields() fields()}) will throw
84 * a {@link ClassNotPreparedException}.
85 * Use {@link ReferenceType#isPrepared()} to determine if
86 * a reference type is prepared.
87 *
88 * @return a List of {@link ReferenceType} objects mirroring classes
89 * initiated by this class loader. The list has length 0 if no classes
90 * are visible to this classloader.
91 */
92 List<ReferenceType> visibleClasses();
93 }
|
1 /*
2 * Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
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
25
26 package com.sun.jdi;
27
28 import java.util.List;
29
30 /**
31 * A class loader object from the target VM.
32 * A ClassLoaderReference is an {@link ObjectReference} with additional
33 * access to classloader-specific information from the target VM. Instances
34 * ClassLoaderReference are obtained through calls to
35 * {@link ReferenceType#classLoader}
36 *
37 * @see ObjectReference
38 *
39 * @author Gordon Hirsch
40 * @since 1.3
41 */
42 public interface ClassLoaderReference extends ObjectReference {
43
44 /**
45 * Returns a list of all classes defined by this class loader.
46 * No ordering of this list guaranteed.
47 * The returned list will include all reference types, including
48 * {@link Class#isHidden hidden classes or interfaces}, loaded
49 * at least to the point of preparation and types (like array)
50 * for which preparation is not defined.
51 *
52 * @return a {@code List} of {@link ReferenceType} objects mirroring types
53 * defined by this class loader. The list has length 0 if no types
54 * have been defined by this classloader.
55 */
56 List<ReferenceType> definedClasses();
57
58 /**
59 * Returns a list of all classes which this class loader
60 * can find by name via {@link ClassLoader#loadClass(String, boolean)
61 * ClassLoader::loadClass}, {@link Class#forName(String) Class::forName}
62 * and bytecode linkage in the target VM. That is, this class loader
63 * has been recorded as an initiating loader of these classes.
64 * <p>
65 * Each class in the returned list was created by this class loader
66 * either by defining it directly or by delegation to another class loader
67 * (see JVMS {@jvms 5.3}).
68 *
69 * The returned list does not include {@link Class#isHidden() <em>hidden</em>}
70 * classes or interfaces that are created by the invocation of
71 * {@link java.lang.invoke.MethodHandles.Lookup#defineHiddenClass(byte[], boolean, java.lang.invoke.MethodHandles.Lookup.ClassOption...)
72 * Lookup::defineHiddenClass} because:
73 * <ul>
74 * <li>A hidden class or interface cannot be referenced by the constant pools
75 * of other classes and interfaces.
76 * <li>A hidden class or interface cannot be discovered by any class loader.
77 * </ul>
78 * <p>
79 * In addition, the returned list does not include array classes whose
80 * {@linkplain ArrayType#componentType() element type} is a
81 * {@link Class#isHidden() hidden class or interface} as they cannot
82 * be discovered by this class loader.
83 * <p>
84 * The visible class list has useful properties with respect to
85 * the type namespace. A particular type name will occur at most
86 * once in the list. Each field or variable declared with that
87 * type name in a class defined by
88 * this class loader must be resolved to that single type.
89 * <p>
90 * No ordering of the returned list is guaranteed.
91 * <p>
92 * Note that unlike {@link #definedClasses()}
93 * and {@link VirtualMachine#allClasses()},
94 * some of the returned reference types may not be prepared.
95 * Attempts to perform some operations on unprepared reference types
96 * (e.g. {@link ReferenceType#fields() fields()}) will throw
97 * a {@link ClassNotPreparedException}.
98 * Use {@link ReferenceType#isPrepared()} to determine if
99 * a reference type is prepared.
100 *
101 * @return a {@code List} of {@link ReferenceType} objects mirroring
102 * classes which this class loader can find by name. The list
103 * has length 0 if no classes are visible to this classloader.
104 *
105 * @jvms 5.3 Creation and Loading
106 */
107 List<ReferenceType> visibleClasses();
108 }
|