java-7

What complexity are operations on Java 7's BigInteger?

心已入冬 提交于 2019-11-30 14:11:15
问题 What complexity are the methods multiply , divide and pow in BigInteger currently? There is no mention of the computational complexity in the documentation (nor anywhere else). 回答1: If you look at the code for BigInteger (provided with JDK), it appears to me that multiply(..) has O(n^2) (actually the method is multiplyToLen(..) ). The code for the other methods is a bit more complex, but you can see yourself. Note: this is for Java 6. I assume it won't differ in Java 7. 回答2: There is a new

Java SE strong cryptography for Java 7? [closed]

你。 提交于 2019-11-30 14:04:44
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . The preview release of Java 7 seems to be missing JCE package for unlimited cryptography strength. Has someone stumbled upon such? 回答1: http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html 回答2: You need to install the missing JCE package. Locate your jre lib/security directory $

Invoke private method with java.lang.invoke.MethodHandle

一个人想着一个人 提交于 2019-11-30 13:55:03
How can I invoke private method using method handles ? As far as I can see there are only two kinds of publicly accessible Lookup instances: MethodHandles.lookup() MethodHandles.publicLookup() and neither allows unrestricted private access. There is the non-public Lookup.IMPL_LOOKUP that does what I want. Is there some public way to obtain it (assuming that SecurityManager allows it) ? Turns out it's possible with Lookup#unreflect(Method) and temporarily making method accessible (potentially introducing small security issue unless done during program initialization). Here is modified main

JDK 1.7 Throwable `addSuppressed()` method

北慕城南 提交于 2019-11-30 13:47:29
问题 Well, I get through related questions, I read the source code of JDK 1.7, but I don't find the answer. In this question I want to completely ignore fillInStackTrace . As of JDK 1.4 initCause() method was added. For example, when you use core reflection to invoke the method you receives InvocationTargetException with the cause that have target exception in it. When I saw this feature I started to use it also in a scenario like this try { //contains some code that can throw new IOException(); }

Type inference more restrictive in JDK 7 than JDK 6?

情到浓时终转凉″ 提交于 2019-11-30 13:39:56
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(BigDecimal.ZERO)); // This line fails in JDK 7 but not JDK 6 } private static void bar(final Foo<? extends

How do you configure aspectj maven plugin to use Java 7?

大兔子大兔子 提交于 2019-11-30 13:30:39
What are the appropriate configuration/versions/plugin versions for the aspectj plugin to use Java 7? I am trying to upgrade from Java 6 to Java 7, and the aspectj compiler seems to not be compiling Java 7. I'm specifying the java source and target version as 1.7 in the plugin configuration for aspectj plugin and for the maven compiler plugin. I introduced Java7-specific syntax to my code, adding several language features such as string in switch and the diamond operator. During the build, I get errors from aspectj about the Java7 syntax. The first sign that things are going wrong is: [INFO] -

Simplified Varargs Method Invocation in Java 7

心不动则不痛 提交于 2019-11-30 13:15:29
问题 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? 回答1: For example, foo() is not safe, it may store non-T in the array, causing problem at [2] <T

Java 7 + Rhino 1.7R3 support for CommonJS modules?

為{幸葍}努か 提交于 2019-11-30 12:58:13
问题 I need help getting CommonJS working on Java 7 and Rhino 1.7R3. Rhino 1.7R3 supports CommonJS modules: https://developer.mozilla.org/En/New_in_Rhino_1.7R3 And Java 7 comes bundled with Rhino 1.7R3. Unfortunately, Java 7's Rhino is a modified version, and it does not include the org.mozilla.javascript.commonjs package: http://jdk7.java.net/rhino/README.TXT I would like to use Rhino 1.7R3's support for CommonJS through the javax.script API as follows: ScriptEngineManager mgr = new

No com.sun.tools.javac in JDK7

被刻印的时光 ゝ 提交于 2019-11-30 12:36:32
I'm using JDK7 and Eclipse Indiago in Windows 7 64-bit. I set environment variable JAVA_HOME to F:\JDK7 and add %JAVA_HOME%\bin in path. It's my sample code: com.sun.tools.javac.Main m1 = new com.sun.tools.javac.Main(); m1.compile(source); Error I get: Type com.sun.tools cannot be resolved to a type Why there is no com.sun.tools ? What's the problem ? It looks like you are using Eclipse. By default Eclipse only imports JRE jars, not the ones from the JDK. Solution 1: Go to Eclipse preferences (on Windows: Window-->Preferences) Open the preference Java-->Installed JREs Select your JRE and press

Convert existing generics to diamond syntax

安稳与你 提交于 2019-11-30 12:30:42
问题 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