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 10:20 |
Dennis Hendriks Messages: 75 Registered: January 2010 Location: The Netherlands |
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 11:22 |
Dani Megert Messages: 3802 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
|
|
| |
Goto Forum:
Current Time: Sat Nov 09 02:33:53 GMT 2024
Powered by FUDForum. Page generated in 0.02807 seconds
|