I'm getting a error trying to compile a simple code in Eclipse. I'm using jre8.
For example, when I try to compile this code:
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class MyProject {
    public static void main (String args[])
    {
        List<String> myList = new ArrayList<String>();
        myList.add("test");
        myList.add("test2");
        Collections.sort(myList);
    }
}
I get a error in the Collections.sort(myList); line.
The error is:
Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
    The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class files
    at project.Principal.main(Principal.java:14)
I have already opened eclipse Build Path, removed JRE System Library [jre8] and added it again. But didn't work! What can I do? Thanks!
PS.: In the Collections.sort(myList); line eclipse shows this error:
The type java.lang.CharSequence cannot be resolved. It is inderectly referenced from required .class files.
The first Eclipse version supporting Java 8 was Eclipse Kepler SR2 (4.3.2) with an additional patch. (See: Installing Java™ 8 Support in Eclipse Kepler SR2, and the corresponding Marketplace Item that needs to be installed: Java 8 support for Eclipse Kepler SR2).
In my opinion you should udpate to the latest Eclipse Version.
With Luna SR2 (4.4.2) no additional patch is necessary.
Windows > Preferences: Java > Installed JREs

If this is not the case you can add a new JRE with the add button.
JRE System Library == JavaSE-1.8 for your ProjectIn the Package Explorer, you should see the Java version:

If this is not correct you should open the context menu the JRE System Library item and select the Properties menu entry.

In your project you have a .classpath file (Use the Navigator View if you do not see the file), that should looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" path="src"/>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
    <classpathentry kind="output" path="bin"/>
</classpath>
Project Menu > Clean...
Select your project from the list or "Clean all projects" and "Start a build immediately"
See also:
This is because the BytecodeParser class in soot.JastAddJ doesn't support higher version of java class file format.The CONSTANT_MethodHandle,CONSTANT_MethodType and CONSTANT_InvokeDynamic of constant pool type missed.Below is my solution to fix the question:
(1) add the type int soot.JastAddJ.BytecodeParser:
private static final int CONSTANT_MethodHandle=15;
private static final int CONSTANT_MethodType=16;
private static final int CONSTANT_InvokeDynamic=18;
(2) add 3 classes to support the parse:
in the method parseEntry of soot.JastAddJ.BytecodeParser,add 
CONSTANT_MethodHandle_Info, CONSTANT_MethodType_Info, CONSTANT_InvokeDynamic_Info
in the switch case block.
Now,soot can run successfully.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With