我已经将java从8更新到9-ea并从2.13更新为3.4.1.以下是gradle --version输出.
------------------------------------------------------------
Gradle 3.4.1
------------------------------------------------------------
Build time: 2017-03-03 19:45:41 UTC
Revision: 9eb76efdd3d034dc506c719dac2955efb5ff9a93
Groovy: 2.4.7
Ant: Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM: 9-ea (Oracle Corporation 9-ea+158)
OS: Linux 4.8.0-36-generic amd64
Run Code Online (Sandbox Code Playgroud)
遇到以下错误时编译:
FAILURE: Build failed with an exception.
* What went wrong:
java.lang.ExceptionInInitializerError (no error message)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Run Code Online (Sandbox Code Playgroud)
输出gradle --stacktrace如下:
java.lang.ExceptionInInitializerError
at org.gradle.initialization.DefaultClassLoaderRegistry.restrictTo(DefaultClassLoaderRegistry.java:40) …Run Code Online (Sandbox Code Playgroud) 通过将--permit-illegal-access标志传递给VM,我使用JRE build 9-ea + 163运行我的应用程序.现在我想用Java Webstart启动应用程序.第一次尝试
javaws -J--permit-illegal-access <JNLP-Url>
Run Code Online (Sandbox Code Playgroud)
不起作用.我得到同样InaccessibleObjectException有module java.base does not "opens java.util" to unnamed module因为没有国旗.
添加<j2se java-vm-args="--permit-illegal-access" version="9*"/>到JNLP没有帮助.
Webstart支持--permit-illegal-access旗帜吗?
我还可以在JNLP文件中指定标志吗?
顺便说一句,Java 9
javaws https://docs.oracle.com/javase/tutorialJWS/samples/deployment/NotepadJWSProject/Notepad.jnlp
Run Code Online (Sandbox Code Playgroud)
投掷IllegalAccessException,-J--permit-illegal-access也没有帮助.
PS:将env变量设置JAVA_TOOL_OPTIONS为--permit-illegal-access有效,但由于无法访问客户端,因此不是解决方案.
在Spring 5.0.0.RC4参考文档中,它说:
Publisher或Flow.Publisher - 支持实现Reactive Streams Publisher的任何类型.
https://docs.spring.io/spring/docs/5.0.0.RC4/spring-framework-reference/reactive-web.html#webflux
但是当我创建一个基于Spring 5.0.0.RC4的简单项目时,我Flow.Publisher在控制器中返回时失败了.似乎Flow.Publisher杰克逊无法将其序列化.
org.springframework.core.codec.CodecException: Type definition error: [simple type, class java.util.concurrent.ForkJoinPool$DefaultForkJoinWorkerThreadFactory]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class java.util.concurrent.ForkJoinPool$DefaultForkJoinWorkerThreadFactory and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: java.util.concurrent.SubmissionPublisher["executor"]->java.util.concurrent.ForkJoinPool["factory"])
at org.springframework.http.codec.json.AbstractJackson2Encoder.encodeValue(AbstractJackson2Encoder.java:132)
at org.springframework.http.codec.json.AbstractJackson2Encoder.lambda$encode$0(AbstractJackson2Encoder.java:96)
at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:107)
at reactor.core.publisher.FluxJust$WeakScalarSubscription.request(FluxJust.java:91)
at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.request(FluxMapFuseable.java:156)
at org.springframework.http.server.reactive.ChannelSendOperator$WriteBarrier.onSubscribe(ChannelSendOperator.java:143)
at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onSubscribe(FluxMapFuseable.java:90)
at reactor.core.publisher.FluxJust.subscribe(FluxJust.java:68)
at reactor.core.publisher.FluxMapFuseable.subscribe(FluxMapFuseable.java:63)
at org.springframework.http.server.reactive.ChannelSendOperator.subscribe(ChannelSendOperator.java:76)
at reactor.core.publisher.MonoOnErrorResume.subscribe(MonoOnErrorResume.java:44)
at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:150)
at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1068)
at reactor.core.publisher.MonoFlatMap$FlatMapInner.onNext(MonoFlatMap.java:241)
at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onNext(FluxOnErrorResume.java:72)
at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.onNext(FluxPeekFuseable.java:198) …Run Code Online (Sandbox Code Playgroud) A week ago, every project I had was working normally, but when I updated my Eclipse to the Oxygen version and installed JDK-9, things have come strange. When I try to use Strings, after some time (more like every time I save the project) the compiler throws me an error for every String in my project.
So I've tried importing java.lang.String to see if it fix the …
注意:这与性能问题无关.我只观察到无法解释/理解的性能差异.
在对一些针对Java 9的新开发的代码进行基准测试时,我发现了一些奇怪的东西.HashMap带有5个密钥的(非常)简单基准测试表明,Java 9比Java 8慢得多.这可以解释一下,还是我的(基准)代码完全错误?
码:
@Fork(
jvmArgsAppend = {"-Xmx512M", "-disablesystemassertions"}
)
public class JsonBenchmark {
@State(Scope.Thread)
public static class Data {
final static Locale RUSSIAN = new Locale("ru");
final static Locale DUTCH = new Locale("nl");
final Map<Locale, String> hashmap = new HashMap<>();
public Data() {
hashmap.put(Locale.ENGLISH, "Flat flashing adjustable for flat angled roof with swivel");
hashmap.put(Locale.FRENCH, "Solin pour toit plat inclinée");
hashmap.put(Locale.GERMAN, "Flachdachkragen Flach Schrägdach");
hashmap.put(DUTCH, "Plakplaat vlak/hellend dak inclusief glijschaal");
hashmap.put(RUSSIAN, "?????? ????? ??????? …Run Code Online (Sandbox Code Playgroud) 我有一个module-info.java看起来像的文件 -
module foo.microservice {
requires spring.core;
requires spring.beans;
requires spring.context;
requires java.sql; // required for Spring Annotation based configuration :(
opens foo.microservice.configuration to spring.core;
opens foo.microservice.internal.services to spring.beans;
opens foo.microservice.internal.controllers to spring.beans;
exports foo.microservice.configuration;
exports foo.microservice.controllers;
exports foo.microservice.models;
exports foo.microservice.services;
}
Run Code Online (Sandbox Code Playgroud)
我希望有可能允许Spring访问所有内部包,而无需将每个包显式添加到module-info.java.
有没有办法让一个更通用的opens语句允许所有我的内部包(和子包)可访问spring.beans?
在IntelliJ 2018.1(构建,执行,部署>编译器> Java编译器)的首选项中,有一个标记为的复选框:
使用'--release'选项进行交叉编译(Java 9及更高版本)
我在网上搜索时找到了相关信息."?" 单击帮助图标时出现404错误.
这个选项的目的/功能是什么?
编辑:我分析了给定的答案.特别是我测试了Till Brychcy的假设,这个假设似乎成立了,但开了更多问题.在以下大分隔符之后,我在问题的最后添加了分析:"-----------分析Till Brychcy的答案----------"
它以某种方式编译并在IJ中运行,但mvn clean install无法编译测试
我有一个带有2个模块的java 9 maven项目:apimod和clientmod.模块clientmod依赖于模块apimod(这些模块都是Maven模块和Java 9模块).
此外,我希望模块clientmod不仅可以重用生产代码apimod,还可以重用测试代码.这是一个常见的模式,我多次使用Java 8.使用Java 9(它与Java 10相同)它也可以正常工作,只要我不声明module-info.java(也就是说,只要我不这样做)运行模块系统).
但是一旦我这样做,启用测试依赖性似乎会禁用生产依赖:( api.Base一src/main类模块apimod)不再可见client.test.DerivedTest(一src/test类模块clientmod).测试不再编译.
这是Maven还是Java 9中的错误?这是最新版本:Java 9.0.4(与Java 10相同),Maven 3.5.3,maven-compiler-plugin 3.7.0
源代码位于:
git clone https://github.com/vandekeiser/wires.git
Run Code Online (Sandbox Code Playgroud)
我对分支中的测试失败问题进行了"二分法":
git checkout MINIMIZE_ISSUE
`mvn clean install`
Run Code Online (Sandbox Code Playgroud)
- > BUILD FAIL(测试中的编译错误clientmod)
我希望模块clientmod不仅可以重用生产代码,apimod还可以重用测试代码.使用Maven,你就像那样(clientmod/pom.xml):
<dependency>
<groupId>fr.cla</groupId>
<artifactId>apimod</artifactId> …Run Code Online (Sandbox Code Playgroud) VarHandle显示以下错误 -
Exception in thread "main" java.lang.NoSuchMethodError: VarHandle.compareAndSet(VarHandleExample,int,int)void
at java.base/java.lang.invoke.MethodHandleNatives.newNoSuchMethodErrorOnVarHandle(MethodHandleNatives.java:492)
at java.base/java.lang.invoke.MethodHandleNatives.varHandleOperationLinkerMethod(MethodHandleNatives.java:445)
at java.base/java.lang.invoke.MethodHandleNatives.linkMethodImpl(MethodHandleNatives.java:378)
at java.base/java.lang.invoke.MethodHandleNatives.linkMethod(MethodHandleNatives.java:366)
at j9.VarHandleExample.update(VarHandleExample.java:23)
at j9.VarHandleExample.main(VarHandleExample.java:14)
Run Code Online (Sandbox Code Playgroud)
我的计划是:
import java.lang.invoke.MethodHandles;
import java.lang.invoke.VarHandle;
public class VarHandleExample {
public int publicTestVariable = 10;
public static void main(String[] args) throws NoSuchFieldException, IllegalAccessException {
VarHandleExample e= new VarHandleExample();
e.update();
}
public void update() throws NoSuchFieldException, IllegalAccessException {
VarHandle publicIntHandle = MethodHandles.lookup()
.in(VariableHandlesTest.class)
.findVarHandle(VarHandleExample.class, "publicTestVariable", int.class);
publicIntHandle.compareAndSet(this, 10, 100); // CAS
}
}
Run Code Online (Sandbox Code Playgroud) 代码(缩短实际代码来解释问题).
import java.util.Map;
import java.util.HashMap;
public class TypeReferenceTest {
public static class Model {
public void setAbc(Abc<String> abc) { }
}
public static class Abc<T> {
public Abc(T val) { }
}
public static void main(String[] args) {
Map<String, Object> attrMap = new HashMap<>();
attrMap.put("key", 0);
Model m = new Model ();
m.setAbc(new Abc<>(getAttrOrDefault(attrMap, "key", "Default")));
System.out.println("Test completed.....");
}
public static <T extends Object> T getAttrOrDefault(Map<String, Object> attrMap, String attrName, T defaultValue) {
@SuppressWarnings("unchecked")
T attrValue = (T)attrMap.get(attrName);
return (attrValue …Run Code Online (Sandbox Code Playgroud) java-9 ×10
java ×8
spring ×2
compilation ×1
eclipse ×1
generics ×1
gradle ×1
java-10 ×1
javac ×1
jmh ×1
jnlp ×1
maven ×1
methodhandle ×1
module-info ×1