Thread: Re: [CEDET-devel] semanticdb-javap not working (Page 2)
Brought to you by:
zappo
From: David E. <de...@ra...> - 2012-02-05 17:44:31
|
Eric M. Ludlam writes: > On 01/24/2012 02:11 AM, Joel Borggren-Franck wrote: >> But here is a list to get you started looking: >> - Oracle supplied bundle: JAVA_HOME/jre/lib/rt.jar >> - Mac OS X JDK 6: >> /Library/Java/JavaVirtualMachines/1.6.0_29-b11-402.jdk/Contents/Classes/classes.jar >> - Max OS X Oracle JDK 7 Preview: /Library/Java/JavaVirtualMachines/JDK >> 1.7.0 Developer Preview.jdk/Contents/Home/jre/lib/rt.jar >> - On Windows JAVA_HOME is usually a variation of C:\Program Files\Java ... > > Does anyone know if there is an existing Emacs tool/lib that knows this > stuff? I don't think so. But shouldn't it be enough to simply use JAVA_HOME/jre/lib? If JAVA_HOME isn't defined, you can check the location of the java binary as fallback and go one level up from there. But if that still doesn't work, just throw an error and ask the user to define JAVA_HOME properly. The fun is that there are different definitions out there of where JAVA_HOME should point to, but I think it has more or less settled to the top level of a JDK installation. -David |
From: Eric M. L. <eri...@gm...> - 2011-11-15 23:25:02
|
Hi, On 11/15/2011 02:47 PM, Joel Borggren-Franck wrote: > On Tue, Nov 15, 2011 at 6:49 PM, David Ventimiglia > <dve...@gu...> wrote: >> >> So this: >> >> ;; Get a list of paths together >> (dolist (P (append edepaths edeclasspath)) >> >> Becomes this: >> >> ;; Get a list of paths together >> (dolist (P (append edepaths edeclasspath semanticdb-javap-classpath)) >> > > This works. Thanks!! > >> Also, looking at the code it looks like semanticdb-javap.el doesn't actually use the javap executable, but rather just parses the contents of JAR files more or less "manually". >> > > You are right I can now complete Types, but not members of Types. > > Also the implicit java.lang.* import is missing. > > Eric how hard would it be to add completion on members of types if you > can get a list of members? I happen to have a half decent elisp > class-file parser lying around. Hand the parser a class-file and I can > make it output a list of members (complete with types and parameters). Hi, I wrote the semanticdb-javap code to work with the android project. I'm surprised that I left such a glaring error. Thanks for finding that! We should add that into the code. It is simple enough to not need papers. Any volunteers? The javap code works by calling cedet-javap-get-class against the jars in your library. That calls javap, and then parses the output. When I was using this on android code, if you had a variable of some class, it would complete the members of that class after the variable pretty reliably for me. I didn't try .class files or the like. Extending this to support .class files on your path seems like a pretty good idea. I'm not that familiar w/ javap, but if it can take a .class file, it should work fine to just add them to your class path. Use the debugger on semanticdb-javap-extract-tag-table to find out what is going on. If it doesn't handle the class file, then alternates to javap seem like as good an idea to me as any. An outstanding bug is that this library can't figure out how to resolve imports of *, and I seem to remember having trouble with stuff in the default jar files, as I couldn't reliably find them on the file system. Enjoy Eric |
From: David V. <dve...@gu...> - 2011-11-15 23:51:11
|
> I wrote the semanticdb-javap code to work with the android project. > I'm > surprised that I left such a glaring error. Thanks for finding that! > We > should add that into the code. It is simple enough to not need papers. > Any volunteers? You bet. I'll just submit a patch to this list. > > The javap code works by calling cedet-javap-get-class against the jars > in your library. That calls javap, and then parses the output. When I > was using this on android code, if you had a variable of some class, it > would complete the members of that class after the variable pretty > reliably for me. I didn't try .class files or the like. > > Extending this to support .class files on your path seems like a pretty > good idea. I'm not that familiar w/ javap, but if it can take a .class > file, it should work fine to just add them to your class path. Use the > debugger on semanticdb-javap-extract-tag-table to find out what is > going > on. If it doesn't handle the class file, then alternates to javap seem > like as good an idea to me as any. It looks like the Elisp code manually manages separate databases/tables for Jar files, figures out which Jar file a Type belongs to, then calls javap for the Type and just that one Jar file, in order eventually to get the Type's tags. Perhaps it could be simplified, since javap can be made to do more of the work. All of semanticdb-javap-classpath could be passed to javap, along with the Type we're looking for, and javap will do the rest. > ...I seem to remember having trouble with stuff in the > default jar files, as I couldn't reliably find them on the file system. Perhaps unqualified Types (such as String and Integer) could be assumed to be in java.lang, and again javap could be invoked to get at the Type members, since javap will know all about java.lang.* without CEDET having to know where the default Jar files are. Just a thought. Cheers, David |
From: <jo...@ve...> - 2012-01-21 17:28:19
|
"Eric M. Ludlam" <eri...@gm...> writes: > On 01/20/2012 06:49 PM, Philipp Haselwarter wrote: >> Oh and please please, write more documentation on how to properly set up >> cedet :) >> >>> (info "(cedet) JDEE Target") >>> @TODO - Add section on how to configure semanticdb-javap for >>> extracting symbols and header info from .jar files for semantic. > > Indeed, that would be good. I am dependent on others for development > environments I don't use myself. For javap, I did get it working > suitably for Android dev, but never figured out system jar files, and I > don't use JDEE either to know how to integrate the two. > > I think Joel may soon be in a position to add the right info here. ;) > >> just crossed my mind: maybe do a little screencast demo? that always >> gives me the best impression of how a complex piece of software can >> work... > > I looked into that a couple years back, but I couldn't get the tool I > found on Emacswiki to work after 1/2 an hour or so and eventually gave up. > > I would encourage anyone who wants to to give this a try. It can only help! > >> Making your IDE work by trial-and-error is a /very/ time consuming task. >> That said, I know that writing documentation is, too. btw, thanks for >> providing this wonderful library for Emacs! > > Since I don't write code for a living anymore, I usually just watch for > things going by on the Mailing list that would make good topics, and try > to get it added into the doc. > > I have found it difficult to remain motivated since I don't actually get > to use CEDET much anymore, so if you learn something, consider providing > a patch for the doc, and getting an FSF assignment! > >> Back at the topic: >> >> Would this make completion for java's standard library available? >> Actually, what is left in jdee that cedet can't do? > > As I understand it, JDEE uses beanshell, which introspects, and emits > handy Emacs Lisp code. As such, it does well with system libs. What > Joel has done, I think, is point semanticdb-javap-classpath at some > system jar files. I hadn't tried this (I used the android system Jar > file) but I don't know why it wouldn't work. The system jar, I'm sure, > will emit every possible javap output syntax, so if something wasn't > used with Android, I wouldn't have fixed the parser for it, and things > won't parse well. As a datapoint I toyed with using a Clojure REPL instead of Beanshell a while ago. Clojure is better maintained than Beanshell was my thought, also the impedance mismatch is less between Clojure and Elisp than Beanshell and Elisp. Ideally I wanted something that didn't require downloading dependencies, but I didn't find a solution, so went with Clojure. Another thing that might be interesting is tighter integration between CEDET and Maven. I think maybe Malabar Mode is in that direction but haven't looked closer. > > As far as features, JDEE has a lot of features related to build, debug, > projects, and some pretty nifty java specific code helpers and wizards. > Since CEDET is a utility, that really continues to belong in a tool > like JDEE, and CEDET will continue to try and support such tools. > >> jdee does not seem to be quite up to speed with cedet anymore, making >> 1.1beta work requires some fiddling (jde still uses >> `senator-minor-mode', calls `semantic-add-minor-mode' with three >> arguments…). So where's the compatibility going? >> > > Paul Landes has been recommending folks stick with an old CEDET Beta. > Getting a tool like JDEE to work using either trunk, or newtrunk or > Emacs integrated CEDET may be tricky since it uses a lot of features. > > I think JDEE just needs some TLC to bring it up to speed with newer > CEDET. Moving it to support CEDET trunk is probably not too bad. > > Eric > > ------------------------------------------------------------------------------ > Try before you buy = See our experts in action! > The most comprehensive online learning library for Microsoft developers > is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, > Metro Style Apps, more. Free future releases when you subscribe now! > http://p.sf.net/sfu/learndevnow-dev2_______________________________________________ > Cedet-devel mailing list > Ced...@li... > https://lists.sourceforge.net/lists/listinfo/cedet-devel -- Joakim Verona |
From: Philipp H. <phi...@gm...> - 2012-01-21 20:05:52
|
On Sat, Jan 21 2012 18:27 (@1327166872), jo...@ve... wrote: > "Eric M. Ludlam" <eri...@gm...> writes: > >> On 01/20/2012 06:49 PM, Philipp Haselwarter wrote: ---8<---[snipped 35 lines]---8<--- >>> Back at the topic: >>> >>> Would this make completion for java's standard library available? >>> Actually, what is left in jdee that cedet can't do? >> >> As I understand it, JDEE uses beanshell, which introspects, and emits >> handy Emacs Lisp code. As such, it does well with system libs. What >> Joel has done, I think, is point semanticdb-javap-classpath at some >> system jar files. I hadn't tried this (I used the android system Jar >> file) but I don't know why it wouldn't work. The system jar, I'm sure, >> will emit every possible javap output syntax, so if something wasn't >> used with Android, I wouldn't have fixed the parser for it, and things >> won't parse well. > > As a datapoint I toyed with using a Clojure REPL instead of Beanshell a > while ago. Clojure is better maintained than Beanshell was my thought, > also the impedance mismatch is less between Clojure and Elisp than > Beanshell and Elisp. > > Ideally I wanted something that didn't require downloading dependencies, > but I didn't find a solution, so went with Clojure. That sounds very interesting. The Clojure community seems to be quite active, while Beanshell.. well. How did your experiments go? Do you think using the Clojure REPL as backend is viable? ---8<---[snipped 35 lines]---8<--- -- Philipp Haselwarter |
From: <jo...@ve...> - 2012-01-23 15:32:54
|
Philipp Haselwarter <phi...@gm...> writes: > On Sat, Jan 21 2012 18:27 (@1327166872), jo...@ve... wrote: > >> "Eric M. Ludlam" <eri...@gm...> writes: >> >>> On 01/20/2012 06:49 PM, Philipp Haselwarter wrote: > ---8<---[snipped 35 lines]---8<--- >>>> Back at the topic: >>>> >>>> Would this make completion for java's standard library available? >>>> Actually, what is left in jdee that cedet can't do? >>> >>> As I understand it, JDEE uses beanshell, which introspects, and emits >>> handy Emacs Lisp code. As such, it does well with system libs. What >>> Joel has done, I think, is point semanticdb-javap-classpath at some >>> system jar files. I hadn't tried this (I used the android system Jar >>> file) but I don't know why it wouldn't work. The system jar, I'm sure, >>> will emit every possible javap output syntax, so if something wasn't >>> used with Android, I wouldn't have fixed the parser for it, and things >>> won't parse well. >> >> As a datapoint I toyed with using a Clojure REPL instead of Beanshell a >> while ago. Clojure is better maintained than Beanshell was my thought, >> also the impedance mismatch is less between Clojure and Elisp than >> Beanshell and Elisp. >> >> Ideally I wanted something that didn't require downloading dependencies, >> but I didn't find a solution, so went with Clojure. > > That sounds very interesting. The Clojure community seems to be quite > active, while Beanshell.. well. > How did your experiments go? Do you think using the Clojure REPL as > backend is viable? At the time it seemed entirely plausible. My recollection is a bit hazy though. If you are interested I can look through my notes and provide a better answer. I'm not really sure this is the correct path though. Maybe maven-shell or Clojure on top of a maven plugin would be easier to maintain. > > ---8<---[snipped 35 lines]---8<--- -- Joakim Verona |
From: Eric M. L. <eri...@gm...> - 2012-02-05 18:40:29
|
On 02/05/2012 12:44 PM, David Engster wrote: > Eric M. Ludlam writes: >> On 01/24/2012 02:11 AM, Joel Borggren-Franck wrote: >>> But here is a list to get you started looking: >>> - Oracle supplied bundle: JAVA_HOME/jre/lib/rt.jar >>> - Mac OS X JDK 6: >>> /Library/Java/JavaVirtualMachines/1.6.0_29-b11-402.jdk/Contents/Classes/classes.jar >>> - Max OS X Oracle JDK 7 Preview: /Library/Java/JavaVirtualMachines/JDK >>> 1.7.0 Developer Preview.jdk/Contents/Home/jre/lib/rt.jar >>> - On Windows JAVA_HOME is usually a variation of C:\Program Files\Java ... >> >> Does anyone know if there is an existing Emacs tool/lib that knows this >> stuff? > > I don't think so. But shouldn't it be enough to simply use > JAVA_HOME/jre/lib? If JAVA_HOME isn't defined, you can check the > location of the java binary as fallback and go one level up from > there. But if that still doesn't work, just throw an error and ask the > user to define JAVA_HOME properly. > > The fun is that there are different definitions out there of where > JAVA_HOME should point to, but I think it has more or less settled to > the top level of a JDK installation. Indeed, but I find JAVA_HOME rarely declared, even on systems where there is a good java. (At least on the two machines I tried.) As a followup here, I just checked in changes to cedet-java to try to derive where the JDK is, using the JAVA_HOME variable, and some of the other more standard locations from this msg. I didn't hook in the discovered JAR file anywhere though. That's a part 2. For example, there is more than just rt.jar, so how many jars should I be scanning through to build the semanticdb-javap symbol list? I think I've forgotten a bunch about how that worked to know what to ask next. Anyway, if folks could try out trunk, and use the new command "cedet-java-describe" and see if it can find your JDK, and let me know how it goes, that would be spiffy! Thanks Eric |
From: Joel Borggren-F. <jb...@kt...> - 2012-03-05 09:55:05
|
Hi, Sorry for not responding faster, my mail-reader fooled me into thinking that there was nothing new in this mail conversation :/ Anyhow, I've seen you checked stuff in, here is a late response to some of your questions: On Sun, Feb 5, 2012 at 7:40 PM, Eric M. Ludlam <eri...@gm...> wrote: > On 02/05/2012 12:44 PM, David Engster wrote: >> >> Eric M. Ludlam writes: >>> >>> On 01/24/2012 02:11 AM, Joel Borggren-Franck wrote: >>>> >>>> But here is a list to get you started looking: >>>> - Oracle supplied bundle: JAVA_HOME/jre/lib/rt.jar >>>> - Mac OS X JDK 6: >>>> >>>> /Library/Java/JavaVirtualMachines/1.6.0_29-b11-402.jdk/Contents/Classes/classes.jar >>>> - Max OS X Oracle JDK 7 Preview: /Library/Java/JavaVirtualMachines/JDK >>>> 1.7.0 Developer Preview.jdk/Contents/Home/jre/lib/rt.jar >>>> - On Windows JAVA_HOME is usually a variation of C:\Program Files\Java >>>> ... >>> >>> >>> Does anyone know if there is an existing Emacs tool/lib that knows this >>> stuff? >> >> >> I don't think so. But shouldn't it be enough to simply use >> JAVA_HOME/jre/lib? If JAVA_HOME isn't defined, you can check the >> location of the java binary as fallback and go one level up from >> there. But if that still doesn't work, just throw an error and ask the >> user to define JAVA_HOME properly. >> >> The fun is that there are different definitions out there of where >> JAVA_HOME should point to, but I think it has more or less settled to >> the top level of a JDK installation. > > > Indeed, but I find JAVA_HOME rarely declared, even on systems where there is > a good java. (At least on the two machines I tried.) > There are often multiple JDKs installed for a java developer. IMHO You can require from a developer to either set JAVA_HOME or in some other way configure the path to the JDK they want to use. > I didn't hook in the discovered JAR file anywhere though. That's a part 2. > For example, there is more than just rt.jar, so how many jars should I be > scanning through to build the semanticdb-javap symbol list? I think I've > forgotten a bunch about how that worked to know what to ask next. > There are some additional jars that might make sense, tools.jar for example. I'll think about this and send in a (trivial) patch. > Anyway, if folks could try out trunk, and use the new command > "cedet-java-describe" and see if it can find your JDK, and let me know how > it goes, that would be spiffy! > This works. I foresee some changes for Mac in the near future, I'll send in a patch when that happens. cheers /Joel |
From: Eric M. L. <eri...@gm...> - 2012-02-11 15:17:00
|
Hi, I checked in the change I originally proposed below. Eric On 02/05/2012 12:23 PM, Eric M. Ludlam wrote: > On 01/24/2012 02:11 AM, Joel Borggren-Franck wrote: >> On Tue, Jan 24, 2012 at 2:10 AM, Eric M. Ludlam<eri...@gm...> wrote: [...] >> Btw, you could possibly refine the regexp in the patch to search for >> and replace either "class " or "interface " as a prefix, and only use >> one re-search-forwad, but I couldn't figure out how emacs want's its >> regexp. > > Regarding your patch, yes, below is a short form that I didn't test. > > > === modified file 'semantic/semanticdb-javap.el' > *** semantic/semanticdb-javap.el 2012-01-21 16:23:12 +0000 > --- semantic/semanticdb-javap.el 2012-02-05 17:17:41 +0000 > *************** > *** 891,896 **** > --- 891,904 ---- > (goto-char (point-min)) > ;; The first line says "Compiled from ..." or some-such. > (insert "// ") > + > + ;; strip out fully qualified part of class- and interface names > + (save-excursion > + (goto-char (point-min)) > + (while (re-search-forward "\\(class\\|interface\\) \\([^\\. > ]*\\.\\)+" nil t) > + (replace-match "\\1 ")) > + ) > + > ;; Enable java mode and semantic parsing. > (java-mode) > (semantic-new-buffer-fcn) > > > Should it really replace it with something more like: > > (replace-match "package \\2;\n\\1 ") > > where it adds in the package statement that is made up of the package of > the class in the file? |
From: Joel Borggren-F. <jb...@kt...> - 2012-03-05 09:56:20
|
Thanks, see end for comments, On Sat, Feb 11, 2012 at 4:16 PM, Eric M. Ludlam <eri...@gm...> wrote: > Hi, > > I checked in the change I originally proposed below. > > Eric > > > On 02/05/2012 12:23 PM, Eric M. Ludlam wrote: >> >> On 01/24/2012 02:11 AM, Joel Borggren-Franck wrote: >>> >>> On Tue, Jan 24, 2012 at 2:10 AM, Eric M. Ludlam<eri...@gm...> >>> wrote: > > [...] >>> >>> Btw, you could possibly refine the regexp in the patch to search for >>> >>> and replace either "class " or "interface " as a prefix, and only use >>> one re-search-forwad, but I couldn't figure out how emacs want's its >>> regexp. >> >> >> Regarding your patch, yes, below is a short form that I didn't test. >> >> >> === modified file 'semantic/semanticdb-javap.el' >> *** semantic/semanticdb-javap.el 2012-01-21 16:23:12 +0000 >> --- semantic/semanticdb-javap.el 2012-02-05 17:17:41 +0000 >> *************** >> *** 891,896 **** >> --- 891,904 ---- >> (goto-char (point-min)) >> ;; The first line says "Compiled from ..." or some-such. >> (insert "// ") >> + >> + ;; strip out fully qualified part of class- and interface names >> + (save-excursion >> + (goto-char (point-min)) >> + (while (re-search-forward "\\(class\\|interface\\) \\([^\\. >> ]*\\.\\)+" nil t) >> + (replace-match "\\1 ")) >> + ) >> + >> ;; Enable java mode and semantic parsing. >> (java-mode) >> (semantic-new-buffer-fcn) >> >> >> Should it really replace it with something more like: >> >> (replace-match "package \\2;\n\\1 ") >> >> where it adds in the package statement that is made up of the package of >> the class in the file? Possibly, but I don't think so, as you walk the directory structure to find the file. The Class with fully qualified name 'foo.bar.Baz' will be in the jar in a subdirectory "bar/baz/" with the class-file name "Baz.class". IIRC semantic picks up the "package" through the subdirectory structure, and you don't want to do that twice. cheers /Joel |