我们正在迁移旧代码,实际上相当旧的代码到 Java 11。我在编译其中一个类时遇到问题。示例代码是:
package XXXX;
import java.lang.ref.*;
import sun.security.action.*;
import java.security.*;
import java.io.*;
class Converters
{
private static Object lock;
private static String converterPackageName;
private static String defaultEncoding;
public static final int BYTE_TO_CHAR = 0;
public static final int CHAR_TO_BYTE = 1;
private static final String[] converterPrefix;
private static SoftReference[] classCache;
static /* synthetic */ Class class$sun$io$Converters;
private static String getConverterPackageName() {
final String converterPackageName = Converters.converterPackageName;
if (converterPackageName != null) {
return converterPackageName;
}
String converterPackageName2 = AccessController.doPrivileged((PrivilegedAction<String>)new GetPropertyAction("file.encoding.pkg")); …Run Code Online (Sandbox Code Playgroud) 我正在 JDK11 环境中运行 JDK8 应用程序。我正在使用 TLSv1.2 和 TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 密码套件算法,我怀疑它在 JDK11 中不受支持或禁用。有 jvm 支持的密码列表,请参阅https://docs.oracle.com/javase/7/docs/technotes/guides/security/SunProviders.html 另外,如果您在这里看到有人列出了支持的密码jdk 至 jdk1.8 https://developer.ibm.com/answers/questions/301898/where-i-can-find-list-of-cipher-suites-that-suppor/
但我想知道jdk11中支持/启用/禁用哪种密码套件算法。我正在使用 TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 密码算法,但是当我尝试在 jdk 11 运行时环境中运行我的应用程序时,我收到 SSLHandshakeException(Getting javax.net.ssl.SSLHandshakeException in JDK11)。这就是为什么我试图改变我的密码套件算法,并且同样我想知道我可以在 JDK11 环境中使用哪种算法。如果我也了解 jdk11 和 jdk8 都支持的密码,那将会很有帮助。请帮我解决一下。
谢谢。
我必须提交包含正文的http DELETE请求。我知道如何做到这一点,但就我而言,它使用java.net.http.HttpRequest. 不幸的是,该组件仅允许提交BodyPublisherPUT和POST请求。
我的问题是,有什么方法可以用于HttpRequest有问题的DELETE请求吗?
我正在尝试使用 google-client-api 获取 google-calendar 但遇到以下错误:
javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:131)
at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:117)
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:308)
at java.base/sun.security.ssl.Alert$AlertConsumer.consume(Alert.java:285)
at java.base/sun.security.ssl.TransportContext.dispatch(TransportContext.java:181)
at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:164)
at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1152)
at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1063)
at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:402)
at java.base/sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:567)
at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(HttpURLConnection.java:1362)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1337)
at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:246)
at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:113)
at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:84)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1012)
at com.google.api.client.auth.oauth2.TokenRequest.executeUnparsed(TokenRequest.java:322)
at com.google.api.client.auth.oauth2.TokenRequest.execute(TokenRequest.java:346)
at com.google.api.client.googleapis.auth.oauth2.GoogleCredential.executeRefreshToken(GoogleCredential.java:398)
at com.google.api.client.auth.oauth2.Credential.refreshToken(Credential.java:494)
at com.google.api.client.auth.oauth2.Credential.intercept(Credential.java:217)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:880)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:541)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:474)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:591)
at org.springframework.batch.core.listener.CompositeJobExecutionListener.beforeJob(CompositeJobExecutionListener.java:73)
at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:298)
at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:134)
at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50)
at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:127)
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) …Run Code Online (Sandbox Code Playgroud) google-calendar-api ssl-certificate google-client tls1.2 java-11
多个来源展示了如何在 app.yaml entryPoint 命令中设置 JVM 参数(例如 -Xmx):
https://cloud.google.com/appengine/docs/standard/java11/building-app/writing-web-service https://github.com/GoogleCloudPlatform/java-docs-samples/blob/master/appengine-java11 /kotlin-ktor/app.yaml
但是,我没有看到任何有关推荐设置或是否需要良好性能的文档。如果我们不指定内存值,会使用什么设置?内存设置是否会随着机器类型的变化而自动调整?
随着 Oracle 更改 JDK 许可协议,公司开始转向 OpenJDK。
我的问题是 - 哪个 OpenJDK 发行版是更好的选择?我正在评估 Oracle Open JDK 和 AdoptOpenJDK,它们似乎都是一个理想的选择。但是,在支持方面,Oracle OpenJDK 遵循 6 个月的发布节奏,没有任何长期支持,但是 AdoptOpenJDK 具有适用于 Java 版本 8 的 LTS 11. 因此,如果我切换到 Oracle OpenJDK,那么我将必须遵循新的发布节奏,以通过安全补丁更新数据(我不太关心新功能),但是如果我切换到 AdoptOpenJDK,那么我可以选择他们的 LTS 版本 (11) 之一,并期望新的安全补丁将应用于该版本。我主要关心的是,我想在切换到 OpenJDK 发行版后及时了解 Java 安全更新。
参考文献 https://www.reddit.com/r/java/comments/9hd97k/openjdk_vs_adoptopenjdk/
我正在尝试在 java 11 中不存在的文件夹中创建 gc 日志。xxx 文件夹不存在。
C:\>java -Xlog:gc*:file=C:\Users\xxx\gc.log --version
[0.006s][error][logging] Error opening log file 'C:\Users\xxx\gc.log': No such file or directory
[0.006s][error][logging] Initialization of output 'file=C:\Users\xxx\gc.log' using options '(null)' failed.
Invalid -Xlog option '-Xlog:gc*:file=C:\Users\xxx\gc.log', see error log for details.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Run Code Online (Sandbox Code Playgroud)
如何获取gc不存在的文件夹中的日志?如果该文件夹存在,则工作正常。
java -version
openjdk version "11.0.5" 2019-10-15
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.5+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.5+10, mixed mode)
Run Code Online (Sandbox Code Playgroud) 在下面的示例中,我创建了一个 Java 11 httpClient,然后创建了多个并发 HttpRequest。
代码
private static void httpClientExample(){
HttpClient httpClient = HttpClient.newHttpClient();
System.out.println("TP1");
var task1 = httpClient.sendAsync(HttpRequest.newBuilder()
.uri(URI.create("https://www.bing.com/"))
.build(), HttpResponse.BodyHandlers.ofString())
.thenApply(HttpResponse::uri).thenAccept(System.out::println);
var task2 = httpClient.sendAsync(HttpRequest.newBuilder()
.uri(URI.create("https://openjdk.java.net/"))
.build(), HttpResponse.BodyHandlers.ofString())
.thenApply(HttpResponse::uri).thenAccept(System.out::println);
var task3 = httpClient.sendAsync(HttpRequest.newBuilder()
.uri(URI.create("https://www.google.co.uk/"))
.build(), HttpResponse.BodyHandlers.ofString())
.thenApply(HttpResponse::uri).thenAccept(System.out::println);
System.out.println("Requests Sent");
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("Main Thread Completed");
}
Run Code Online (Sandbox Code Playgroud) 我正在下载 java jdk 并在列表https://www.oracle.com/in/java/technologies/javase-downloads.html中它只在 java 11 前面显示 LTS。但据我所知,java 8 是 LTS,我还在维基百科https://en.m.wikipedia.org/wiki/Java_version_history上搜索,它显示 java 8 作为 LTS 版本,它将支持到 2030 年。那么,这是否意味着 java 8 不再是 LTS 版本。
我正在准备 Java 认证考试,我不明白的一件事如下:
class Calculator {
public static long add(int a, long... b) {
System.out.println("int a, Var args long b");
int total = a;
for (long val : b) {
total += val;
}
return total;
}
public static long add(int a, Long b) {
System.out.println("int + Long");
return a + b;
}
}
public class OverloadTests {
public static void main(String[] args) {
var result = Calculator.add(1, 2);
System.out.println("result = " + result);
}
}
Run Code Online (Sandbox Code Playgroud)
Java 文档(https://docs.oracle.com/javase/specs/jls/se11/html/jls-15.html#jls-15.12.2)说: …
java-11 ×10
java ×7
tls1.2 ×2
adoptopenjdk ×1
encryption ×1
httprequest ×1
java-8 ×1
java-9 ×1
methods ×1
openjdk-11 ×1
overloading ×1
rc4-cipher ×1