|
From: Scott W. <arc...@db...> - 2000-01-06 14:41:17
|
This message was sent from Geocrawler.com by "Scott Wyatt" <sc...@fe...> Be sure to reply to that address. Hi, I have been using Jedit for a little while and have been very pleased with its functionality. I recently downloaded the new plugin JavaInsight and had some problems getting it to run correctly. After reviewing the source, I was able to fix the problems enough to be able to use the plugin. I thought you guys might like to know what I fixed in case you are having the same problems. If for some reason these issues have been fixed, please ignore this post. **I do not know if this will format correctly in the mailing list. BuildTools: Problem: 1. The class PackageBrowser was not correctly extracting the file paths out of various compressed files. It would probably work on a Unix system because the path separator is "/", however on Windows the path separator is "" and it would not create the file paths correctly. This prevented JavaInsight from populating its JTree correctly. It would simply be an empty tree. It seems that the entry name returned by the java zip package always uses "/". Changed Code: PackageBrowser.parseJar() private static void parseJAR(File jar) { try { ZipFile archive = new ZipFile (jar.getAbsolutePath()); for(Enumeration elements = archive.entries(); elements.hasMoreElements();) { ZipEntry entry = (ZipEntry) elements.nextElement(); **This was added to correct the Problem String entryName = entry.getName ().replace('/', (System.getProperty ("file.separator").toCharArray())[0]); ** String ext = FileUtils.getExtension(entryName); if(ext != null && ext.equals ("class") && entry.getName().indexOf("$") == -1) { String pkg = getPackage (entryName); if(pkg != null) { String className = getFullyQualifiedClassName(entryName); getJavaPackage (pkg).addClass(new JavaClass(className, jar.getAbsolutePath())); } } } } catch(IOException e) { e.printStackTrace(); return; } } 2. The class MiscUtilites was not performing it comparison of the OS path separator correctly. Consequently, the method getTempDir() was always returning /tmp on my Windows box even if c:Temp existed. Changed Code: MiscUtilities.getTempDir() public static String getTempDir() { String separator = System.getProperty ("file.separator"); ** Changed the conditions from == to equals(). if(separator.equals("/") && (new File ("/tmp")).exists()) return "/tmp"; if(separator.equals("\") && (new File ("c:\temp")).exists()) return "c:\temp"; else return "/tmp"; ** } JavaInsight: Problem: 1. The jode package which performs the decompilation was requiring the classpath to be set, however, the params that were sent did not include the classpath and I kept getting CNFE from the jode package. Added Code: JavaInsight.getJodeClassPath() I simply added a method that generates the classpath that jode requires. It needed its classpath to be delimited by commas instead of colons or semicolons. I then passed this to the jode package using the -c option. ** Added to JavaInsight Class public String getJodeClassPath() { String classArray[] = JavaUtils.getClasspath(); String classpath = ""; for(int i=0; i<classArray.length; ++i) classpath += classArray[i]+","; if(!classpath.equals("")) classpath = classpath.substring(0, classpath.length()-1); else classpath = "."; return classpath; } Changed Code: JavaInsight.decompileClass() Was: String param[] = {className}; Changed To: String[] params = { className, "--pretty", "-c", getJodeClassPath() }; These are the changes I made to correct most of the problems I had, however, there are some bugs in the jode package dealing with the order of the classpath it expects. I probably will save that for a rainy day. If this is an inappropriate place to put this post, I apologize. Hope this helps someone. Keep up the awesome work on Jedit. P.S. Keep the toolbar. Scott (Fedex Programmer/Analyst) Geocrawler.com - The Knowledge Archive |