/usr/share/doc/libjcifs-java/examples/ClassLoaderTest.java is in libjcifs-java-doc 1.3.19-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | import java.net.URL;
import java.net.URLClassLoader;
import java.lang.reflect.Method;
import java.io.PrintStream;
import java.io.InputStream;
import jcifs.Config;
/*
This test was used to provoke the following exception:
Exception in thread "main" .java.lang.ExceptionInInitializerError
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:592)
at ClassLoaderTest.main(ClassLoaderTest.java:46)
Caused by: java.util.ConcurrentModificationException
at java.util.Hashtable$Enumerator.next(Hashtable.java:1020)
at java.util.Hashtable.putAll(Hashtable.java:469)
at jcifs.Config.load(Config.java:164)
at jcifs.Config.<clinit>(Config.java:70)
caused by this line of code in the jcifs.Config static initializer:
prp.putAll( System.getProperties() );
The fix is to simply clone() the system properties like:
prp.putAll( (java.util.Map)System.getProperties().clone() );
At least this removes the error.
*/
public class ClassLoaderTest implements Runnable {
static final int MULT = 1;
public void run()
{
for (int i = 0; i < (ClassLoaderTest.MULT * 700); i++) {
System.setProperty("i" + i, "x");
System.err.print('.');
}
}
public static void main(String[] argv) throws Exception
{
if (argv.length < 1) {
System.err.println("usage: ClassLoaderTest <jcifsjarpath>");
System.exit(1);
}
ClassLoaderTest clt = new ClassLoaderTest();
(new Thread(clt)).start();
for (int j = 0; j < (ClassLoaderTest.MULT * 100); j++) {
URL url = new URL(argv[0]);
URLClassLoader ucl = URLClassLoader.newInstance(new URL[] {url});
Class c = ucl.loadClass("jcifs.Config");
/*
Method m = c.getMethod("list", PrintStream.class);
m.invoke(null, new Object[] { System.err });
*/
Method m = c.getMethod("load", InputStream.class);
m.invoke(null, new Object[] { null });
ucl = null;
System.err.print('+');
}
}
}
|