File tree Expand file tree Collapse file tree 2 files changed +34
-5
lines changed
src/test/java/pl/mperor/lab/java Expand file tree Collapse file tree 2 files changed +34
-5
lines changed Original file line number Diff line number Diff line change 1414import java .net .UnknownHostException ;
1515import java .nio .charset .Charset ;
1616
17- /**
18- * Java 18 (March 2022)
19- */
17+ /// Java 18™ (March 2022)
18+ /// [JDK 18](https://openjdk.org/projects/jdk/18)
19+ ///
20+ /// - STANDARD FEATURES:
21+ /// - 400: UTF-8 by Default
22+ /// - 408: Simple Web Server
23+ /// - 421: Deprecate Finalization for Removal
24+ /// - 418: Internet-Address Resolution SPI (service-provider interface)
25+ /// - 413: Code Snippets in Java API Documentation
26+ /// - 416: Reimplement Core Reflection with Method Handles
27+ ///
28+ /// - PREVIEW & INCUBATOR:
29+ /// - 419: Foreign Function & Memory API (Second Incubator)
30+ /// - 420: Pattern Matching for switch (Second Preview)
31+ /// - 417: Vector API (Third Incubator)
2032public class Java18 {
2133
2234 @ Test
@@ -86,8 +98,11 @@ protected void finalize() throws Throwable {
8698
8799 @ Test
88100 public void testInetAddressResolution () throws UnknownHostException {
89- InetAddress address = InetAddress .getByName ("localhost" );
90- Assertions .assertTrue (address .isLoopbackAddress ());
101+ InetAddress localhost = InetAddress .getByName ("localhost" );
102+ Assertions .assertTrue (localhost .isLoopbackAddress ());
103+
104+ InetAddress google = InetAddress .getByName ("google.com" );
105+ Assertions .assertNotNull (google .getAddress ());
91106 }
92107
93108 @ Test
Original file line number Diff line number Diff line change 77import java .io .Closeable ;
88import java .io .File ;
99import java .io .IOException ;
10+ import java .lang .invoke .MethodHandle ;
11+ import java .lang .invoke .MethodHandles ;
12+ import java .lang .invoke .MethodType ;
13+ import java .lang .reflect .Method ;
1014import java .nio .file .Files ;
1115import java .nio .file .Path ;
1216import java .util .concurrent .ForkJoinPool ;
@@ -141,4 +145,14 @@ protected Integer compute() {
141145 }
142146 }
143147
148+ @ Test
149+ public void testMethodHandlesVsCoreReflection () throws Throwable {
150+ Method method = String .class .getMethod ("isEmpty" );
151+ Assertions .assertTrue ((boolean ) method .invoke ("" ));
152+
153+ MethodHandles .Lookup lookup = MethodHandles .lookup ();
154+ MethodHandle methodHandle = lookup .findVirtual (String .class , "isEmpty" , MethodType .methodType (boolean .class ));
155+ Assertions .assertTrue ((boolean ) methodHandle .invoke ("" ));
156+ }
157+
144158}
You can’t perform that action at this time.
0 commit comments