Created
September 21, 2016 12:40
-
-
Save struberg/4be74fcda608178e20549331779a10e5 to your computer and use it in GitHub Desktop.
Java bytecode coercion with Java9 and the --release option
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.concurrent.ConcurrentHashMap; | |
public class Test { | |
public static void main(String[] args) { | |
ConcurrentHashMap<String, String> map = new ConcurrentHashMap<>(); | |
map.put("A", "B"); | |
map.keySet(); | |
} | |
} | |
Java8 and 9: | |
$> javac Test.java | |
$> javap -c Test.class | |
18: invokevirtual #7 // Method java/util/concurrent/ConcurrentHashMap.keySet:()Ljava/util/concurrent/ConcurrentHashMap$KeySetView; | |
(note the KeySetView which only got introduced in Java8!) | |
Java7 compatibility: | |
$> javac --release 7 Test.java | |
$> javap -c Test.class | |
18: invokevirtual #7 // Method java/util/concurrent/ConcurrentHashMap.keySet:()Ljava/util/Set; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment