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

402 questions
34
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
  • 770
  • 1
  • 11
  • 21
33
votes
1 answer

Explanation of the Thread-Local Handshakes

As part of the putative JDK 10 this JEP 312: Thread-Local Handshakes was proposed. I've tried to grasp its description, but I am still not confident that I got the idea properly. Is it essentially an attempt to reanimate something similar to the…
Andremoniy
  • 34,031
  • 20
  • 135
  • 241
32
votes
5 answers

JAXB not available on Tomcat 9 and Java 9/10

TLDR: On Java 9/10, a web app in Tomcat has no access to JAXB even though its reference implementation is present on the class path. Edit: No, this is not a duplicate of How to resolve java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException in…
Nicolai Parlog
  • 47,972
  • 24
  • 125
  • 255
28
votes
5 answers

Unrecognized VM option 'UseParNewGC' , Error: Could not create the Java Virtual Machine

I am trying to start a server using jre 10.0.1 64 bit. There is an obvious change in the settings for the JVM in windows start batch files. With the setting of -XX:+UseParNewGC as the reference point of the error what would this need to be changed…
Javacodeman113
  • 407
  • 1
  • 4
  • 11
28
votes
2 answers

Why am I getting an AssertionError when assigning Arrays.asList() to var directly?

I'm trying to understand local variable type inference in Java 10. The code below works perfectly during compilation and runtime: List list1 = Arrays.asList(1L, 2.0F, "3"); var list2 = list1; However, this line throws a compilation error: var…
hoan
  • 1,058
  • 8
  • 13
27
votes
1 answer

Migrate Jersey project to use Java 10 results in java.lang.IllegalArgumentException at jersey.repackaged.org.objectweb.asm.ClassReader.

Previously, when the project was on Tomcat 8 and Java 8, it was working fine, but after I migrated my project to Tomcat 9 and Java 10, it is giving me error as follows: Oct 05, 2018 11:02:01 AM org.apache.catalina.core.ApplicationContext log SEVERE:…
Jaydeep Bobade
  • 1,005
  • 2
  • 16
  • 25
27
votes
1 answer

Should I use var in Java 10?

Given that I can't use var for non-denotable types (Nulls, Anonymous classes, Some Single Method Class and most importantly Intersecting Types), am I better off not using it for better readability and consistency (given that it's only for local…
Antho Christen
  • 1,369
  • 1
  • 10
  • 21
27
votes
2 answers

"array initializer needs an explicit target-type" - why?

Following JEP 286: Local-Variable Type Inference description I am wondering, what the reason is for introducing such a restriction, as: Main.java:199: error: cannot infer type for local variable k var k = { 1 , 2 }; ^ (array…
Andremoniy
  • 34,031
  • 20
  • 135
  • 241
25
votes
1 answer

What is the conceptual difference between a "restricted keyword" and "reserved type name" in Java 10?

Java 10 comes with the new Local Variable Type Inference. The token var can be used to reduce the boilerplate required when declaring a variable. e.g. var s = "hello"; According to What type of token is exactly "var" in Java 10? this new token is…
bhspencer
  • 13,086
  • 5
  • 35
  • 44
23
votes
3 answers

“var” in java 10 and kotlin

I know that we can use the “var” keyword for defining variables in Kotlin: var foo = 3 The latest java update (java 10) also introduces the “var” type: var bar = new int[]{1, 2, 3}; // int[] bar = {1, 2, 3} My question is, what is the difference…
gldanoob
  • 762
  • 1
  • 7
  • 18
22
votes
2 answers

How to use Application Class-Data Sharing feature of java 10?

I read about CDS in Oracle doc https://docs.oracle.com/javase/8/docs/technotes/guides/vm/class-data-sharing.html What I understood is the system class files needed for loading the jvm are parsed, verified and then stored in a archive at …
Shubham Kadlag
  • 2,248
  • 1
  • 13
  • 32
22
votes
3 answers

Can't link to JDK10 in Javadoc comments

After upgrading from Java 9 to 10, links to the JDK no longer work when generating documentation with the Javadoc tool (e.g., for a file importing java.util.Optional, {@link Optional} renders as Optional instead of as Optional; same issue with @see,…
gdejohn
  • 7,451
  • 1
  • 33
  • 49
21
votes
2 answers

What type of token exactly is "var" in Java 10?

In the last issue of Heinz Kabutz's newsletter, #255 Java 10: Inferred Local Variables, it is shown that var is not a reserved word in Java 10, because you can also use var as an identifier: public class Java10 { var var = 42; // <-- this…
fps
  • 33,623
  • 8
  • 55
  • 110
20
votes
1 answer

RandomAccessFile.setLength much slower on Java 10 (Centos)

The following code public class Main { public static void main(String[] args) throws IOException { File tmp = File.createTempFile("deleteme", "dat"); tmp.deleteOnExit(); RandomAccessFile raf = new RandomAccessFile(tmp,…
Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
20
votes
3 answers

How can I install Netbeans with JDK 10

I try the command line with JavaHome: netbeans-trunk-nightly-201803230002-javase-windows.exe --javahome "C:\Program Files\Java\jdk-10" It should work, but I receive a message: There is no JRE at the specified location C:\Program…
Tiến Phạm Văn
  • 303
  • 1
  • 2
  • 4
1
2
3
26 27