What is causing Eclipse Oxygen 1a to throw a newJavaModelException? - java

On Windows 10 I downloaded and installed Eclipse Oxygen [Release (4.7.1a)
Build id: 20171005-1200] using the Eclipse Installer.
I then created a trivial Java project (no module stuff) using the New Project wizard:
public class Demo1 {
public static void main(String[] args) {
new Demo1().test(0L);
}
void test(int i) {
doStuff();
}
void test(long l) {
doStuff();
}
void doStuff() {
String s = "abcde";
s = s.substring(2,4);
System.out.print("s=");
System.out.println( s.toString());
}
}
It runs OK, and if I do CTL=>Open Implementation for test() or doStuff() or System or String or toString() or substr() everything is fine.
However, for println() and print() an error message is displayed:
Also, a stack trace is written to the Error Log:
!ENTRY org.eclipse.jdt.ui 4 0 2017-10-23 01:42:54.695 !MESSAGE An
error occurred while searching for implementations of 'print'. See
error log for details. !STACK 1 Java Model Exception: Java Model
Status [ is not on its project's build path] at
org.eclipse.jdt.internal.core.JavaElement.newJavaModelException(JavaElement.java:570)
at
org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:247)
at
org.eclipse.jdt.internal.core.Openable.openAncestors(Openable.java:505)
at
org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:241)
at
org.eclipse.jdt.internal.core.Openable.openAncestors(Openable.java:505)
at
org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:241)
at
org.eclipse.jdt.internal.core.SourceRefElement.generateInfos(SourceRefElement.java:107)
at
org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement.java:583)
at
org.eclipse.jdt.internal.core.BinaryType.getElementInfo(BinaryType.java:287)
at
org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:306)
at
org.eclipse.jdt.internal.core.BinaryType.isInterface(BinaryType.java:725)
at
org.eclipse.jdt.internal.ui.javaeditor.JavaElementImplementationHyperlink$1.run(JavaElementImplementationHyperlink.java:237)
at
org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:119)
!SUBENTRY 1 org.eclipse.jdt.core 4 1006 2017-10-23 01:42:54.695
!MESSAGE is not on its project's build path
However, after clicking OK, the Implementation popup is displayed as expected, and clicking PrintStream sends me to the correct method implementation:
This looks like a bug in Eclipse or its installer, but the issue is very basic yet I don't see any reports for it. I have a few questions arising:
Does anyone else get this issue, or is it working?
Is there any configuration I could/should do to fix this?
Any ideas why Open Implementation would be giving the error only for print() and println()?

This seems to be a bug in the current implementation as pointed out by #ZhekaKozlov and from another thread where #Stephan has shared a work in progress documentation for the future release's New & Noteworthy for Photon M3 states that:-
Note: It is not mandatory to run Eclipse with Java Runtime 9 to get the Java 9 support. However, a Java runtime 9 is required to be on
a project's build path to compile a modular project against the system
modules.
When a Java Runtime 9 is added to a project's build path, the system modules are listed under the System library in the package explorer:
I am assuming the --add-modules=ALL-SYSTEM was solving this while users were appending this as a -vmargs arg to eclipse.ini.

Related

Error: "UnsatisfedLinkError: com.aparapi.internal.jni.OPENCLJNI.getPlatforms()" JNI configuration

I would try to execute an example script based on Aparapi, on MAC OS. I'm using the last version of Eclipse, but when I execute DeviceInfo example to get all the available devices:
public class DeviceInfo {
public static void main(String[] args) {
KernelPreferences preferences = KernelManager.instance().getDefaultPreferences();
System.out.println("-- Devices in preferred order --");
for (Device device : preferences.getPreferredDevices(null)) {
System.out.println(device);
}
}
}
it generates the
java.lang.UnsatisfiedLinkError: com.amd.aparapi.OpenCLJNI.getPlatforms()Ljava/util/List"
Is there someone who can help me?
build the native assembly for Mac (x86_64) and add it into jniLibs; here's the source code.
java.lang.UnsatisfiedLinkError generally means, that it cannot find the native assembly.
Despite macOS Mojave 10.14.4 don't support directly OpenCL, I've executed Aparapi Framework.
I founded that the problem is the Aparapi Library. In particular, to resolve generated error I followed these steps:
Download this repository https://github.com/aparapi/aparapi for AMD Graphic Cards
Open the directory "com.amd.aparapi" and from terminal execute
ant -f build.xml
This command generates .jar file of this library
Add the generate jar to the project's classpath in Eclipse
Add the specific Aparapi library for your OS in:
<your-workspace-path>/<your-project>/src/main/resources/osx/
Before to execute the code, add the VM argument in "Run Configuration"
-Djava.library.path=<your-workspace-path>/<your-project>/src/main/resources/osx/
Execute your script!

Cannot add -ea arguments to Eclipse class

Here's a simple program that I try to run:
public class TutorialExample {
public static void main(String[] args) {
boolean example = true;
assert example == true;
}
}
I have tried to follow these steps exactly for this common issue, but am unsuccessful. I still get the resulting error that reads:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
assert cannot be resolved to a type
Duplicate local variable example
Syntax error on token "==", = expected
Here is a sample image of my run configurations with the VM argument -ea included.
The Run Configuration only sets options for when you run your code. You have a problem with compiling the code.
Open the Preferences and go to the 'Java > Compiler' page. Check that the 'Compiler compliance level' is set the same level as the Java release you are running (but must be at least 1.4 for assert).
It is also possible to have Java settings specific to a project so also check the project 'Java Compiler' page in the Properties for the the project.

Intellij Idea: Issues with building project using IBM JDK 7

I've a project which has requirement to use with IBM JDK 7. I'm using Intellij Idea 15.0.2 on windows 7. My project is multi-module maven project and uses some groovy scripts and also uses gradle to flatten the POMs using maven org.fortasoft:gradle-maven-plugin. Now when I try to build my application (Build -> Rebuild Project), I get a one liner error in Messages window
Error:java.lang.NullPointerException
When I check build.log (C:\Users\.IntelliJIdea15\system\log\build-log\build.log), I see following exception. As soon as I change the project SDK to Oracle JDK 7, everything works fine. Any idea on whats going wrong here?
[Update 1:] I also tried to invalidate cache and restarted idea, just to rule out cache is playing foul play here.
2015-12-22 14:16:23,343 [ 4126] INFO - .incremental.IncProjectBuilder - java.lang.NullPointerException
org.jetbrains.jps.incremental.ProjectBuildException: java.lang.NullPointerException
at org.jetbrains.jps.incremental.groovy.GroovyBuilder.build(GroovyBuilder.java:142)
at org.jetbrains.jps.incremental.IncProjectBuilder.runModuleLevelBuilders(IncProjectBuilder.java:1230)
at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:904)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:976)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:870)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:695)
at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:386)
at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:193)
at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:137)
at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:294)
at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:125)
at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler$1.run(BuildMain.java:232)
at org.jetbrains.jps.service.impl.SharedThreadPoolImpl$1.run(SharedThreadPoolImpl.java:42)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:482)
at java.util.concurrent.FutureTask.run(FutureTask.java:273)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1176)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:795)
Caused by: java.lang.NullPointerException
at java.lang.ClassLoader.loadClass(ClassLoader.java:731)
at java.lang.ClassLoader.loadClass(ClassLoader.java:707)
at org.jetbrains.jps.incremental.groovy.InProcessGroovyc.createCompilationClassLoader(InProcessGroovyc.java:179)
at org.jetbrains.jps.incremental.groovy.InProcessGroovyc.runGroovyc(InProcessGroovyc.java:76)
at org.jetbrains.jps.incremental.groovy.GroovyBuilder.runGroovycOrContinuation(GroovyBuilder.java:201)
at org.jetbrains.jps.incremental.groovy.GroovyBuilder.build(GroovyBuilder.java:117)
... 17 more
Any idea on whats going wrong here?
IF we look to InProcessGroovyc.createCompilationClassLoader, we can see code
private JointCompilationClassLoader createCompilationClassLoader(Collection<String> compilationClassPath) throws Exception {
ClassLoader parent = obtainParentLoader(compilationClassPath);
ClassLoader groovyClassLoader = null;
try {
ClassLoader auxiliary = parent != null ? parent : buildCompilationClassLoader(compilationClassPath, null).get();
Class<?> gcl = auxiliary.loadClass("groovy.lang.GroovyClassLoader"); // 179 line, we throw NullPointer Exception
In ClassLoader.loadClass
public Class<?> loadClass(String name) throws ClassNotFoundException {
return loadClass(name, false); // 131 line
}
protected Class<?> loadClass(String name, boolean resolve)
throws ClassNotFoundException
{
synchronized (getClassLoadingLock(name)) {
// First, check if the class has already been loaded
Class<?> c = findLoadedClass(name); // return null if class not found
So main problem that IBM JDK 7 can't find groovy.lang.GroovyClassLoader, please check that groovy install correctly, IBM JDK can see groovy lib (groovy was downloaded, GROOVY_HOME environment variable is set correctly and GROOVY_HOME/bin added to your PATH environment variable).
So it seems that this is actually a bug with v15.0.2. Workaround is to add -Didea.parallel.class.loader=false under Settings | Build, Execution, Deployment | Compiler | User-local build process VM options
More details here. Fix should be available with v15.0.3. Till that time this workaround works (at least for me).

Eclipse throws org.osgi.framework.BundleException on launch

When I try launching Eclipse Indigo on Windows XP I am getting an error and the prompter tells me to go to the log file.
Apparently, it's throwing an org.osgi.framework.BundleException:
!ENTRY org.eclipse.ui.ide 4 0 2012-02-01 11:17:19.301 !MESSAGE
FrameworkEvent ERROR !STACK 0 org.osgi.framework.BundleException:
Exception in org.eclipse.ui.internal.ide.IDEWorkbenchPlugin.stop() of
bundle org.eclipse.ui.ide. at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.stop(BundleContextImpl.java:791)
at
org.eclipse.osgi.framework.internal.core.BundleHost.stopWorker(BundleHost.java:510)
at
org.eclipse.osgi.framework.internal.core.AbstractBundle.suspend(AbstractBundle.java:565)
at
org.eclipse.osgi.framework.internal.core.Framework.suspendBundle(Framework.java:1161)
at
...
Does anyone know how to fix this? I believe it stopped working because I played around with the Java path trying to get a project ported onto a Blackberry emulator.
However I tried setting the path to the correct value but I'm getting no luck.
I've even installed a fresh version of Eclipse into another directory but the problem does not go away.
From http://www.javalobby.org/java/forums/t92895.html (as indicated by Banana Man in the comments):
Put the unzipped "eclipse" folder under c drive. Create a shortcut of
"eclipse.exe". In the target, put this:
C:\eclipse\eclipse.exe -vm "C:\Program
Files\Java\jre1.5.0_11\bin\javaw.exe"
Note - "C:\Program Files\Java\jre1.5.0_11\bin\javaw.exe" is where your
jre is installed at. You can change this path to match your your jre
path.
In the start in, I have this: C:\eclipse

Java virtual machine launch issue

HI All,
I got an issue, all of a sudden Java stopped working completely. I start getting error like "Could not create the virtual machine". There is no issue with the memory (it has 3GB RAM) and was working fine for over a 6 months in this system without any issue.
Here are some peculiar behaviors -
When I start eclipse I see Java virtual machine dialog box with error messages like
"Could not find main class org.eclipse......support.legacysystemproperties"
Eclipse is able to start(with above error), but while running the program, I get error like "Could not create Java Virtual Machine" in a dialog box and after I click OK on that dialog box, I see error like "unrecognized option -dfile.encoding=cp1252
I used text editor, wrote a class Test.java (without any package), compiled it (Edit #1:javac Test.java). But when I execute the program (Edit #1:java Test), I get the following error -
Exception in thread "main" java.lang.NoClassDefFoundError: test (wrong name: Test).
Edit #1:
Note : The compiled file, Test.class is successfully created in the directory. I did recheck the path and classpath environment variables. All seem to be correct.
Please note that there seems to be some issues with cases which affected the Java.
I did uninstall Java (all versions), re-installed, but nothing helped. Also, I did run CCleaner to clean registry, Malwarebytes' Anti-Malware, but none helped so far.
Appreciate if someone could help me to resolve the issue.
I did googled for this and found that some have experienced similar issues, but none of them have found solution yet other than some suggestion that re-installation of Windows OS itself, which I want to avoid it. I did system restore, but that failed for some other
reason.
Please note that am using Java for over 10 years. This is first time am having such issue. This is something to do with Windows Registry or some other system configuration, but I am not able to find out the exact problem.
Anyways awaiting some good suggestion.
EDIT: Okay, so it looks like the Java executable is getting the command line arguments lower-cased.
Step 1: Verify
You can double-check whether this affects all command line arguments by creating a class with a lower-case name which just dumps its arguments:
public class test {
public static void main(String[] args) {
for (String arg : args) {
System.out.println(arg);
}
}
}
Compile and run this with a variety of inputs.
Step 2: Check scope
Assuming step 1 confirms the problem, if you've got .NET installed you can see whether it affects that as well. Create a file Test.cs:
using System;
class Test
{
static void Main(string[] args)
{
foreach (string arg in args)
{
Console.WriteLine(arg);
}
}
}
Compile this with "csc Test.cs" having found csc in the .NET framework directory (e.g. in c:\Windows\Microsoft.NET\Framework\v4.0.30319 for .NET 4).
Run it like this:
Test foo BAR Baz
and see what happens
Step 3: If step 2 showed that the issue is limited to java.exe:
Check your path, and work out where you're actually running java.exe from
Try explicitly running java.exe from your JRE or JDK directory

Categories

Resources