|
44 | 44 | import java.util.HashMap;
|
45 | 45 | import java.util.HashSet;
|
46 | 46 | import java.util.List;
|
| 47 | +import java.util.Locale; |
47 | 48 | import java.util.Map;
|
48 | 49 | import java.util.Set;
|
49 | 50 | import java.util.Vector;
|
@@ -170,11 +171,18 @@ public static ClassLoader create(@CheckForNull ClassLoader parent, @NonNull ICla
|
170 | 171 | // actually our classloader that we exported to the other side.
|
171 | 172 | return ((ClassLoaderProxy) proxy).cl;
|
172 | 173 | }
|
173 |
| - return new RemoteClassLoader(parent, proxy); |
| 174 | + |
| 175 | + String name; |
| 176 | + try { |
| 177 | + name = proxy.getName(); |
| 178 | + } catch(IOException ignored) { |
| 179 | + name = String.format(Locale.ROOT, "unknown-due-to-io-error %1$#x", System.identityHashCode(proxy)); |
| 180 | + } |
| 181 | + return new RemoteClassLoader(name, parent, proxy); |
174 | 182 | }
|
175 | 183 |
|
176 |
| - private RemoteClassLoader(@CheckForNull ClassLoader parent, @NonNull IClassLoader proxy) { |
177 |
| - super(new URL[0], parent); |
| 184 | + private RemoteClassLoader(String name, @CheckForNull ClassLoader parent, @NonNull IClassLoader proxy) { |
| 185 | + super(name, new URL[0], parent); |
178 | 186 | final Channel channel = RemoteInvocationHandler.unwrap(proxy);
|
179 | 187 | this.channel = channel == null ? null : channel.ref();
|
180 | 188 | this.underlyingProxy = proxy;
|
@@ -887,6 +895,12 @@ public interface IClassLoader {
|
887 | 895 | */
|
888 | 896 | @NonNull
|
889 | 897 | ResourceFile[] getResources2(String name) throws IOException;
|
| 898 | + |
| 899 | + /** |
| 900 | + * Name of the classLoader |
| 901 | + * @since 3242 |
| 902 | + */ |
| 903 | + String getName() throws IOException; |
890 | 904 | }
|
891 | 905 |
|
892 | 906 | /**
|
@@ -1178,6 +1192,11 @@ public ResourceFile[] getResources2(String name) throws IOException {
|
1178 | 1192 | return r;
|
1179 | 1193 | }
|
1180 | 1194 |
|
| 1195 | + @Override |
| 1196 | + public String getName() throws IOException { |
| 1197 | + return cl.getName(); |
| 1198 | + } |
| 1199 | + |
1181 | 1200 | @Override
|
1182 | 1201 | public boolean equals(Object that) {
|
1183 | 1202 | if (this == that) {
|
@@ -1276,6 +1295,11 @@ public ResourceFile[] getResources2(String name) throws IOException {
|
1276 | 1295 | return proxy.getResources2(name);
|
1277 | 1296 | }
|
1278 | 1297 |
|
| 1298 | + @Override |
| 1299 | + public String getName() throws IOException { |
| 1300 | + return proxy.getName(); |
| 1301 | + } |
| 1302 | + |
1279 | 1303 | private Object readResolve() throws ObjectStreamException {
|
1280 | 1304 | try {
|
1281 | 1305 | return getChannelForSerialization().getExportedObject(oid);
|
@@ -1336,6 +1360,11 @@ public ResourceFile[] getResources2(String name) throws IOException {
|
1336 | 1360 | throw new IOException("Cannot get " + name, cause);
|
1337 | 1361 | }
|
1338 | 1362 |
|
| 1363 | + @Override |
| 1364 | + public String getName() throws IOException { |
| 1365 | + throw new IOException("Cannot getName", cause); |
| 1366 | + } |
| 1367 | + |
1339 | 1368 | }
|
1340 | 1369 |
|
1341 | 1370 | private static Iterable<String> analyze(InputStream bytecode) {
|
|
0 commit comments