Questions tagged [java-10]

Use this tag for questions specific to Java 10, which is version 10 of the Java platform, released on 20 March 2018. In most cases you should also specify the java tag.

Oracle announced the general availability of Java SE 10 (JDK 10) on March 20, 2018.

JDK 10 is a production-ready implementation of the Java SE 10 Platform Specification, as specified by JSR 383 in the Java Community Process.

Key features include:

  • Local-variable type inference: enhances the Java language to extend type inference to declarations of local variables with initializers.
  • Parallel Full GC for G1: improves G1 worst-case latencies by making the full GC parallel.
  • Application Class-Data Sharing: optimizes startup time and footprint by extending the existing Class-Data Sharing ("CDS") feature to allow application classes to be placed in the shared archive.
  • Experimental Java-Based JIT Compiler: enables the Java-based JIT compiler, Graal, to be used as an experimental JIT compiler on the Linux/x64 platform

Other document links - Release Notes and API JavaDoc

397 questions
989
votes
37 answers

How to resolve java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException

I have some code that uses JAXB API classes which have been provided as a part of the JDK in Java 6/7/8. When I run the same code with Java 9, at runtime I get errors indicating that JAXB classes can not be found. The JAXB classes have been…
Andy Guibert
  • 34,857
  • 7
  • 32
  • 54
770
votes
1 answer

Why does array[idx++]+="a" increase idx once in Java 8 but twice in Java 9 and 10?

For a challenge, a fellow code golfer wrote the following code: import java.util.*; public class Main { public static void main(String[] args) { int size = 3; String[] array = new String[size]; Arrays.fill(array, ""); for(int i =…
Olivier Grégoire
  • 28,397
  • 21
  • 84
  • 121
151
votes
8 answers

Unable to compile simple Java 10 / Java 11 project with Maven

I have a trivial Maven project: src └── main └── java └──…
ZhekaKozlov
  • 29,055
  • 16
  • 100
  • 138
74
votes
7 answers

How to install JDK 10 under Ubuntu?

How do I install Java Development Kit (JDK) 10 on Ubuntu? The installation instructions on Oracle's help center only explain how to download and extract the archive on Linux platform, without any system setup.
Sam
  • 11,071
  • 8
  • 41
  • 63
67
votes
7 answers

Why can't the var keyword in Java be assigned a lambda expression?

It is allowed to assign var in Java 10 with a string like: var foo = "boo"; While it is not allowed to assign it with a lambda expression such as: var predicateVar = apple -> apple.getColor().equals("red"); Why can't it infer a lambda or method…
hi.nitish
  • 2,154
  • 1
  • 11
  • 20
60
votes
9 answers

Eclipse can't find XML related classes after switching build path to JDK 10

I'm developing on a Maven project (branch platform-bom_brussels-sr7) in Eclipse. When I recently tried switching the Java Build Path for the project to JDK 10, Eclipse build can no longer find classes such as javax.xml.xpath.XPath,…
Carsten
  • 3,914
  • 4
  • 28
  • 47
59
votes
2 answers

Difference in behaviour of the ternary operator on JDK8 and JDK10

Consider the following code public class JDK10Test { public static void main(String[] args) { Double d = false ? 1.0 : new HashMap().get("1"); System.out.println(d); } } When running on JDK8, this code prints…
SerCe
  • 5,190
  • 1
  • 26
  • 45
51
votes
4 answers

findResource("") returning null when module-info.java is present, why is that?

I'm debugging why in the presence of module-info.java in my Spring Boot application, spring-orm throws an exception during start up time. This is the exception: org.springframework.beans.factory.BeanCreationException: Error creating bean with name…
pupeno
  • 256,034
  • 114
  • 324
  • 541
50
votes
3 answers

SimpleDateFormat with German Locale - Java 8 vs Java 10+

I have code and a test-case in a legacy application, which can be summarized as follows: @Test public void testParseDate() throws ParseException { String toParse = "Mo Aug 18 11:25:26 MESZ +0200 2014"; String pattern = "EEE MMM dd HH:mm:ss z…
rzo1
  • 4,764
  • 2
  • 21
  • 59
41
votes
3 answers

Does Java 10 provide a val keyword? If not, why not?

Java 10 brings a C#-like var keyword for local type-inference. But does Java 10 also provide a val keyword, as is found in Scala? val would work like var but the binding would be final. var x = "Hello, world. "; x = "abc"; // allowed val y =…
sdgfsdh
  • 24,047
  • 15
  • 89
  • 182
40
votes
7 answers

Maven: Invalid target release: 10

I'm trying to compile my maven project using Java 10 but I'm having trouble. In my IDE (IntelliJ IDEA) everything compiles and runs just fine under Java 10. I installed the latest maven version 3.5.4 and pointed my JAVA_HOME to the JDK 10: $ mvn…
BullyWiiPlaza
  • 12,477
  • 7
  • 82
  • 129
39
votes
4 answers

Proper fix for Java 10 complaining about illegal reflection access by jaxb-impl 2.3.0?

We are looking at upgrading some legacy code to Java 10. As JAXB is not visible by default (EDIT: and the proper long term solution is not to circumvent the symptom using various JVM flags, but fix it properly) I have added this snippet to my…
Thorbjørn Ravn Andersen
  • 68,906
  • 28
  • 171
  • 323
38
votes
3 answers

Java 10: Will Java 7's Diamond Inference Work with Local Type Inference?

From JEP 286, we see that we'll be able to utilize local type inference (var) in JDK 10 (18.3). The JEP states that the following compiles, which is expected: var list = new ArrayList(); // infers ArrayList I'm curious to know…
Jacob G.
  • 26,421
  • 5
  • 47
  • 96
35
votes
4 answers

Does using var with a literal result in a primitive or a primitive wrapper class?

After reading and talking about Java 10s new reserved type name var (JEP 286: Local-Variable Type Inference), one question arose in the discussion. When using it with literals like: var number = 42; is number now an int or an Integer? If you just…
sweisgerber.dev
  • 1,517
  • 15
  • 34
33
votes
2 answers

Generics behavior differs in JDK 8 and 9

The following simple class (repo to reproduce it): import static org.hamcrest.*; import static org.junit.Assert.assertThat; import java.util.*; import org.junit.Test; public class TestGenerics { @Test public void thisShouldCompile() { …
alostale
  • 740
  • 11
  • 18
1
2 3
26 27