Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » [compiler] EclipseCompiler does not ask JavaFileManager for input files
[compiler] EclipseCompiler does not ask JavaFileManager for input files [message #945278] Mon, 15 October 2012 06:20 Go to next message
Dennis Hendriks is currently offline Dennis Hendriks
Messages: 61
Registered: January 2010
Location: Eindhoven, The Netherland...
Member
Hi all,

For a while, I've been using the javax.tools.JavaCompiler interface, and
the implementation of this interface that comes with the Sun JDK. I've used
this for runtime in-memory compilation, where both the input Java sources
and the output class files are stored in-memory.

I tried to switch the JavaCompiler to EclipseCompiler, provided by JDT.
However, it seems that the EclipseCompiler does not use the JavaFileManager
that I've provided, to load dependencies. That is, imports are resolved
without using the JavaFileManager, as indicated by this stack trace:

FileSystem.isPackage(char[][], char[]) line: 364
LookupEnvironment.getTopLevelPackage(char[]) line: 1139
CompilationUnitScope.findImport(char[][], int) line: 433
CompilationUnitScope.findSingleImport(char[][], int, boolean) line: 492
CompilationUnitScope.resolveSingleImport(ImportBinding, int) line: 705
ClassScope(Scope).getTypeOrPackage(char[], int, boolean) line: 2733
ClassScope(Scope).getType(char[]) line: 2466
SingleTypeReference.getTypeBinding(Scope) line: 44
SingleTypeReference(TypeReference).internalResolveType(Scope) line: 132
SingleTypeReference(TypeReference).resolveType(ClassScope) line: 208
SingleTypeReference(TypeReference).resolveSuperType(ClassScope) line: 186
ClassScope.findSupertype(TypeReference) line: 1229
ClassScope.connectSuperclass() line: 895
ClassScope.connectTypeHierarchy() line: 1049
CompilationUnitScope.connectTypeHierarchy() line: 304
LookupEnvironment.completeTypeBindings() line: 214
Compiler.internalBeginToCompile(ICompilationUnit[], int) line: 746
Compiler.beginToCompile(ICompilationUnit[]) line: 383
Compiler.compile(ICompilationUnit[]) line: 432
EclipseCompilerImpl(Main).performCompilation() line: 3891
EclipseCompilerImpl.call() line: 72
EclipseCompiler$1.call() line: 185
[...]

Here, an import is resolved, but instead of using the JavaFileManger that I
provided, it is using LookupEnvironment and FileSystem, which seem to use
only the classpath.

To me, it seems like the EclipseCompiler, while it implements the
javax.tools.JavaCompiler interface, is not compatible with that interface,
as it bypasses the JavaFileManager. At the very least, it is not compatible
with Sun's implementation of the JavaCompiler interface, which does ask the
JavaFileManager for ALL inputs, dependencies, etc.

I could not find a bugzilla for this inconsistency.

Could anyone shed some light on this?

Thanks,
Dennis
Re: [compiler] EclipseCompiler does not ask JavaFileManager for input files [message #946656 is a reply to message #945278] Tue, 16 October 2012 07:22 Go to previous messageGo to next message
Dani Megert is currently offline Dani Megert
Messages: 3801
Registered: July 2009
Senior Member
On 15.10.2012 12:20, Dennis Hendriks wrote:
> Hi all,
>
> For a while, I've been using the javax.tools.JavaCompiler interface,
> and the implementation of this interface that comes with the Sun JDK.
> I've used this for runtime in-memory compilation, where both the input
> Java sources and the output class files are stored in-memory.
>
> I tried to switch the JavaCompiler to EclipseCompiler, provided by
> JDT. However, it seems that the EclipseCompiler does not use the
> JavaFileManager that I've provided, to load dependencies. That is,
> imports are resolved without using the JavaFileManager, as indicated
> by this stack trace:
>
> FileSystem.isPackage(char[][], char[]) line: 364
> LookupEnvironment.getTopLevelPackage(char[]) line: 1139
> CompilationUnitScope.findImport(char[][], int) line: 433
> CompilationUnitScope.findSingleImport(char[][], int, boolean) line: 492
> CompilationUnitScope.resolveSingleImport(ImportBinding, int) line: 705
> ClassScope(Scope).getTypeOrPackage(char[], int, boolean) line: 2733
> ClassScope(Scope).getType(char[]) line: 2466
> SingleTypeReference.getTypeBinding(Scope) line: 44
> SingleTypeReference(TypeReference).internalResolveType(Scope) line: 132
> SingleTypeReference(TypeReference).resolveType(ClassScope) line: 208
> SingleTypeReference(TypeReference).resolveSuperType(ClassScope) line: 186
> ClassScope.findSupertype(TypeReference) line: 1229
> ClassScope.connectSuperclass() line: 895
> ClassScope.connectTypeHierarchy() line: 1049
> CompilationUnitScope.connectTypeHierarchy() line: 304
> LookupEnvironment.completeTypeBindings() line: 214
> Compiler.internalBeginToCompile(ICompilationUnit[], int) line: 746
> Compiler.beginToCompile(ICompilationUnit[]) line: 383
> Compiler.compile(ICompilationUnit[]) line: 432
> EclipseCompilerImpl(Main).performCompilation() line: 3891
> EclipseCompilerImpl.call() line: 72
> EclipseCompiler$1.call() line: 185
> [...]
>
> Here, an import is resolved, but instead of using the JavaFileManger
> that I provided, it is using LookupEnvironment and FileSystem, which
> seem to use only the classpath.
>
> To me, it seems like the EclipseCompiler, while it implements the
> javax.tools.JavaCompiler interface, is not compatible with that
> interface, as it bypasses the JavaFileManager. At the very least, it
> is not compatible with Sun's implementation of the JavaCompiler
> interface, which does ask the JavaFileManager for ALL inputs,
> dependencies, etc.
>
> I could not find a bugzilla for this inconsistency.
I suspect you ran into https://bugs.eclipse.org/188796

Dani
>
> Could anyone shed some light on this?
>
> Thanks,
> Dennis
Re: [compiler] EclipseCompiler does not ask JavaFileManager for input files [message #946747 is a reply to message #946656] Tue, 16 October 2012 09:10 Go to previous message
Dennis Hendriks is currently offline Dennis Hendriks
Messages: 61
Registered: January 2010
Location: Eindhoven, The Netherland...
Member
> I suspect you ran into https://bugs.eclipse.org/188796
Yes, that is exactly it. I'll continue the conversation in that bugzilla. Thanks!
Previous Topic:Refresh and classpath initialisation
Next Topic:[APT] Annotation Processor - java.lang.NoClassDefFoundError: javax/persistence/Column
Goto Forum:
  


Current Time: Sat Apr 19 11:47:19 EDT 2014

Powered by FUDForum. Page generated in 0.01629 seconds