java-9

Strategy in StringConcatFactory

你。 提交于 2021-02-19 03:55:09
问题 I have know the invokedynamic instruction. Also I have known the basic process how it implements. But when I arrive the code. I can't understand the code in StringConcatFactory . Can you tell me how the six strategies implements by the source code. Only the default strategy is also done. As a university student, I can't under the source code. private enum Strategy { /** * Bytecode generator, calling into {@link java.lang.StringBuilder}. */ BC_SB, /** * Bytecode generator, calling into {@link

eclipselink static weaving with final fields on Java 9

不打扰是莪最后的温柔 提交于 2021-02-19 01:56:41
问题 I have some JPA annotated fields declared final like this: @Column(name = "SOME_FIELD", updatable = false, nullable = false) private final String someField; Those fields are stored in the database when the entity is inserted in the database. They cannot further be updated. For the Java programming language, such fields can be considered final. With the EclipseLink static weaving plugin, it's possible to lazy load entities, owing to some byte code instrumentation. I don't know if such

How do Java Module directives impact reflection access into a module?

橙三吉。 提交于 2021-02-18 07:37:05
问题 According to https://www.oracle.com/corporate/features/understanding-java-9-modules.html, the Java Module system introduces the following directives: exports, exports ... to uses provides ... with open, opens, opens ... to What (if any) impact does each directive have on an external module accessing internal members using reflection? For example, does exports <package> allow external modules to access all public , protected , private members of the exported package using reflection? What

Does Java 9 contain built-in JSON?

怎甘沉沦 提交于 2021-02-08 09:43:11
问题 I was wondering if Java 9 has built-in support for JSON. If so how can I import it? I'm writing a socket program so I'm not talking about Java EE and my target to import to is a simple Java SE class. 回答1: There was a proposal to drop the feature by Mark Reinhold, Oracle’s Head of the Java: We may reconsider this [JSON API] JEP for JDK 10 or a later release, especially if new language features such as value types and generics over primitive types (JEP 218) enable a more compact and expressive

Make “gradle javadoc” task work with Java 9

前提是你 提交于 2021-02-07 20:59:55
问题 I have a multi-module Gradle Java project using source/target = 1.9/1.9. There are two modules, my.base and my.dependsOnBase . The my.base module has no other dependencies: module my.base { exports my.base.foo; exports my.base.bar; } The my.dependsOnBase module has only a single dependency, which is my.base : module my.dependsOnBase { requires my.base; exports my.dependsOnBase.baz; } When I run $ gradle javadoc it works fine on my.base . But when it gets to my.dependsOnBase I get the

Make “gradle javadoc” task work with Java 9

血红的双手。 提交于 2021-02-07 20:58:35
问题 I have a multi-module Gradle Java project using source/target = 1.9/1.9. There are two modules, my.base and my.dependsOnBase . The my.base module has no other dependencies: module my.base { exports my.base.foo; exports my.base.bar; } The my.dependsOnBase module has only a single dependency, which is my.base : module my.dependsOnBase { requires my.base; exports my.dependsOnBase.baz; } When I run $ gradle javadoc it works fine on my.base . But when it gets to my.dependsOnBase I get the

Stream.dropWhile() doesn't return correct value in two different values

瘦欲@ 提交于 2021-02-07 18:38:16
问题 I am trying to learn new features in Java-9 I come to know about the dropWhile method of Stream but it is returning different values in two different scenarios. Here is my code package src.module; import java.util.stream.Collectors; import java.util.stream.Stream; import java.util.List; public class Test { public static void main(String[] args) { String s[] = new String[3]; s[0] = "Hello"; s[1] = ""; s[2] = "World"; List<String> value = Stream.of(s).dropWhile(a -> a.isEmpty()).collect

Java 9 automatic module dependencies cannot be resolved / module not found

老子叫甜甜 提交于 2021-02-07 13:47:56
问题 I'm trying to migrate some legacy applications to the new Java 9 module system, to strengthen its encapsulation. I'm starting from the outside-in, with the assumption that classes on the periphery will have the least external dependencies. As you'd expect, I've declared a very open module to start with: module com.example.user { exports com.example.user; } This instantly breaks the entire project (inside all classes), when suddenly every import for an external dependency no longer resolves

Querying swap space in java 9

好久不见. 提交于 2021-02-07 12:54:40
问题 Due to a bug in the sigar library version I am using (returns bogus values for swap), I tried using com.sun.management.OperatingSystemMXBean instead. This worked fine and gave me the desired results (on Windows). Class<?> sunMxBeanClass = Class.forName("com.sun.management.OperatingSystemMXBean"); sunMxBeanInstance = sunMxBeanClass.cast(ManagementFactory.getOperatingSystemMXBean()); getFreeSwapSpaceSize = getMethodWithName(sunMxBeanClass, "getFreeSwapSpaceSize"); getTotalSwapSpaceSize =

Querying swap space in java 9

徘徊边缘 提交于 2021-02-07 12:52:32
问题 Due to a bug in the sigar library version I am using (returns bogus values for swap), I tried using com.sun.management.OperatingSystemMXBean instead. This worked fine and gave me the desired results (on Windows). Class<?> sunMxBeanClass = Class.forName("com.sun.management.OperatingSystemMXBean"); sunMxBeanInstance = sunMxBeanClass.cast(ManagementFactory.getOperatingSystemMXBean()); getFreeSwapSpaceSize = getMethodWithName(sunMxBeanClass, "getFreeSwapSpaceSize"); getTotalSwapSpaceSize =