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

using the ASTParser outside of OSGi environment causes NPE #1077

Open
martinlippert opened this issue Dec 20, 2024 · 1 comment
Open

using the ASTParser outside of OSGi environment causes NPE #1077

martinlippert opened this issue Dec 20, 2024 · 1 comment

Comments

@martinlippert
Copy link

I am using the ASTParser from JDT outside of an OSGi environment, basically as a maven dependency. This works nicely with the standard ASTParser. Now I am doing some early-bird experiments using the latest Javac-based parser implementation and it looks like that parser implementation requires some OSGi stuff to be running to fetch preferences.

I know that this use case might not be a priority at the moment for the efforts around the Javac-based implementation (totally understandable), but maybe you find this report useful nevertheless... :-)

Here is the stack trace that I am running into:

java.lang.ExceptionInInitializerError
	at org.eclipse.core.internal.preferences.PreferencesService.<init>(PreferencesService.java:70)
	at org.eclipse.core.internal.preferences.PreferencesService.getDefault(PreferencesService.java:61)
	at org.eclipse.core.internal.preferences.AbstractScope.getNode(AbstractScope.java:38)
	at org.eclipse.jdt.internal.javac.ProcessorConfig.getRawProcessorOptions(ProcessorConfig.java:102)
	at org.eclipse.jdt.internal.javac.ProcessorConfig.getProcessorOptions(ProcessorConfig.java:54)
	at org.eclipse.jdt.internal.javac.JavacUtils.configureOptions(JavacUtils.java:184)
	at org.eclipse.jdt.internal.javac.JavacUtils.configureJavacContext(JavacUtils.java:91)
	at org.eclipse.jdt.internal.javac.JavacUtils.configureJavacContext(JavacUtils.java:64)
	at org.eclipse.jdt.core.dom.JavacCompilationUnitResolver.parse(JavacCompilationUnitResolver.java:636)
	at org.eclipse.jdt.core.dom.JavacCompilationUnitResolver.resolve(JavacCompilationUnitResolver.java:192)
	at org.eclipse.jdt.core.dom.ASTParser.createASTs(ASTParser.java:1105)
	at org.springframework.ide.vscode.boot.java.utils.ASTParserCleanupEnabled.createASTs(ASTParserCleanupEnabled.java:105)
	at org.springframework.ide.vscode.boot.java.utils.SpringIndexerJava.scanFiles(SpringIndexerJava.java:590)
	at org.springframework.ide.vscode.boot.java.utils.SpringIndexerJava.scanFiles(SpringIndexerJava.java:519)
	at org.springframework.ide.vscode.boot.java.utils.SpringIndexerJava.initializeProject(SpringIndexerJava.java:162)
	at org.springframework.ide.vscode.boot.app.SpringSymbolIndex$InitializeProject.run(SpringSymbolIndex.java:897)
	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1848)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.base/java.lang.Thread.run(Thread.java:1575)
Caused by: java.lang.NullPointerException: Cannot invoke "org.eclipse.osgi.service.datalocation.Location.isReadOnly()" because "location" is null
	at org.eclipse.core.runtime.preferences.ConfigurationScope.getLocation(ConfigurationScope.java:79)
	at org.eclipse.core.internal.preferences.ConfigurationPreferences.<clinit>(ConfigurationPreferences.java:31)
	... 20 more
java.lang.ExceptionInInitializerError
	at org.eclipse.core.internal.preferences.PreferencesService.<init>(PreferencesService.java:70)
	at org.eclipse.core.internal.preferences.PreferencesService.getDefault(PreferencesService.java:61)
	at org.eclipse.core.internal.preferences.AbstractScope.getNode(AbstractScope.java:38)
	at org.eclipse.jdt.internal.javac.ProcessorConfig.getRawProcessorOptions(ProcessorConfig.java:102)
	at org.eclipse.jdt.internal.javac.ProcessorConfig.getProcessorOptions(ProcessorConfig.java:54)
	at org.eclipse.jdt.internal.javac.JavacUtils.configureOptions(JavacUtils.java:184)
	at org.eclipse.jdt.internal.javac.JavacUtils.configureJavacContext(JavacUtils.java:91)
	at org.eclipse.jdt.internal.javac.JavacUtils.configureJavacContext(JavacUtils.java:64)
	at org.eclipse.jdt.core.dom.JavacCompilationUnitResolver.parse(JavacCompilationUnitResolver.java:636)
	at org.eclipse.jdt.core.dom.JavacCompilationUnitResolver.resolve(JavacCompilationUnitResolver.java:192)
	at org.eclipse.jdt.core.dom.ASTParser.createASTs(ASTParser.java:1105)
	at org.springframework.ide.vscode.boot.java.utils.ASTParserCleanupEnabled.createASTs(ASTParserCleanupEnabled.java:105)
	at org.springframework.ide.vscode.boot.java.utils.SpringIndexerJava.scanFiles(SpringIndexerJava.java:590)
	at org.springframework.ide.vscode.boot.java.utils.SpringIndexerJava.scanFiles(SpringIndexerJava.java:519)
	at org.springframework.ide.vscode.boot.java.utils.SpringIndexerJava.initializeProject(SpringIndexerJava.java:162)
	at org.springframework.ide.vscode.boot.app.SpringSymbolIndex$InitializeProject.run(SpringSymbolIndex.java:897)
	at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1848)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.base/java.lang.Thread.run(Thread.java:1575)
Caused by: java.lang.NullPointerException: Cannot invoke "org.eclipse.osgi.service.datalocation.Location.isReadOnly()" because "location" is null
	at org.eclipse.core.runtime.preferences.ConfigurationScope.getLocation(ConfigurationScope.java:79)
	at org.eclipse.core.internal.preferences.ConfigurationPreferences.<clinit>(ConfigurationPreferences.java:31)
	... 20 more

@mickaelistria
Copy link

This report is interesting and welcome, but as you expect, we won't make a priority fixing it.
But as any sane OSS project, we would try to prioritize any incoming pull request and would be happy to merge such PR if it fixes issues without harm ;)

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

No branches or pull requests

2 participants