1
1
/* VMClassLoader.java -- Reference implementation of native interface
2
2
required by ClassLoader
3
Copyright (C) 1998, 2001, 2002, 2004, 2005 Free Software Foundation
3
Copyright (C) 1998, 2001, 2002, 2004, 2005, 2006 Free Software Foundation
5
5
This file is part of GNU Classpath.
42
import gnu.classpath.Configuration;
42
43
import gnu.classpath.SystemProperties;
43
import gnu.classpath.Configuration;
44
import gnu.java.lang.InstrumentationImpl;
46
import java.io.BufferedReader;
45
47
import java.io.File;
46
48
import java.io.IOException;
49
import java.io.InputStreamReader;
50
import java.lang.instrument.Instrumentation;
47
51
import java.net.MalformedURLException;
48
52
import java.net.URL;
49
53
import java.security.ProtectionDomain;
50
54
import java.util.Enumeration;
51
55
import java.util.HashMap;
56
import java.util.HashSet;
52
57
import java.util.Map;
53
59
import java.util.StringTokenizer;
54
60
import java.util.Vector;
55
61
import java.util.zip.ZipFile;
238
244
* Returns a String[] of native package names. The default
239
* implementation returns an empty array, or you may decide
240
* this needs native help.
245
* implementation tries to load a list of package from
246
* the META-INF/INDEX.LIST file in the boot jar file.
247
* If not found or if any exception is raised, it returns
248
* an empty array. You may decide this needs native help.
242
250
private static String[] getBootPackages()
244
return new String[0];
252
URL indexList = getResource("META-INF/INDEX.LIST");
253
if (indexList != null)
257
Set packageSet = new HashSet();
260
BufferedReader reader = new BufferedReader(
261
new InputStreamReader(
262
indexList.openStream()));
263
while ((line = reader.readLine()) != null)
267
if (line.length() == 0)
270
packageSet.add(line.replace('/', '.'));
276
return (String[]) packageSet.toArray(new String[packageSet.size()]);
278
catch (IOException e)
280
return new String[0];
284
return new String[0];
346
386
* for this class.
348
388
static native Class findLoadedClass(ClassLoader cl, String name);
391
* The Instrumentation object created by the vm when agents are defined.
393
static final Instrumentation instrumenter = null;
396
* Call the transformers of the possible Instrumentation object. This
397
* implementation assumes the instrumenter is a
398
* <code>InstrumentationImpl</code> object. VM implementors would
399
* have to redefine this method if they provide their own implementation
400
* of the <code>Instrumentation</code> interface.
402
* @param loader the initiating loader
403
* @param name the name of the class
404
* @param data the data representing the classfile, in classfile format
405
* @param offset the offset into the data where the classfile starts
406
* @param len the length of the classfile data in the array
407
* @param pd the protection domain
408
* @return the new data representing the classfile
410
static final Class defineClassWithTransformers(ClassLoader loader,
411
String name, byte[] data, int offset, int len, ProtectionDomain pd)
414
if (instrumenter != null)
416
byte[] modifiedData = new byte[len];
417
System.arraycopy(data, offset, modifiedData, 0, len);
419
((InstrumentationImpl)instrumenter).callTransformers(loader, name,
420
null, pd, modifiedData);
422
return defineClass(loader, name, modifiedData, 0, modifiedData.length,
427
return defineClass(loader, name, data, offset, len, pd);