* Why GCJ won't load my plugin when compiling bytecode? @ 2011-09-09 20:57 Li junsong 2011-09-09 21:03 ` Andrew Pinski 0 siblings, 1 reply; 8+ messages in thread From: Li junsong @ 2011-09-09 20:57 UTC (permalink / raw) To: java Hi there, I have a java source code Welcome.java, and my plugin's name is findvar.so. To avoid things getting complex, I write a very simple plugin, printing out Hello when loaded(printing hello in initial function). My plugin can be loaded if GCJ compiles source code to native machine code, that is if I type: gcj-4.6 -fplugin=findvar.so Welcome.java --main=Welcome Hello is then output to screen, and a.out is produced. But it won't work if GCJ compiles source code to java bytecode gcj-4.6 -fplugin=findvar.so -C Welcome.java --main=Welcome Nothing is promoted, only Welcome.class is produced. Does that mean that GCJ doesn't support -C and -fplugin at the same time? I really appreciate your answer. J. Li ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Why GCJ won't load my plugin when compiling bytecode? 2011-09-09 20:57 Why GCJ won't load my plugin when compiling bytecode? Li junsong @ 2011-09-09 21:03 ` Andrew Pinski 2011-09-09 21:57 ` Li junsong 0 siblings, 1 reply; 8+ messages in thread From: Andrew Pinski @ 2011-09-09 21:03 UTC (permalink / raw) To: Li junsong; +Cc: java On Fri, Sep 9, 2011 at 1:56 PM, Li junsong <ljs.darkfish@gmail.com> wrote: > Does that mean that GCJ doesn't support -C and -fplugin at the same time? Because the source to byte-code conversion is done by ECJ (Eclipse's java compiler) and not really done by a GCC front-end. Thanks, Andrew Pinski ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Why GCJ won't load my plugin when compiling bytecode? 2011-09-09 21:03 ` Andrew Pinski @ 2011-09-09 21:57 ` Li junsong 2011-09-09 22:24 ` Bryce McKinlay 0 siblings, 1 reply; 8+ messages in thread From: Li junsong @ 2011-09-09 21:57 UTC (permalink / raw) To: Andrew Pinski; +Cc: java On Fri, Sep 9, 2011 at 11:03 PM, Andrew Pinski <pinskia@gmail.com> wrote: > On Fri, Sep 9, 2011 at 1:56 PM, Li junsong <ljs.darkfish@gmail.com> wrote: >> Does that mean that GCJ doesn't support -C and -fplugin at the same time? > > Because the source to byte-code conversion is done by ECJ (Eclipse's > java compiler) and not really done by a GCC front-end. > Thanks, > Andrew Pinski > Thanks, Andrew. I want to do some optimization to reduce the allocation of java objects. The reason why I need to compile java source code to .class file is that I need stack information to see the information about java objects allocation. The only way (I know) to measure results of the optimization is to use Sun Java VM, which can produce profiles at runtime. I chose gcj to write plugin to do optimization. So I need its .class files output, but not its binary code. If I do not get it wrong, it means that If I want to do such optimization and measure the outcome, I have to look for other compilers, ( since GCC plugins won't work ) right? Thanks, J. Li ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Why GCJ won't load my plugin when compiling bytecode? 2011-09-09 21:57 ` Li junsong @ 2011-09-09 22:24 ` Bryce McKinlay 2011-09-09 23:03 ` Li junsong 2011-09-12 0:49 ` Alan Eliasen 0 siblings, 2 replies; 8+ messages in thread From: Bryce McKinlay @ 2011-09-09 22:24 UTC (permalink / raw) To: Li junsong; +Cc: Andrew Pinski, java On Fri, Sep 9, 2011 at 10:57 PM, Li junsong <ljs.darkfish@gmail.com> wrote: > I chose gcj to write plugin to do optimization. So I need its .class > files output, but not its binary code. Modern versions of gcj only compile .class files to object code. gcj doesn't directly compile Java source code, nor generate bytecode. (early versions of gcj did do these things, but it was changed years ago) When you give it .java source files, gcj actually first calls out to regular java compiler, then compiles the resulting .class files. You can see the commands its running by adding -v to your command line. > If I do not get it wrong, it means that If I want to do such > optimization and measure > the outcome, I have to look for other compilers, ( since GCC plugins > won't work ) right? That's right. A gcc plugin will never have a chance to run when using "gcj -C" because the gcc compiler itself is not run. Bryce ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Why GCJ won't load my plugin when compiling bytecode? 2011-09-09 22:24 ` Bryce McKinlay @ 2011-09-09 23:03 ` Li junsong 2011-09-12 0:49 ` Alan Eliasen 1 sibling, 0 replies; 8+ messages in thread From: Li junsong @ 2011-09-09 23:03 UTC (permalink / raw) To: Bryce McKinlay; +Cc: java On Sat, Sep 10, 2011 at 12:24 AM, Bryce McKinlay <bmckinlay@gmail.com> wrote: > On Fri, Sep 9, 2011 at 10:57 PM, Li junsong <ljs.darkfish@gmail.com> wrote: > >> I chose gcj to write plugin to do optimization. So I need its .class >> files output, but not its binary code. > > Modern versions of gcj only compile .class files to object code. gcj > doesn't directly compile Java source code, nor generate bytecode. > (early versions of gcj did do these things, but it was changed years > ago) > > When you give it .java source files, gcj actually first calls out to > regular java compiler, then compiles the resulting .class files. You > can see the commands its running by adding -v to your command line. > >> If I do not get it wrong, it means that If I want to do such >> optimization and measure >> the outcome, I have to look for other compilers, ( since GCC plugins >> won't work ) right? > > That's right. A gcc plugin will never have a chance to run when using > "gcj -C" because the gcc compiler itself is not run. > > Bryce > Thank you so much! Now I know it. But I'm just wondering if others would make the same mistakes. Unless people put his questions in this mail list, he would get no chance to find out these informations. I mean, I have referred to the GNU java homepage ( which told me they had been merged with project GNU ClassPath), gcc internals(in which the chapter "Java Tree" is blank ! ), the "ecj stuff"( There're lots of error in gcj when the first time I compiled my new gcc 4.6), But I find few resources talking about gcj "internals". So, If there is any thing I can do, apart from putting the question I met on my blog to tell others "don't make the same mistake again", please just let me know. Thanks, J. Li ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Why GCJ won't load my plugin when compiling bytecode? 2011-09-09 22:24 ` Bryce McKinlay 2011-09-09 23:03 ` Li junsong @ 2011-09-12 0:49 ` Alan Eliasen 2011-09-12 0:54 ` Mark Mielke 2011-09-12 9:32 ` Bryce McKinlay 1 sibling, 2 replies; 8+ messages in thread From: Alan Eliasen @ 2011-09-12 0:49 UTC (permalink / raw) To: java On 09/09/2011 04:24 PM, Bryce McKinlay wrote: > Modern versions of gcj only compile .class files to object code. gcj > doesn't directly compile Java source code, nor generate bytecode. > (early versions of gcj did do these things, but it was changed years > ago) Is this a permanent decision? Is there any intention to make gcj compile from java source code again? Can anyone give me pointers to where this was decided upon and announced? I'm curious to see the discussion. -- Alan Eliasen eliasen@mindspring.com http://futureboy.us/ ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Why GCJ won't load my plugin when compiling bytecode? 2011-09-12 0:49 ` Alan Eliasen @ 2011-09-12 0:54 ` Mark Mielke 2011-09-12 9:32 ` Bryce McKinlay 1 sibling, 0 replies; 8+ messages in thread From: Mark Mielke @ 2011-09-12 0:54 UTC (permalink / raw) To: Alan Eliasen; +Cc: java On 09/11/2011 08:49 PM, Alan Eliasen wrote: > On 09/09/2011 04:24 PM, Bryce McKinlay wrote: >> Modern versions of gcj only compile .class files to object code. gcj >> doesn't directly compile Java source code, nor generate bytecode. >> (early versions of gcj did do these things, but it was changed years >> ago) > > Is this a permanent decision? Is there any intention to make > gcj compile from java source code again? > > Can anyone give me pointers to where this was decided upon and > announced? I'm curious to see the discussion. > Doesn't seem like years but maybe... Java 5. Support for generics and such. Continue enhancing an alternative compiler with limited contributors, or use of that is basically guaranteed to be supported (Eclipse's compiler). I wasn't part of the decision - only an observer - but it seemed like an excellent decision when it was made, and I don't see why it isn't an excellent decision still. Cheers, -- Mark Mielke<mark@mielke.cc> ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Why GCJ won't load my plugin when compiling bytecode? 2011-09-12 0:49 ` Alan Eliasen 2011-09-12 0:54 ` Mark Mielke @ 2011-09-12 9:32 ` Bryce McKinlay 1 sibling, 0 replies; 8+ messages in thread From: Bryce McKinlay @ 2011-09-12 9:32 UTC (permalink / raw) To: Alan Eliasen; +Cc: java On Mon, Sep 12, 2011 at 1:49 AM, Alan Eliasen <eliasen@mindspring.com> wrote: > On 09/09/2011 04:24 PM, Bryce McKinlay wrote: >> >> Modern versions of gcj only compile .class files to object code. gcj >> doesn't directly compile Java source code, nor generate bytecode. >> (early versions of gcj did do these things, but it was changed years >> ago) > > Is this a permanent decision? Is there any intention to make gcj > compile from java source code again? > > Can anyone give me pointers to where this was decided upon and announced? > I'm curious to see the discussion. http://gcc.gnu.org/ml/java/2007-01/msg00027.html http://gcc.gnu.org/java : January 8, 2007 We've merged the gcj-eclipse branch to svn trunk. The merge changes gcj to use the Eclipse compiler as a front end, enabling all 1.5 language features. This merge also brings in a new, generics-enabled version of Classpath, including some new tools. This new code will appear in GCC 4.3. June 6, 2006 RMS approved the plan to use the Eclipse compiler as the new gcj front end. Work is being done on the gcj-eclipse branch; it can already build libgcj. This project will allow us to ship a 1.5 compiler in the relatively near future. The old gcjx branch and project is now dead. ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2011-09-12 9:32 UTC | newest] Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2011-09-09 20:57 Why GCJ won't load my plugin when compiling bytecode? Li junsong 2011-09-09 21:03 ` Andrew Pinski 2011-09-09 21:57 ` Li junsong 2011-09-09 22:24 ` Bryce McKinlay 2011-09-09 23:03 ` Li junsong 2011-09-12 0:49 ` Alan Eliasen 2011-09-12 0:54 ` Mark Mielke 2011-09-12 9:32 ` Bryce McKinlay
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).