JAL-1807 Bob's JalviewJS prototype first commit
[jalviewjs.git] / site / j2s / org / xml / sax / helpers / NewInstance.js
1 Clazz.declarePackage ("org.xml.sax.helpers");\r
2 Clazz.load (null, "org.xml.sax.helpers.NewInstance", ["java.lang.Thread", "$.UnknownError"], function () {\r
3 c$ = Clazz.declareType (org.xml.sax.helpers, "NewInstance");\r
4 c$.newInstance = Clazz.defineMethod (c$, "newInstance", \r
5 function (classLoader, className) {\r
6 var driverClass;\r
7 if (classLoader == null) {\r
8 driverClass = Clazz._4Name (className);\r
9 } else {\r
10 driverClass = classLoader.loadClass (className);\r
11 }return driverClass.newInstance ();\r
12 }, "ClassLoader,~S");\r
13 c$.getClassLoader = Clazz.defineMethod (c$, "getClassLoader", \r
14 function () {\r
15 var m = null;\r
16 try {\r
17 m = Thread.getMethod ("getContextClassLoader", null);\r
18 } catch (e) {\r
19 if (Clazz.exceptionOf (e, NoSuchMethodException)) {\r
20 return org.xml.sax.helpers.NewInstance.getClassLoader ();\r
21 } else {\r
22 throw e;\r
23 }\r
24 }\r
25 try {\r
26 return m.invoke (Thread.currentThread (), null);\r
27 } catch (e$$) {\r
28 if (Clazz.exceptionOf (e$$, IllegalAccessException)) {\r
29 var e = e$$;\r
30 {\r
31 throw  new UnknownError (e.getMessage ());\r
32 }\r
33 } else if (Clazz.exceptionOf (e$$, java.lang.reflect.InvocationTargetException)) {\r
34 var e = e$$;\r
35 {\r
36 throw  new UnknownError (e.getMessage ());\r
37 }\r
38 } else {\r
39 throw e$$;\r
40 }\r
41 }\r
42 });\r
43 });\r