java-7

Schema generation with EclipseLink and Hibernate (JPA2.1) - @ForeignKey ignored

一个人想着一个人 提交于 2019-12-19 03:49:54
问题 I am testing JPA2.1 and the new "schema generation" feature. For that, I tested two implementations under the HyperSQL database : EclipseLink 2.5.2-M1 which is the reference implementation. Hibernate 4.3 I don't have any preference for an implementation (not even for performance). I tested EclipseLink because it was the first JPA2.1 implementation available, but now, Hibernate 4.3 is here and JPA2.1 compliant. The only thing I want is to get something independent from the JPA provider -

Why does isAnnotationPresent work differently between Java 7 and Java 8?

 ̄綄美尐妖づ 提交于 2019-12-19 03:12:31
问题 I just discovered this today when one of my unit tests failed because of upgrading from Java 7 to Java 8. The unit test calls a method which tries to find an annotation on a method which is annotated on a child class but with a different return type. In Java 7, isAnnotationPresent seems to only find annotations if they were really declared in code. In Java 8, isAnnotationPresent seems to include annotations that were declared in child classes. To illustrate this I created a simple (??) test

What is the status of Java superpackages?

前提是你 提交于 2019-12-19 02:47:25
问题 In JSR 294 the superpackage feature for Java is specified. It should debut in Java 7, but the JSR is marked as inactive and Java 7 was released half a year ago. Definite information on superpackages are somewhat hard to come by on the net, there are numerous articles on the 'upcoming superpackages', but hardly any on the current state of the feature. So my question is: What is the status of the feature? 回答1: I believe it is now called modules and should be part of Java 8 Java 9 - you can find

Focus problems with JDK7 and native components

自闭症网瘾萝莉.ら 提交于 2019-12-18 16:55:22
问题 We have a swing application which embeds a IE ocx component via JNIWrapper. After switching from jdk6 to jdk7 we start noticing focus problems. When the embedded IE shows a web page with text fields (e.g. the google search page) than the trouble starts: The Browser 'catches' the focus, so u can start typing in the search text field. Every key typed goes to the IE ocx. But swing seems to ignore this focus change. Even if i change the focus to a swing text field (and swing shows the blinking

Type inference more restrictive in JDK 7 than JDK 6?

[亡魂溺海] 提交于 2019-12-18 15:54:41
问题 I think this might be related to Why does a generic cast of a List<? extends Set..> to List<Set..> succeed on Sun JDK 6 but fail to compile on Oracle JDK 7? If we take the following classes, they compile fine under JDK 6: public final class Foo<V> { private final V value; private Foo(final V value) { this.value = value; } public static <T, R extends T> Foo<T> of(final R value) { return new Foo<T>(value); } } final class Tester { @Test(groups="unit") public static void test() { bar(Foo.of

Will compiling for Java 1.5 on Java 1.7 still work?

你说的曾经没有我的故事 提交于 2019-12-18 15:02:32
问题 I've recently moved to Java 7 in one of my projects. I claim that it can run on Java 1.5 simply because there's nothing I depend on that is in Java 6 or 7. However when compiling today I noticed this: bootstrap class path not set in conjunction with -source 1.5 Google has found little information on this warning. Does this mean that you can't compile to Java 1.5 from Java 1.7? 回答1: This Oracle blog explains the warning: http://blogs.oracle.com/darcy/entry/bootclasspath_older_source The reason

Changes in access of variables for generic classes in Java 7

蹲街弑〆低调 提交于 2019-12-18 14:17:43
问题 Here is a simple example of some code that compiles using Java 6, but does not compile in Java 7. public class Test<T extends Test> { private final int _myVar; public Test(int myVar) { _myVar = myVar; } public int get(TestContainer<T> container){ T t = container.get(); return t._myVar; } private static class TestContainer<T extends Test> { private final T _test; private TestContainer(T test) { _test = test; } public T get(){ return _test; } } } In Java 7, it fails to compile in the get

Get file/directory size using Java 7 new IO

淺唱寂寞╮ 提交于 2019-12-18 13:52:19
问题 How can I get the size of a file or directory using the new NIO in java 7? 回答1: Use Files.size(Path) to get the size of a file. For the size of a directory (meaning the size of all files contained in it), you still need to recurse manually, as far as I know. 回答2: Here is a ready to run example that will also skip-and-log directories it can't enter. It uses java.util.concurrent.atomic.AtomicLong to accumulate state. public static void main(String[] args) throws IOException { Path path = Paths

Wildcards in Generics: “? super T” works while “? extends T” does not?

∥☆過路亽.° 提交于 2019-12-18 13:36:49
问题 My question is about generics in Java 7. Suppose we have such class hierarchy: interface Animal {} class Lion implements Animal {} class Butterfly implements Animal {} Just like in Java Generics Tutorial Also we have a class class Cage<T> { private List<T> arr = new ArrayList<>(); public void add(T t) { arr.add(t); } public T get() { return arr.get(0); } } And here is the code which uses that classes: public static void main(String[] args) { Cage<? extends Animal> cage = new Cage<>(); Animal

Null-safe Method invocation Java7

折月煮酒 提交于 2019-12-18 13:13:39
问题 I want to get details about this feature of Java7 like this code public String getPostcode(Person person) { if (person != null) { Address address = person.getAddress(); if (address != null) { return address.getPostcode(); } } return null; } Can be do something like this public String getPostcode(Person person) { return person?.getAddress()?.getPostcode(); } But frankly its not much clear to me.Please explain? 回答1: Null-safe method invocation was proposed for Java 7 as a part of Project Coin,