java-7

What means “javax.net.ssl.SSLHandshakeException: server certificate change is restrictedduring renegotiation” and how to prevent it?

风格不统一 提交于 2019-11-27 20:00:04
问题 We use Oracle jdk 1.7.0_71 and Tomcat 7.0.55. Unfortunately we started to get the following exception during SSL connection between servers: javax.net.ssl.SSLHandshakeException: server certificate change is restrictedduring renegotiation What it means? How to prevent it? The exception is disappeared after the Tomcat restart. The full stack: Caused by: javax.net.ssl.SSLHandshakeException: server certificate change is restrictedduring renegotiation at sun.security.ssl.Alerts.getSSLException

Why is StringBuilder#append(int) faster in Java 7 than in Java 8?

大城市里の小女人 提交于 2019-11-27 19:48:41
问题 While investigating for a little debate w.r.t. using "" + n and Integer.toString(int) to convert an integer primitive to a string I wrote this JMH microbenchmark: @Fork(1) @OutputTimeUnit(TimeUnit.MILLISECONDS) @State(Scope.Benchmark) public class IntStr { protected int counter; @GenerateMicroBenchmark public String integerToString() { return Integer.toString(this.counter++); } @GenerateMicroBenchmark public String stringBuilder0() { return new StringBuilder().append(this.counter++).toString(

Close resource quietly using try-with-resources

跟風遠走 提交于 2019-11-27 19:42:52
Is it possible to ignore the exception thrown when a resource is closed using a try-with-resources statement? Example: class MyResource implements AutoCloseable{ @Override public void close() throws Exception { throw new Exception("Could not close"); } public void read() throws Exception{ } } //this method prints an exception "Could not close" //I want to ignore it public static void test(){ try(MyResource r = new MyResource()){ r.read(); } catch (Exception e) { System.out.println("Exception: " + e.getMessage()); } } Or should I continue to close in a finally instead? public static void test2(

Compiling Java 7 to Java 6

对着背影说爱祢 提交于 2019-11-27 19:42:16
I'm aware that the runtime features of Java 7 are not available with Java 6 but since no new byte code has been added the new byte code invokedynamic is only relevant for non-Java languages, I was wondering how hard it would be to convert Java 7 source code (new switch statement, diamond operator) to pure Java 6 (i.e. to be able to start to convert the source to Java 7 without losing Java 6 compatibility). Any pointers? karmakaze Mark a .class file output by Java 7 javac with version 1.6.0 (i.e. 0x32) printf "\x00\x00\x00\x32" |dd of=Example.class seek=4 bs=1 count=4 conv=notrunc (according to

Java 7 JVM VerifyError in Eclipse

こ雲淡風輕ζ 提交于 2019-11-27 19:00:46
When I compile my project in eclipse indigo using JDK 7, I get the following error dialog with the following stacktrace Exception in thread "main" java.lang.VerifyError: Expecting a stackmap frame at branch target 32 in method ... at offset 0 at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Unknown Source) at java.lang.Class.getMethod0(Unknown Source) at java.lang.Class.getMethod(Unknown Source) at sun.launcher.LauncherHelper.getMainMethod(Unknown Source) at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source) I've found a relevant bug

How to replace com.sun.image.codec.jpeg.JPEGImageEncoder in this code?

时间秒杀一切 提交于 2019-11-27 18:59:48
I have used com.sun.image.codec.jpeg.JPEGImageEncoder to handle JPEG images, like charts and others, in my webapp. Now, I am updating my machine to use JDK7, but this version deprecated this class. Below is the code that I need to change: public void processChart(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("image/jpeg"); out = response.getOutputStream(); response.setHeader("Pragma", "no-cache"); response.setHeader("Cache-Control", "no-cache"); response.setDateHeader("Expires",0); try { int w = Integer.parseInt(request

Closures in Java 7 [duplicate]

╄→尐↘猪︶ㄣ 提交于 2019-11-27 18:46:18
This question already has an answer here: Closure in Java 7 [closed] 7 answers I have heard that closures could be introduced in the next Java standard that is scheduled to be released somewhere around next summer. What would this syntax look like? I read somewhere that introducing closures in java is a bigger change than generic was in java 5. Is this true? pros and cons? (By now we definitely know that closures not will be included in the next Java release) OR edit: http://puredanger.com/tech/2009/11/18/closures-after-all/ :D edit2: Re-thinking JDK7: http://blogs.oracle.com/mr/entry

Java 7 on 32-bit Windows 7 - Java Webstart - Unable to load resource

微笑、不失礼 提交于 2019-11-27 18:44:34
问题 Java 7 on 32-bit Windows 7 - Java Webstart - Unable to load resource I can't launch any java webstart application on a 32-bit Windows 7 system. E.g. ArgoUML - http://argouml-downloads.tigris.org/jws/argouml-latest-stable.jnlp Everything works fine with Java 6, but with Java 7 I get this kind of errors: Unable to load resource: java.io.IOException: Error writing to server or java.net.SocketException: Connection reset Java version: Java Web Start 10.7.2.11 Using JRE version 1.7.0_07-b11 Java

Java 7.1 in IBM Websphere

蓝咒 提交于 2019-11-27 18:31:16
问题 I have Java SDK 6 in IBM websphere 8.5.5.2. Where can i download Java SDK 7.1 in IBM website and update it to websphere. I tried google and couldn't find required information to update Java SDK 7.1. Can i update it from Installation Manager or should i download any files from IBM? 回答1: Download Java SDK 7.1 from WebSphere Application Server V8.5.5 Fix Pack 2. Then unzip both archives 7.1.0.0-WS-IBMWASJAVA-part1.zip and 7.1.0.0-WS-IBMWASJAVA-part2.zip to folder and use Installation Manager to

Objects.hash() vs Objects.hashCode(), clarification needed

帅比萌擦擦* 提交于 2019-11-27 18:28:03
in Java 7 we have o.hashCode(); Objects.hashCode(o); Objects.hash(o); The first 2 are roughly the same with the null point check, but what is last one? When a single object reference is supplied, the returned value does not equal the hash code of that object reference. Why is that? I mean, we don't need 3 methods that do the same thing, I understand that, but why do we need Objects.hash() at all? When would you chose to use one vs another? Tim S. See the documentation for hashCode and hash . hash takes Object... while hashCode takes Object . The example given is: @Override public int hashCode(