java基础峰会项目
Last week was the Java Virtual Machine Language Summit, where language designers and JVM engineers come together every year to present the newest developments and discuss the future of the virtual machine. For us Java developers this might seem one step removed, after all the JVM is just the machinery executing our code. And the event itself is thoroughly overshadowed by the upcoming JavaOne.
上周是Java虚拟机语言峰会 ,语言设计师和JVM工程师每年聚集一堂,介绍最新的发展并讨论虚拟机的未来。 对于我们的Java开发人员来说,这似乎已消除了一步,毕竟JVM只是执行我们代码的机器。 即将到来的JavaOne彻底掩盖了该事件本身。
But make no mistake, the JVM stepped out of Java’s shadow long ago and leads a life of its own. Just consider all the innovative languages that run on the JVM and triggered improvements in Java (cough, lambda expressions, cough). And don’t overlook how the JVM’s limitations and capabilities keep influencing the language’s evolution. It is impossible not only to gain a deeper understanding of Java when ignoring the JVM, but also to contemplate Java’s future without considering the JVM’s.
但是请不要误会,JVM早已摆脱Java的阴影,过着自己的生活。 只需考虑在JVM上运行并触发Java改进的所有创新语言(咳嗽,lambda表达式,咳嗽)。 并且不要忽略JVM的局限性和功能如何继续影响语言的发展。 在不考虑JVM的情况下,不仅要获得对Java的更深入了解,而且要在不考虑JVM的情况下考虑Java的未来是不可能的。
So to get a feeling for where Java is going it is essential to look at where the JVM is going. And the JVMLS lets us do just that! There were talks about a lot of interesting topics but I want to focus on three.
因此,要了解Java的发展方向,必须先了解JVM的发展方向。 JVMLS让我们做到了! 有很多有趣的话题,但我想集中讨论三个。
Project Jigsaw is Java 9‘s flagship feature and will bring modularity to the language. It will allow developers to create modules and promises reliable configuration and strong encapsulation as well as improved scalability, security, and performance.
Jigsaw项目是Java 9的旗舰功能,它将为该语言带来模块化 。 它将允许开发人员创建模块,并承诺可靠的配置和强大的封装以及改进的可伸缩性,安全性和性能。
In Java 9 we will be able to create modules, where a module is just a JAR containing a new construct – a module descriptor. It describes a module by giving it a name, listing the other modules it requires, and the packages it exports. At runtime, modules can (mostly) only see modules they require (this is called Readability) and can only access types in other modules if they read that module and that module exports the package containing the type (called Accessibility).
在Java 9中,我们将能够创建模块,其中模块只是一个包含新构造的JAR-模块描述符 。 它通过给模块命名来描述模块,列出所需的其他模块以及导出的软件包。 在运行时,模块(大部分)只能(大多数)看到它们需要的模块(这称为Readability ),并且只有在读取其他模块并且该模块导出包含该类型的包的情况下,才能访问其他模块中的类型(称为Accessibility )。
This means that the compiler and JVM finally abandon the big ball of mud, into which they used to roll all our code and our dependencies. Instead we will get a real graph that closely mirrors our perception of how our software is structured. And both the compiler and the JVM will understand that graph! They will note when something is missing, when there are two versions of the same module, when two modules export the same packages, etc. And they will fail at compile or launch time instead of throwing errors at runtime or, worse, misbehaving subtly.
这意味着编译器和JVM最终摒弃了大麻烦,他们过去将我们的所有代码和依赖项都放入了其中。 取而代之的是,我们将得到一个真实的图形,该图形紧密地反映了我们对软件结构的看法。 而且编译器和JVM都将理解该图! 他们会指出何时缺少某些东西,何时有同一模块的两个版本,何时两个模块导出相同的包等。它们将在编译或启动时失败,而不是在运行时抛出错误,或者更糟的是,表现不佳。
To get a deeper insight, see Alex Buckley’s talk “Poject Jigsaw – Under The Hood” or have a look at the Jigsaw resources on my blog, maybe start with this walkthrough to get your hands dirty. Other Jigsaw-related presentations are Claes Redestad’s “JLink-Time Optimization” and, especially interesting for those working with Nashorn, Michael Haupt’s “Nashorn Modularity”
要获得更深入的了解,请参见Alex Buckley的演讲“ Poject Jigsaw – The Hood”或查看我博客上的Jigsaw资源 ,也许从本演练开始,以使您的手变得肮脏。 其他与拼图有关的演示是Claes Redestad的“ JLink-Time Optimization” ,特别是对于那些与Nashorn合作的人来说 ,Michael Haupt的“ Nashorn Modularity”特别有趣。
Project Valhalla aims to introduce value types, which can be summarized as self-defined primitives.
Valhalla项目旨在引入值类型,这些值类型可以概括为自定义基元。
Like primitives, value types incur neither memory overhead nor indirection. A self-defined point with two int fields x and y will be inlined wherever it is used. It will only require the memory needed for those two ints and an array of points will essentially be an array of x/y pairs. Like primitives, such points have no identity – while there can be two different Integer objects with value 5, there can’t be two different ints 5.
像基元一样,值类型既不会导致内存开销也不会导致间接寻址。 无论使用什么位置,都将内联具有两个int字段x和y的自定义point 。 它仅需要这两个int所需的内存,并且点数组本质上将是x / y对数组。 像基元一样,这些点没有身份-虽然可以有两个不同的Integer对象,它们的值均为5,但不能有两个不同的int 5。
Like classes, value types can have methods and fields and implement interfaces. Thus the slogan: “Codes like a class, works like an int.” This will allow us to no longer weigh an abstraction we would prefer against the performance (we imagine) we need.
像类一样,值类型可以具有方法和字段并实现接口。 因此,口号是: “代码就像一个类,就像一个整数一样工作。” 这将使我们不再将所需的抽象与我们需要的性能(我们想象的)权衡。
But the project quickly got sidetracked. As you know, generics do not work for primitives – there can’t be an ArrayList<int>. This is already painful with eight primitives (see the primitive specializations of Stream or libraries like Trove) but becomes unbearable when developers can define more. If value types would have to be boxed to interact with generics (like primitives are today), their use would be fairly limited and they would be a non-starter.
但是该项目很快就被搁置了。 如您所知,泛型不适用于基元–不能存在ArrayList<int> 。 对于八个基元(请参阅Stream或Trove之类的库的基元专业化),这已经很痛苦,但是当开发人员可以定义更多基元时,这变得难以忍受。 如果将值类型装箱才能与泛型进行交互(例如今天的原始类型),则它们的使用将受到相当的限制,并且将是初学者。
So we want to be able to use generics with value types – and primitives can come along for the ride. In the end we not only want to instantiate an ArrayList<int> or ArrayList<point>, we also want it to be backed by an int[] or point[], respectively. This is called specialization and opens a whole new can of worms.
因此,我们希望能够将泛型与值类型一起使用 -并且原语可以伴随而来。 最后,我们不仅要实例化ArrayList<int>或ArrayList<point> ,还希望它们分别由int[]或point[] 。 这被称为专业化,打开了一个全新的蠕虫罐。
To take a good look at those worms, watch Brian Goetz’ talk “Adventures in Parametric Polymorphism”. If you want to go deeper, watch last year’s talk – preferably first – and follow with Maurizio Cimadamore’s “Valhalla Reflection – One Mirror To Rule’em All” and maybe even Remi Forax’ “Valhalla Backport”
为了更好地了解这些蠕虫,请观看Brian Goetz的演讲“参量多态冒险” 。 如果您想更深入一点,请观看去年的演讲 (最好是首先观看),然后观看毛里齐奥·西马达莫尔(Maurizio Cimadamore)的“瓦尔哈拉倒影–统治一切的一面镜子” ,甚至还可以观看雷米·福阿克斯(Remi Forax)的“瓦尔哈拉倒车”
If we’re lucky some or even all of this will end up in Java 10.
如果幸运的话,部分甚至所有这些都将在Java 10中结束。
And then there is John Rose, the gray eminence sitting in the background and pulling the strings. With the all the hot topics taken he talked about the siren calls that lure the VM into its future:
然后是约翰·罗斯(John Rose),坐在地板上的灰色杰出人士拉着琴弦。 在讨论了所有热门话题之后,他谈到了诱使VM进入其未来的警报电话:
a uniform model over objects, values, arrays, methods, etc 对象,值,数组,方法等的统一模型 continued work on performance, for example with regards to memory efficiency by increasing density and sharing, and with continued optimizations of hot paths 继续进行性能方面的工作,例如通过增加密度和共享来提高内存效率,并不断优化热路径 granular concurrency with fibers surpassing threads as the core abstraction 光纤超过线程作为核心抽象的粒度并发 becoming ever more useful, compatible, and interoperable – for languages running on top of it as well as for native ones, thus healing the rift between them 变得越来越有用,兼容和互操作—无论是在其上运行的语言还是本机语言上运行的语言,从而治愈它们之间的裂痕 stack reification, where the stack holds classes and methods as true objects, not just as strings, and where each frame’s full context (locals, monitors, etc) is visible and the stack can be edited by the running program 堆栈化,堆栈将类和方法作为真正的对象而不是字符串保存,并且每个帧的完整上下文(本地,监视器等)都可见,并且堆栈可以由运行的程序进行编辑Honestly, much of what John Rose envisions is way over my head. But it’s great to listen to him anyway, if just to soak up his enthusiasm. You don’t have to take my word for it, just watch “VM Futures” and see for yourself!
老实说,约翰·罗斯(John Rose)设想的很多事情都困扰着我。 但是无论如何还是要听他讲话真是很棒,即使只是为了激发他的热情。 您不必信守我的诺言,只需观看“ VM Futures”并亲自看看!
Much in the spirit of Rose’s outlook is Project Panama, about which Mikel Vidstedt and Tobi Ajila talk in “Going Native”, and to which Ian Graves adds the “Vector API For Java”. Also aimed at healing the rift is Christian Wimmer’s presentation about the “One Compiler”.
罗斯计划的精神是巴拿马计划 ,Mikel Vidstedt和Tobi Ajila在“ Going Native”中谈到了巴拿马计划 ,Ian Graves在其中添加了“ Java Vector API” 。 克里斯蒂安·威默(Christian Wimmer)关于“一个编译器”的介绍也旨在修复裂痕。
The JVM is a powerful beast and a lot of intelligent people are working hard to make it more so while keeping the complexities under control. Are they doing a good job, what do you think?
JVM是一个强大的野兽,许多聪明的人正在努力使它变得更多,同时又要控制复杂性。 他们做得很好,您怎么看?
And if all of that is too far removed from your daily work, be back in a month when we cover JavaOne 2016!
如果所有这些与您的日常工作相去甚远,请在我们介绍JavaOne 2016的一个月后回来!
翻译自: https://www.sitepoint.com/jvmls-2016/
java基础峰会项目
相关资源:jdk-8u281-windows-x64.exe