-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Package: antlr Version: 2.7.5-8 Severity: wishlist
The Hibernate project[0] ran into issues with ANTLR 2.7.5 which resulted in them submitting a patch to the ANTLR upstream project which is scheduled to be included in 2.7.6; however, 2.7.6 has not come yet. The patch can be found in the Hibernate JIRA system, issue #HHH-218[1]. This patch (or 2.7.6) is a dependency for Hibernate. I would like to see this patch applied for 2.7.5, as it is something that is supposed to be included in 2.7.6. I am also willing to do the work to implement this. [0] - http://www.hibernate.org [1] - http://opensource2.atlassian.com/projects/hibernate/browse/HHH-218 Regards, - -- Barry Hawkins site: www.bytemason.org weblog: www.yepthatsme.com Registered Linux User #368650 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFDNcxjHuKcDICy0QoRAglEAJ9uc5FaK7tP5JvANydKDLqEI08L4QCg9edc EKa9aroa/t1zF6UMn7BfCXE= =i83z -----END PGP SIGNATURE-----
diff -ruN ./antlr/ASTFactory.java ../antlr-2.7.5-patched/antlr/ASTFactory.java --- ./antlr/ASTFactory.java Sat Mar 26 03:57:51 2005 +++ ../antlr-2.7.5-patched/antlr/ASTFactory.java Thu Sep 22 16:23:43 2005 @@ -89,7 +89,7 @@ } Class c = null; try { - c = Class.forName(className); + c = ReflectHelper.classForName(className); tokenTypeToASTClassMap.put(new Integer(tokenType), c); } catch (Exception e) { @@ -217,7 +217,7 @@ public AST create(String className) { Class c = null; try { - c = Class.forName(className); + c = ReflectHelper.classForName(className); } catch (Exception e) { throw new IllegalArgumentException("Invalid class, "+className); @@ -232,7 +232,7 @@ Class c = null; AST t = null; try { - c = Class.forName(className); + c = ReflectHelper.classForName(className); Class[] tokenArgType = new Class[] { antlr.Token.class }; try { Constructor ctor = c.getConstructor(tokenArgType); @@ -375,7 +375,7 @@ public void setASTNodeClass(String t) { theASTNodeType = t; try { - theASTNodeTypeClass = Class.forName(t); // get class def + theASTNodeTypeClass = ReflectHelper.classForName(t);; // get class def } catch (Exception e) { // either class not found, diff -ruN ./antlr/CharScanner.java ../antlr-2.7.5-patched/antlr/CharScanner.java --- ./antlr/CharScanner.java Sat Mar 26 03:57:51 2005 +++ ../antlr-2.7.5-patched/antlr/CharScanner.java Thu Sep 22 16:23:43 2005 @@ -334,7 +334,7 @@ public void setTokenObjectClass(String cl) { try { - tokenObjectClass = Class.forName(cl); + tokenObjectClass = ReflectHelper.classForName(cl); } catch (ClassNotFoundException ce) { panic("ClassNotFoundException: " + cl); diff -ruN ./antlr/ReflectHelper.java ../antlr-2.7.5-patched/antlr/ReflectHelper.java --- ./antlr/ReflectHelper.java Wed Dec 31 18:00:00 1969 +++ ../antlr-2.7.5-patched/antlr/ReflectHelper.java Thu Sep 22 16:07:30 2005 @@ -0,0 +1,45 @@ +// NOTE: During decompile, Jad displayed the following messages: +// Parsing ReflectHelper.class... Generating ReflectHelper.jad +// Couldn't fully decompile method classForName +// Couldn't resolve all exception handlers in method classForName + +// Decompiled by Jad v1.5.8f. Copyright 2001 Pavel Kouznetsov. +// Jad home page: http://www.kpdus.com/jad.html +// Decompiler options: packimports(3) +// Source File Name: ReflectHelper.java + +package antlr; + + +public final class ReflectHelper +{ + +// Due to decompile problems mentioned above, the original classForName +// method generated by Jad has been commented out here and replaced by +// code that makes a bit more sense (dead code removed). +// +// public static Class classForName(String s) +// throws ClassNotFoundException +// { +// ClassLoader classloader = Thread.currentThread().getContextClassLoader(); +// if(classloader != null) +// return classloader.loadClass(s); +// return Class.forName(s); +// Exception exception; +// exception; +// return Class.forName(s); +// } + + public static Class classForName(String s) + throws ClassNotFoundException + { + ClassLoader classloader = Thread.currentThread().getContextClassLoader(); + if(classloader != null) + return classloader.loadClass(s); + return Class.forName(s); + } + + private ReflectHelper() + { + } +} diff -ruN ./antlr/Tool.java ../antlr-2.7.5-patched/antlr/Tool.java --- ./antlr/Tool.java Sat Mar 26 03:57:51 2005 +++ ../antlr-2.7.5-patched/antlr/Tool.java Thu Sep 22 16:23:43 2005 @@ -246,7 +246,7 @@ // (necessary for VAJ interface) String codeGenClassName = "antlr." + getLanguage(behavior) + "CodeGenerator"; try { - Class codeGenClass = Class.forName(codeGenClassName); + Class codeGenClass = ReflectHelper.classForName(codeGenClassName); codeGen = (CodeGenerator)codeGenClass.newInstance(); codeGen.setBehavior(behavior); codeGen.setAnalyzer(analyzer); @@ -303,9 +303,9 @@ int argslen = initargs.length; Class cl[] = new Class[argslen]; for (int i=0;i<argslen;i++) { - cl[i] = Class.forName(initargs[i].getClass().getName()); + cl[i] = ReflectHelper.classForName(initargs[i].getClass().getName()); } - c = Class.forName (p); + c = ReflectHelper.classForName (p); Constructor con = c.getConstructor (cl); o = con.newInstance (initargs); } catch (Exception e) { @@ -318,7 +318,7 @@ Class c; Object o = null; try { - c = Class.forName(p);// get class def + c = ReflectHelper.classForName(p);// get class def o = c.newInstance(); // make a new one } catch (Exception e) { diff -ruN ./antlr/build/Tool.java ../antlr-2.7.5-patched/antlr/build/Tool.java --- ./antlr/build/Tool.java Sat Mar 26 03:57:51 2005 +++ ../antlr-2.7.5-patched/antlr/build/Tool.java Thu Sep 22 16:23:43 2005 @@ -3,6 +3,8 @@ import java.io.*; import java.lang.reflect.*; +import antlr.ReflectHelper; + /** An application-specific build tool for ANTLR. Old build * was a shell script that of course is not portable. All it * did though was to compile; this Java program is a portable @@ -74,14 +76,14 @@ Method m = null; Object appObj = null; try { - c = Class.forName(app); + c = ReflectHelper.classForName(app); appObj = c.newInstance(); } catch (Exception e) { // try again with antlr.build.app try { if ( !app.startsWith("antlr.build.") ) { - c = Class.forName("antlr.build."+app); + c = ReflectHelper.classForName("antlr.build."+app); } error("no such application "+app, e); } diff -ruN ./antlr/debug/LLkDebuggingParser.java ../antlr-2.7.5-patched/antlr/debug/LLkDebuggingParser.java --- ./antlr/debug/LLkDebuggingParser.java Sat Mar 26 03:57:51 2005 +++ ../antlr-2.7.5-patched/antlr/debug/LLkDebuggingParser.java Thu Sep 22 16:23:43 2005 @@ -1,6 +1,7 @@ package antlr.debug; import antlr.ParserSharedInputState; +import antlr.ReflectHelper; import antlr.TokenStreamException; import antlr.LLkParser; import antlr.TokenBuffer; @@ -212,13 +213,13 @@ // default parser debug setup is ParseView try { try { - Class.forName("javax.swing.JButton"); + ReflectHelper.classForName("javax.swing.JButton"); } catch (ClassNotFoundException e) { System.err.println("Swing is required to use ParseView, but is not present in your CLASSPATH"); System.exit(1); } - Class c = Class.forName("antlr.parseview.ParseView"); + Class c = ReflectHelper.classForName("antlr.parseview.ParseView"); Constructor constructor = c.getConstructor(new Class[] {LLkDebuggingParser.class, TokenStream.class, TokenBuffer.class}); constructor.newInstance(new Object[] {this, lexer, tokenBuf}); }