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
20
votes
1 answer

Can Java 10 type inference for local variables infer void?

With Java 10, we can use type inference. String s1 = "hello"; // before Java 10 var s2 = "hello"; // now However, there is one thing which we couldn't do before: have variables of type void. So, in previous versions we simply couldn't define the…
mrek
  • 1,655
  • 1
  • 21
  • 34
20
votes
3 answers

Optional.get() versus overloaded Optional.orElseThrow()

How can one avoid explicitly throwing an Exception while trying to get the value from an Optional or while making use of Optional.get? Currently, this is possibly safeguarded with the API orElseThrow as : // exception could be replaced with any…
Naman
  • 27,789
  • 26
  • 218
  • 353
19
votes
2 answers

Does Java 9 include Graal?

I'm reading JEP 317. It says that Graal (a new experimental Java-based JIT compiler) will be part of JDK 10, but then it says that is already available in JDK 9. So, what's the point of JEP 317 then? Does Java 9 include Graal or not?
ZhekaKozlov
  • 36,558
  • 20
  • 126
  • 155
18
votes
2 answers

The import java.awt cannot be resolved

I have installed the Eclipse [Version: Photon Release (4.8.0)] and JDK 10 on a MacBookPro with macOS 10.13.5 When I write in my code: import java.awt.*; I get the error: The import java.awt cannot be resolved Is the java.awt included in JDK 10 ?…
Livio
  • 249
  • 1
  • 2
  • 7
18
votes
3 answers

java 10 compilaton Null Pointer Exception

I recently installed jdk10. I was doing normal code and it is not working. Am I doing something wrong here? Please see the code and Exception stacktrace. As far as I understand there should be no reason for such behaviour. import…
Akshay Darekar
  • 191
  • 1
  • 5
18
votes
1 answer

Internal changes for limit and unordered stream

Basically this came up while trying to answer another question. Suppose this code: AtomicInteger i = new AtomicInteger(0); AtomicInteger count = new AtomicInteger(0); IntStream.generate(() -> i.incrementAndGet()) .parallel() .peek(x…
Eugene
  • 117,005
  • 15
  • 201
  • 306
17
votes
3 answers

Different behavior of WeekFields on JVM 8 and JVM 10

I have really simple program here: public static void main(String[] args) { LocalDate year = LocalDate.ofYearDay(2022, 100); System.out.println(year); System.out.println(WeekFields.of(Locale.GERMAN).weekOfYear()); …
Lukas Forst
  • 802
  • 1
  • 8
  • 25
17
votes
2 answers

How to customise "host" header in Java http client

Here's my code: HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("http://127.0.0.1:8081/")) .header("Host", "test.example.com") .build(); client.send(request,…
Krzysztof Krasoń
  • 26,515
  • 16
  • 89
  • 115
17
votes
2 answers

How do "var" and raw types come together?

I came across an answer that suggests to use var list = new ArrayList(); I was surprised to find a raw type here, and I am simply wondering: does var use the <> "automatically? ( in the meantime, the answer was changed to use , but I am…
GhostCat
  • 137,827
  • 25
  • 176
  • 248
17
votes
2 answers

Why Oracle JDK 9 download ends so early?

I wanted to install JDK 9 on my machine, visited JDK official download page, and was surprised to see, Java SE 9 has reached end of support. Users of Java SE 9 should switch to Java SE 10. Please visit our Java SE Downloads page to get the current…
Red Boy
  • 5,429
  • 3
  • 28
  • 41
17
votes
4 answers

Error:java: java.lang.ExceptionInInitializerError IntelliJ

Heyo! I've ran into some troubles when attempting to boot up Intellij (ultimate) with JDK 10.0.1 and "spring-boot-starter-test". If I run the main method, regardless of its content and regardless of if I have any active tests I always receive…
Kavzor
  • 185
  • 1
  • 1
  • 10
17
votes
2 answers

How to set up java 10 in Eclipse Oxygen?

I am not sure if latest version of eclipse i.e. Oxygen supports java 10 or not. I configured the JRE for java 10 from preferences on my mac machine. Also, I tried adding maven compiler plugin as below to my pom.xml:-
Vinay Prajapati
  • 7,199
  • 9
  • 45
  • 86
16
votes
2 answers

Java var and inference type ambiguity

Both calls are correct: Collectors.groupingBy((String s)->s.toLowerCase(),Collectors.counting()); Collectors.groupingBy((String s)->s.toLowerCase(Locale.ENGLISH),Collectors.counting()); Since then, why the following one is…
Jean-Baptiste Yunès
  • 34,548
  • 4
  • 48
  • 69
16
votes
1 answer

Nashorn performance on JDK 9 and JDK 10

If you interpret the moment.js library using Nashorn on JDK 8, it runs in a couple of seconds: time .../JDK8/bin/jjs moment-with-locales-2.22.2.js real 0m2.644s user 0m10.059s sys 0m0.287s But do the same on JDK 9 or 10, and it's…
16
votes
3 answers

Patch or override an implementation of a core Java 10 class

There is a bug in JFX which often manifests when calculating screen co-ordinates https://bugs.openjdk.java.net/browse/JDK-8194727 and https://bugs.openjdk.java.net/browse/JDK-8190400 I've tracked the problem down to the implementation of…
jambit
  • 313
  • 1
  • 8
1 2
3
26 27