Project

Profile

Help

Bug #2327 ยป InstantiationProblem.java

Reproduction of issue - Gunther Rademacher, 2015-03-12 16:56

 
import net.sf.saxon.Configuration;

import com.saxonica.config.EnterpriseConfiguration;

public class InstantiationProblem {
public static void main(String[] args) throws Exception {

Thread enterpriseConfigurationUser = new Thread() {
public void run() {
// the following would be a workaround:
//
// try {
// Class.forName("net.sf.saxon.Configuration");
// }
// catch (Exception e) {
// throw new RuntimeException(e);
// }
new EnterpriseConfiguration(); // <-- originally in ConfigurationFactory.getConfiguration()
}
};

Thread transformerUser = new Thread() {
public void run() {
new Configuration(); // <-- originally via TransformerFactory.newInstance()
}
};
enterpriseConfigurationUser.start();
transformerUser.start();
for (int i = 2; ; i += 2) {
Thread.sleep(2000);
if (! (enterpriseConfigurationUser.isAlive() && transformerUser.isAlive()))
break;
System.out.println("both threads alive after " + i + " sec");
if (i >= 10) {
for (Thread t : new Thread[]{enterpriseConfigurationUser, transformerUser}) {
System.out.println("stack trace:");
for (StackTraceElement s : t.getStackTrace())
System.out.println(" " + s);
}
System.exit(1);
}
}

transformerUser.join();
enterpriseConfigurationUser.join();
System.out.println("done");
}
}
    (1-1/1)