[Sablevm-developer] Found deadlock in Class.getConstructor(Class[]).newInstance(Objects[])
Brought to you by:
egagnon
From: Clemens E. <lin...@we...> - 2004-04-15 15:10:59
|
Hello again! After reinstalling my whole gtk/gdk/atk/pango rpms your build-system now even worked on my system. I'm trying to use a lightweight gui library called "lwvcl", which is based on a swingle awt.component. At initialisation it does load some classes via class.forName and does some other class-based stuff. I think I've found a deadlock in Class.getConstructor(Class[]).newInstance(Objects[]). As you can see with this piece if code several different classes where loaded (some of them many times), but suddenly the method hangs when Here's the classname and the argument-type's list: So geladen:java.lang.String java.lang.String So geladen:java.lang.String java.lang.String So geladen:java.lang.String java.lang.String So geladen:LwBorder int So geladen:LwBorder int So geladen:LwBorder int So geladen:LwBorder int So geladen:LwBorder int So geladen:LwBorder int So geladen:LwImgSetRender java.lang.String int int int int int So geladen:LwImgSetRender java.lang.String int int int int int So geladen:LwImgSetRender java.lang.String int int int int int So geladen:LwImgSetRender java.lang.String int int int int int So geladen:LwImgSetRender java.lang.String int int int int int So geladen:LwImgSetRender java.lang.String int int int int int So geladen:LwImgSetRender java.lang.String int int int int int So geladen:LwImgSetRender java.lang.String int int int int int So geladen:LwImgSetRender java.lang.String int int int int int <----- Deadlock here I tried to debug it using gdb, but unlike without gdb I get a segfault. Here's the stacktrace: Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 16384 (LWP 2897)] _svmf_interpreter (_env=0x0) at interpreter.c:266 266 _svmt_method_info *method = frame->method; (gdb) bt #0 _svmf_interpreter (_env=0x0) at interpreter.c:266 #1 0x40083491 in JNI_CreateJavaVM (pvm=0xbffff1e0, penv=0xbffff1e4, _vm_args=0xbffff1f0) at invoke_interface.c:293 #2 0x08049e68 in main (argc=0, argv=0x0) at sablevm.c:1351 And here's the method of the gui library that calls the deadlock-method: /** * Creates an instance of the specified class using appropriate constructor for the given input arguments list. * The list is set of arguments that are separated by the comma. The following arguments types can be * used: * <ul> * <li>Integer. If the argument does not equal "true" or "false" and is not bound by quotes.</li> * <li>Boolean. If the argument equals "true" or "false" and is not bound by quotes.</li> * <li>String. If the argument is not bound by quote.</li> * </ul> * @param <code>className</code> the specified class name. * @param <code>argsStr</code> the specified input arguments list. The argument can be <code>null</code>. * In this case the default constructor will be used to create the class instance. * @return an instance of the class. */ public static Object createObj(String className, String argsStr) throws Exception { if (className.indexOf ('@') == 0) return getStaticObj(className.substring(1)); else { Class classInstance = Class.forName(className.indexOf('.')>0?className:PACKAGE_NAME + className); Object objInstance = null; if (argsStr == null) { objInstance = classInstance.newInstance(); } else { StringTokenizer args = new StringTokenizer(argsStr, ","); Class[] argsTypes = new Class [args.countTokens()]; Object[] argsValues = new Object[argsTypes.length]; for (int j = 0; args.hasMoreTokens(); j++) { String arg = args.nextToken().trim(); if (arg.indexOf('\"')==0) { argsTypes [j] = String.class; argsValues[j] = arg.substring(1, arg.length() - 1); } else if (arg.equals("true") || arg.equals("false")) { argsTypes [j] = Boolean.TYPE; argsValues[j] = new Boolean(arg); } else if (arg.indexOf('@') == 0) { argsValues[j] = getStaticObj(arg.substring(1)); argsTypes [j] = argsValues[j].getClass(); } else { argsTypes [j] = Integer.TYPE; argsValues[j] = new Integer(arg); } } System.out.print("So geladen:"+className); for(int i=0; i < argsTypes.length; i++) { System.out.print(" "+argsTypes[i].getName()); } System.out.println(); objInstance = classInstance.getConstructor(argsTypes).newInstance(argsValues); } return objInstance; } } Maby this code isn't written well, however it works even with the Microsoft-JVM ;-) Hope this helped, lg Linuxhippy |