Java 7 And Beyond
From WikiEducator
Java 7 And Beyond |
---|
Convenor: Ben Evans and Marc Hoffmann |
Participants:
... |
Summary:
Java 7: New FeaturesBen gives a overview of new featured in Java 7:
Feature CategoriesThese enhancements happen on different levels and can be categories as follows:
Notes and examples on the new featuresBinary Literals and Underscores: Multiline Strings were intended but too hard to get a consensus on how they should work/rules/etc Diamond OperatorA Map<Stirng,String> hm = new HashMap<>(); A Map<String, Map<String, String>> hm = new HashMap()<>; // same thing Also infers a methodCall(new ArrayList<>()); MultiCatchtry { ... } catch (IOException | FileNotFound | SomethingException e) { // what is e? // its a disjoint union of types - the compiler works it out. From our perspective its the common super type } Try-with-exceptionstry (FileOutputStream for = ….; InputStream is = …) { fos.write(); } finally { println("All done"); }
Invoke DynamicMarc explained a small example, how Java bytecode with an invokedynamic instruction can be created using the ASM [1] library. As the invokedynamic instruction has been created for new script language, the normal Java compiler will not emit such instructions. The example is available for download [2]. Flip Charts |
Recommendations:
... |