java-7

Simplified Varargs Method Invocation in Java 7

梦想的初衷 提交于 2019-11-30 06:42:40
In Java 7, you have the option to put a @SafeVarargs annotation to suppress the warning you get when compiling a method with a non-reifiable varargs parameter. Project Coin's proposal stipulates that the annotation should be used when the method ensures that only elements of the same type as the varargs parameter are stored in the varargs array. What would be an example of a non-safe method? For example, foo() is not safe, it may store non-T in the array, causing problem at [2] <T extends List<?>> void foo(T... args) { List<String>[] array2 = (List<String>[])args; array2[0] = a_list_of_string;

JRE 1.7 Vulnerability

痴心易碎 提交于 2019-11-30 05:43:51
问题 Today, our Enterprise Architect mentioned that a recent vulnerability was discovered in the JRE 1.7. I found an article the JRE 1.7 vulnerability recommending disabling Java. I am running JDK 1.5 and 1.6 at work (like many organizations, we're not on the latest of technologies), so no problems there. At home I am doing development with Java SE 7u6. I'm playing with Grails, Spring Security, trying to keep learning. I have already gone and disabled the Java Plug-in in all my browsers on my home

Java 7u4 webstart security exception: Class does not match trust level

社会主义新天地 提交于 2019-11-30 04:48:06
问题 We began to notice that with Java 7 (particularly with update 4), that all our users began to see this with our Webstart app: [14:42:58,422] AWT-EventQueue-0(DEBUG) java.lang.SecurityException: class "CLASSNAME" does not match trust level of other classes in the same package [14:42:58,422] AWT-EventQueue-0(DEBUG) at com.sun.deploy.security.CPCallbackHandler$ChildElement.checkResource(Unknown Source) [14:42:58,422] AWT-EventQueue-0(DEBUG) at com.sun.deploy.security.DeployURLClassPath$JarLoader

Why can't diamond infer types on anonymous inner classes?

雨燕双飞 提交于 2019-11-30 04:47:01
In Java 7 and later, diamond can be used to infer types on normally like so without an issue: List<String> list = new ArrayList<>(); However, it can't for anonymous inner classes like this: List<String> st = new List<>() { //Doesn't compile //Implementation here } Why is this? Logically in this scenario, I can definitely infer the type as String . Is there a logical reason for this decision where the type cannot actually be inferred on anonymous inner classes, or was it omitted for other reasons? In the JSR-334 : Using diamond with anonymous inner classes is not supported since doing so in

Why collection literals?

心不动则不痛 提交于 2019-11-30 04:33:05
From the various online articles on Java 7 I have come to know that Java 7 will be having collection literals 1 like the following: List<String> fruits = [ "Apple", "Mango", "Guava" ]; Set<String> flowers = { "Rose", "Daisy", "Chrysanthemum" }; Map<Integer, String> hindiNums = { 1 : "Ek", 2 : "Do", 3 : "Teen" }; My questions are: Wouldn't it have been possible to provide a static method of in all of the collection classes which could be used as follows: List<String> fruits = ArrayList.of("Apple", "Mango", "Guava"); IMO this looks as good as the literal version and is also reasonably concise.

Intellij IDEA Tomcat Application Server was not connected before run configuration stop, reason: Unable to ping server at localhost:1099

蹲街弑〆低调 提交于 2019-11-30 04:25:41
问题 I am using Intellij Ultimate edition 14.0.2 Working on a Java project using Maven as my build tool. We are getting this error when attempting to launch my project via Tomcat server. Application Server was not connected before run configuration stop, reason: Unable to ping server at localhost:1099 Have attempted, mvn clean install, rebuild the project in intellij, open and shut down intellij. 回答1: Thanks for the feedback everyone. I ended up editing my host file to reference my computer name.

Java 7 breaks SWT app on OS X using Web Start

岁酱吖の 提交于 2019-11-30 03:52:05
问题 We have an application that launches via webstart that uses the SWT library. It's well known that osx requires the swt library to run in the main thread, so we have this in our jnlp: <resources os="Mac"> <j2se version="1.6+" java-vm-args="-XstartOnFirstThread"/> <jar href="swt-mac64.jar"/> </resources> Since we've upgraded to Java 7 (1.7.0_10), it seems that webstart doesn't pass the "-XstartOnFirstThread" to the java process that it starts. I can see from 'ps' that the java process isn't

What's the upcoming Java concurrency library: jsr166y? jsr166z?

一笑奈何 提交于 2019-11-30 03:23:05
问题 I wanted to play around with the upcoming concurrency library which is going to be included in Java 7 according to this website. It seems to be named JSR166 . In most places its reference implementation is referred as jsr166y , while few resources call it jsr166z . I discovered two totally different javadocs for each reference implementation. Docs for jsr166y Docs for jsr166z Now, which implementation is going to be included in Java 7? EDIT While people who answered suggest that jsr166y is

Convert existing generics to diamond syntax

拈花ヽ惹草 提交于 2019-11-30 02:53:35
I rather like the diamond syntax for generics that Java 7 introduces - not so much from a time saving perspective (after all most IDEs fill that bit in for you anyway) but just because it makes the code look a bit cleaner. Because of this and other reasons (mainly the fact I'm developing a new piece of software and some of the new APIs in Java 7 will be useful) I'm most likely going to switch the existing codebase to use / require Java 7. However there's a fair chunk already written pre-diamond syntax, and I'd like to consistently use the diamond syntax throughout. Is there an IDE shortcut (I

Is the grammars in Java7 spec really equivalent?

风流意气都作罢 提交于 2019-11-30 02:06:28
问题 The grammar in chapter 18 of JLS v7 seem to differ from the constructs elsewhere in the documentation, but to me there seem to be differences. Specifically in chapter 15 the rules are: RelationalExpression: ShiftExpression RelationalExpression < ShiftExpression RelationalExpression > ShiftExpression RelationalExpression <= ShiftExpression RelationalExpression >= ShiftExpression RelationalExpression instanceof ReferenceType which makes foo instanceof Bar a RelationalExpression (and therefore