Degenerator
Hi All,
starting with build 2144, your IDEA installation sports Degenerator -
a source-to-source convertor that replaces generics in your code with
enourmous number of type casts in order to compile it with JDK 1.4.
Disclaimer and status: primary target audience for degenerator is plugin
developers. If you want to use generics in other projects, we suggest that
you take a look at Retroweaver or similiar tools, or wait for JDK 1.5
altogether. Although we use Degenerator to build IDEA, it may well not be
suitable for your projects. We are not likely to fix any bugs/feature
requests in degenerator unless they hinder our own development process.
Degenerator only supports Generics (JSR-014). It does not support
autoboxing, static imports or other JDK 1.5 bells'n'whistles.
To start degenerator, run {IDEA Installation}/bin/degenerator.{sh,bat}.
Command line arguments are an .ipr or .iml file and output directory.
Probably inconvenient restriction is that all source files should be under
the directory the project file is in.
Degenerator should be run against JDK 1.5-compilable sources - otherwise
unexplainable exceptions may occur.
If you want to enjoy OpenAPI with generics in your plugins, compile OpenAPI
sources (downloadable from http://www.intellij.net/eap) with JSR-014
implementation compiler or with JDK 1.5.
Enjoy,
Cheers,
Dmitry
--
Dmitry Lomov
Software Developer
JetBrains Inc.
http://www.jetbrains.com
"Develop with pleasure!"
Please sign in to leave a comment.
Hi Dmitry,
Thank you for this tool, we definitely will take a look at it.
Just curious, do you have experience with Retroweaver?
Tom
Thomas Singer (MoTJ) wrote:
No, we never tried it. Rejected it moerless flat out, because it requires
its own jar to be shipped with the product.
Freindly,
Dmitry
--
Dmitry Lomov
Software Developer
JetBrains Inc.
http://www.jetbrains.com
"Develop with pleasure!"
IIRC, the jar is not necessary for plain generics->type cast conversion.
Tom
Thomas Singer (MoTJ) wrote:
>> No, we never tried it. Rejected it moerless flat out, because it requires
>> its own jar to be shipped with the product.
IIRC the full story was that we did not learn about retroweaver until after
4.0 release, and afterwards we were considering it inly for other JDK 1.5
features.
Anyway, if additional jar is not needed, Retroweaver is another option for
plugin developers.
Cheers,
Dmitry
--
Dmitry Lomov
Software Developer
JetBrains Inc.
http://www.jetbrains.com
"Develop with pleasure!"
If you run the generics compiler with the '-s' flag, it will translate generics, autoboxing, enums, new for loops, asserts, etc into 1.3 compatible code.
It preserves doc comments, but I think other comments get trashed.
I'd love to try this, but can't use it on IPP or IG until you guys have degenerator in your build scripts for those plugins. Give me a shout when that occurs. Until then, I'll just play with it on MetricsReloaded.
--Dave Griffith
Doesn't work for MetricsReloaded, I'm afraid. In hacking around with JFreeChart, I had to subclass a class which had public members of a private static inner class. In figuring that out, degenerator inserts a cast to the private class, which naturally doesn't compile. I'm rolling back.
--Dave Griffith
Dave Griffith wrote:
Yup, this is a known problem, not likely to be fixed. Degenerator is dumb as
hell indeed.
The problem occurs when you have a public method that returns private
classes. This is definitely bad design (probably excusable in your case,
since you are hacking stuff out of Swing), but in all such cases that we
have ever had, we were able to get rid of that, sometimes with the help of
covariant return type. Probably you can try to make your public method
return public subclasses of private classes the base method should return.
Friendly,
Dmitry
--
Dmitry Lomov
Software Developer
JetBrains Inc.
http://www.jetbrains.com
"Develop with pleasure!"
Simon,
how did you learn that?! I have never seen any mention of that compiler flag
anywhere!
Anyway, due to JSR-014 license you actually cannot use the compiler for
production.
Friendly,
Dmitry
simon SPERO wrote:
--
Dmitry Lomov
Software Developer
JetBrains Inc.
http://www.jetbrains.com
"Develop with pleasure!"
Dave Griffith wrote:
We actually do from the very beginning
--
Maxim Shafirov
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"
That's what I thought. I can't imagine it being a problem unless you were trying to extend a badly designed library, but that's exactly what I had to do to get decent integer histogram graphs out of JFreeChart. There will be an inspection for this sort of thing ("Class escapes it's scope") checked in later today.
--Dave Griffith
You are just amazing!
Just one question though: do you sleep at all?
That would help boost my battered ego knowing it is mostly due to your incredible stamina that you are so productive ;)
Jacques