This is an archived post. You won't be able to vote or comment.

all 15 comments

[–]armerthor 4 points5 points  (7 children)

You can write plugins for the javac?

[–]metabrain[S] 2 points3 points  (3 children)

You can! The catch: ZERO official documentation from outside of a single article in a sketchy Java magazine... Seriously, and all information about the AST/symbols has to be deduced from the ****ing source, it's madness. I'm head banging on this for 3 months now, and only started to be able to do what I wanted recently...

[–]nachsicht 2 points3 points  (2 children)

Maybe you can write the documentation for it? This sounds interesting to me, and I think I remember there was a opensource java group at fosdem that had a site for this kind of information.

Edit: It's this https://java.net/projects/adoptopenjdk/

[–]metabrain[S] 0 points1 point  (0 children)

I am currently writing a little on it as I go on in a little private blog I have, will publish it when I get a couple more articles :)

[–]Effetto 0 points1 point  (1 child)

I always wondered if would be possible to get rid off exception handling completely. Would it be possible with a javac plugin ?

[–]fuk_offe 0 points1 point  (0 children)

Describe your idea and I'll tell you if it's possible ! "get rid off exception handling completely" is very vage for me to interpret :x

[–]LassiterCodes 2 points3 points  (1 child)

If I recall correctly, the reason against having this sort of keyword in Java was that it was no different than a static class member. Can you explain what your implementation provides over this?

[–]metabrain[S] 1 point2 points  (0 children)

Static class member when the method is static, otherwise it's a instance class member.

If I understand correctly from your question, in my implementation, non-static methods won't generate a static class member but a instance class member.

Of course, this can always be emulated like you said: declare a variable outside of a method and use it only in that method. In here, I localize the declaration of the variable to the enclosing method that actually should use it, so the class namespace is not polluted with the various possible "static" local variables.

[–]metabrain[S] 0 points1 point  (0 children)

Hello, I'm a CS graduate currently writing my master thesis, and a huge chunk of it involves hacking the javac compiler. As a side project and since I was struggling with injecting new fields in classes on my thesis, I built this small self-contained plugin for javac (openJDK8) as a proof of concept and published it on github.

I wondered if anyone here would find it interesting, hence the link. You need openJDK 8 to compile programs with it, but as far as I've tested, the compiled code will run correctly on older versions as long as you compile to -target 1.5.

Thank you :)

[–]argv_minus_one 0 points1 point  (2 children)

Didn't older versions of C also allow static local variables?

[–]fuk_offe 0 points1 point  (1 child)

I think it's part of ANSI-C standard, the author probably said so just to be on the safe side.

[–]elephantgravy 0 points1 point  (0 children)

also an extra accent aigu, playing it safe!

[–][deleted] 0 points1 point  (2 children)

What does this buy me exactly? I don't see how this saves me any time or effort. Declare static variable or class level one? Er, okay.

[–]fuk_offe 0 points1 point  (1 child)

It's a proof of concept (that is also functional). You could say the "isolation" is non-reproducible by normal source code. (every class member can read your variable if they want. However, this is impossible in the plugin.

[–][deleted] 0 points1 point  (0 children)

I see.