java-7

Maximum size of a method in Java 7 and 8

断了今生、忘了曾经 提交于 2019-11-26 07:32:42
问题 I know that a method cannot be larger than 64 KB with Java. The limitation causes us problems with generated code from a JavaCC grammar. We had problems with Java 6 and were able to fix this by changing the grammar. Has the limit been changed for Java 7 or is it planned for Java 8? Just to make it clear. I don\'t need a method larger than 64 KB by myself. But I wrote a grammar which compiles to a very large method. 回答1: According to JVMS7 : The fact that end_pc is exclusive is a historical

Am I using the Java 7 try-with-resources correctly

一世执手 提交于 2019-11-26 06:28:11
问题 I am expecting the buffered reader and file reader to close and the resources released if the exception is throw. public static Object[] fromFile(String filePath) throws FileNotFoundException, IOException { try (BufferedReader br = new BufferedReader(new FileReader(filePath))) { return read(br); } } However, is there a requirement to have a catch clause for successful closure? EDIT: Essentially, is the above code in Java 7 equivalent to the below for Java 6: public static Object[] fromFile

Technically what is the main difference between Oracle JDK and OpenJDK? [duplicate]

ぃ、小莉子 提交于 2019-11-26 06:15:48
问题 This question already has answers here : Differences between Oracle JDK and OpenJDK (11 answers) Closed 4 years ago . I have been using OpenJDK for ages, initially for small projects where it has no problems. But since I started to play with it for big toys, I started to notice random/unknown fatal error and crashes (with H.264 codecs, etc.), and it was a nightmare till then to get ride of system crash+fatal errors caused by OpenJDK. After getting completely frustrated and tired with OpenJDK,

Java 7 String - substring complexity

对着背影说爱祢 提交于 2019-11-26 05:36:33
问题 Until Java 6, we had a constant time substring on String . In Java 7, why did they decide to go with copying char array - and degrading to linear time complexity - when something like StringBuilder was exactly meant for that? 回答1: Why they decided is discussed in Oracle bug #4513622 : (str) keeping a substring of a field prevents GC for object: When you call String.substring as in the example, a new character array for storage is not allocated. It uses the character array of the original

Java7 try-with-resources Statement advantage

夙愿已清 提交于 2019-11-26 05:28:09
问题 I was looking the new feature of Java7. I found one is try-with-resources Statement. Can anybody tell me what exactly it means? Why and where we should use it and where we can get advantage of this feature? Even the try statement misses catch block which confusing for me. 回答1: It was introduced because of some resources used in Java (like SQL connections or streams) being difficult to be handled properly; as an example, in java 6 to handle a InputStream properly you had to do something like:

How to enable TLS 1.2 in Java 7

别等时光非礼了梦想. 提交于 2019-11-26 04:48:30
问题 I am trying to enable TLS 1.2 in my web app which uses JBoss 6.4 and Java 1.7. I have -Dhttp.protocols = TLSv1.2 in my application environment but it doesn\'t seem to work for me. Is there anything I could do to enable TLS 1.2? I wrote a simple program context = SSLContext.getInstance(\"TLSv1.2\"); context.init(null,null,null); SSLContext.setDefault(context); SSLSocketFactory factory = (SSLSocketFactory)context.getSocketFactory(); SSLSocket socket = (SSLSocket)factory.createSocket();

“Comparison method violates its general contract!” - TimSort and GridLayout

放肆的年华 提交于 2019-11-26 04:45:11
问题 I made a color palette with a jPanel and a JLabel array in it. At first it worked well, but then i put some other jLabels out of the JPanel and added them some events. Now I keep getting this error: Exception in thread \"AWT-EventQueue-0\" java.lang.IllegalArgumentException: Comparison method violates its general contract! at java.util.TimSort.mergeLo(TimSort.java:747) at java.util.TimSort.mergeAt(TimSort.java:483) at java.util.TimSort.mergeCollapse(TimSort.java:410) at java.util.TimSort.sort

Testng, Emma, Cobertura, coverage and JDK 7 result in ClassFormatError and VerifyError

喜欢而已 提交于 2019-11-26 04:44:52
问题 I have switched to the newest JDK 7 and I am having problems with running testng unit test on byte code that is fiddled by emma coverage tool. None of my test cases are run correctly and for most of them I am receiving such errors. java.lang.ClassFormatError: Illegal local variable table length 10 in method measurement.meter.AbstractSerialPortMeter.<init>(Lmeasurement/meter/SerialPort;)V at measurement.meter.Elc3133aTest.setUp(Elc3133aTest.java:42) I have found an article here JSR 292

How to set specific java version to Maven

旧巷老猫 提交于 2019-11-26 04:39:19
问题 On my machine I have two java versions installed: (1.6 and 1.7 installed manually by me). I need both of them for different projects. But for Maven I need 1.7, now my Maven uses 1,6 java version, how can I set Maven to use 1.7? 回答1: Maven uses the JAVA_HOME parameter to find which Java version it is supposed to run. I see from your comment that you can't change that in the configuration. You can set the JAVA_HOME parameter just before you start maven (and change it back afterwards if need be)

Can&#39;t transparent and undecorated JFrame in JDK7 when enabling nimbus

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-26 04:26:26
问题 Look at this picture : here is the code that transparent\'s the frame: GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = ge.getDefaultScreenDevice(); if (!gd.isWindowTranslucencySupported(TRANSLUCENT)) { System.err.println( \"Translucency is not supported\"); System.exit(0); } JFrame.setDefaultLookAndFeelDecorated(true); this works good but when trying to enable LookAndFeel by adding try { for (javax.swing.UIManager.LookAndFeelInfo info : javax