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

refactor: avoid creation of JDT hacking TMP files #944

Merged
merged 1 commit into from
Nov 9, 2016

Conversation

pvojtechovsky
Copy link
Collaborator

I am trying to unify compilation process of snippets, templates and sources. I have found these facts:

JDTBasedSpoonCompiler buildSources and buildTemplates

  • JDTBasedSpoonCompiler.createTmpJavaFile(folder) always creates empty file. So nobody needs content of that file.
  • JDTBasedSpoonCompiler methods buildSources and buildTemplates does the same - compiles java files and fills the model. Just the classpath and files are different. But all other things related to compilation are same!
    So there is no reason why buildTemplates is creating a temporary file next to zip or jar archives, while buildSources does not need that.
    This TMP file creation code is anyway wrong, it actually might produce many empty tmp files and deletes only one of them!
    There is no test case, which would fail, if creation of tmp files here is omitted.
    The code is here since commit 39562eb (nearly 3 years old) and at this time there was used different version of JDT compiler. So there is high chance that JDT bug is already fixed.

So I suggest to get rid of the creation of these temporary files in buildTemplates. And if it really fails by somebody then we can get the stacktrace and can create a test case and can fix it correctly. But actually it looks like useless code, which just makes things more complicated.

JDTSnippetCompiler buildSources

this method creates temporary file too. I have found that JDT compilation does not need existing file. It is enough to provide there some source path and it passes too.

@tdurieux tdurieux merged commit 2a3a2c0 into INRIA:master Nov 9, 2016
@pvojtechovsky pvojtechovsky deleted the avoidTmpFiles branch November 9, 2016 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants