Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CompilationUnit always outputs class files (and I never want class files) #865

Closed
dfht opened this issue Apr 2, 2019 · 5 comments
Closed
Assignees
Labels
Milestone

Comments

@dfht
Copy link

dfht commented Apr 2, 2019

As of latest Eclipse 4.11 compatible version, I am getting unwanted class files generated into my Eclipse home.
In older Greclipse (Eclipse Oxygen versions), the output phase was commented out by CompilationUnit (in constructor - see below).


        // GRECLIPSE edit -- skip output phase
        //addPhaseOperation(output);

The older version even had a public removeOutputPhaseOperation method.

// can be called to prevent classfile output (so only use if something else is taking charge of output)
   public boolean removeOutputPhaseOperation()

Now it seems that class files are always output. (and the removeOutputPhaseOperation method is no longer present).
In my case I never want these class files. I use GroovyClassLoader to compile source that I derive dynamically from models at runtime. Class files are simply undesirable in my case. In fact this kind of dynamism is one of the main reasons I use Groovy for this purpose.
I use a CompilationUnit to compile source derived from my models, and then use defineClass to insert the classes into the class loader. The file system just has no role to play in my particular use case, so I fail to see why I now see unwanted class files being generated into my Eclipse home.
Please restore old behaviour or at least restore the old removal method (or suggest what I should do to easily avoid this phase - in case there is some API I haven't spotted for doing this as phaseOperations is package private, which is kind of ironic as Groovy has always talked about making stuff public by default :)).

@eric-milles
Copy link
Member

eric-milles commented Apr 2, 2019

removeOutputPhaseOperation was refactored into the tweak method (see last statement):

    public void tweak(boolean isReconcile) {
        staticImportVisitor.isReconcile = this.isReconcile = isReconcile;
        verifier.inlineStaticFieldInitializersIntoClinit = !isReconcile;
        phaseOperations[Phases.OUTPUT].remove(output);
    }

I must have missed something in commits 4cc8f8a and 74bd7bd. Thanks for entering this issue; I was wondering why I was seeing class files in my eclipse home sometimes.

@eric-milles eric-milles self-assigned this Apr 2, 2019
@eric-milles eric-milles added the bug label Apr 2, 2019
@eric-milles eric-milles added this to the v3.4.0 milestone Apr 2, 2019
@dfht
Copy link
Author

dfht commented Apr 2, 2019

Thanks for the quick reply and for putting this on the milestone. I'm not sure of the other things it sets in the tweak method to be honest, so perhaps the standalone public method (or old behavior of not doing the output phase in Greclipse) would better suit me... That said, I'm guessing the output phase was put back in (as the default) for a reason? Or maybe the change was just lost when re-patching the base Groovy CompilationUnit class for the later base Groovy version?

@eric-milles
Copy link
Member

You should not need to call tweak -- it is meant for internal use.

I am restoring //addPhaseOperation(output);

@dfht
Copy link
Author

dfht commented Apr 2, 2019

Sounds good! Thanks :)

@eric-milles
Copy link
Member

Ready to test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants