Merge
This commit is contained in:
commit
f13c56e8aa
2
.hgtags
2
.hgtags
@ -125,3 +125,5 @@ a2a589fc29543ed32919c78a1810ad93a6fcf5bc jdk7-b147
|
||||
de9223c94f9c710b3eebb599cd3586f36c8b94a9 jdk8-b01
|
||||
1b9d19620eb4606a25b1e28f86d66c8bfa867e06 jdk8-b02
|
||||
6815e85bf96d6d3875954f9777660372cd70d065 jdk8-b03
|
||||
31f5c34d78081572ad9a2401c0bb0c6b9711dd65 jdk8-b04
|
||||
c4f9ea1ecb55ff44e0dd21d2888ead308c86a3aa jdk8-b05
|
||||
|
@ -125,3 +125,5 @@ d91364304d7c4ecd34caffdba2b840aeb0d10b51 jdk7-b147
|
||||
f42e3d9394b40a423d345b8da22687b5462e5f25 jdk8-b01
|
||||
69f592185747226a9c765a9fe139c1d34d616f9c jdk8-b02
|
||||
587bb549dff83131b65f40aa51864f69562f34a7 jdk8-b03
|
||||
0b66a233bfb9ba2ebda1e5cdfdb0373d6c1e3c69 jdk8-b04
|
||||
b910aac18c772b823b1f7da03e2c6528725cc6de jdk8-b05
|
||||
|
@ -125,3 +125,5 @@ a2f340a048c88d10cbedc0504f5cf03d39925a40 jdk7-b142
|
||||
949fb60ca830364571e7c4c9964e6b351ca929ec jdk8-b01
|
||||
ed8d94519a87b4adac270c3eec9134ff1f62bff5 jdk8-b02
|
||||
cd0da00694fbce642db9be936d3e4909a71d911d jdk8-b03
|
||||
60a68d688e24473cf84dedd1e60901a61ab82555 jdk8-b04
|
||||
cc1b599b986a37cb57de4584c5e58169766ca535 jdk8-b05
|
||||
|
@ -177,3 +177,5 @@ c149193c768b8b7233da4c3a3fdc0756b975848e jdk7-b143
|
||||
0cc8a70952c368e06de2adab1f2649a408f5e577 jdk8-b01
|
||||
31e253c1da429124bb87570ab095d9bc89850d0a jdk8-b02
|
||||
3a2fb61165dfc72e398179a2796d740c8da5b8c0 jdk8-b03
|
||||
0fa3ace511fe98fe948e751531f3e2b7c60c8376 jdk8-b04
|
||||
dce7d24674f4d0bed00de24f00119057fdce7cfb jdk8-b05
|
||||
|
@ -125,3 +125,5 @@ fc268cd1dd5d2e903ccd4b0275e1f9c2461ed30c jdk7-b147
|
||||
4f0fcb812767594fe9de509f946b56942db5a2f0 jdk8-b01
|
||||
ca4d6ad55a660f0469882e85b4dacf7822d50abf jdk8-b02
|
||||
7a74371ce0c64108b857c497ae130dfe9514532c jdk8-b03
|
||||
acbcadef0b21582abf406f07f1b74d2b8f80dc01 jdk8-b04
|
||||
ff0a3d78e7a22743eabbaa71e9d17b2f094ddf62 jdk8-b05
|
||||
|
@ -125,3 +125,5 @@ d13b1f877bb5ed8dceb2f7ec10365d1db5f70b2d jdk7-b147
|
||||
64df57a1edeca74388bd62f0a87d056db981fbdf jdk8-b01
|
||||
1034127ed402e9d0f1ed1477238ef594e9cc8da6 jdk8-b02
|
||||
7dcb0307508f408507d878cd7c2048c102b15158 jdk8-b03
|
||||
3f6f08163331ed75b30a6de1246670ce655645c8 jdk8-b04
|
||||
7d5d91fddbceb1fc3ae7ff409e732ae4a0391b34 jdk8-b05
|
||||
|
@ -126,3 +126,4 @@ f097ca2434b1412b12ab4a5c2397ce271bf681e7 jdk7-b147
|
||||
13e70aa1398eb959c54bc68b783ca0eef1286ad2 jdk8-b02
|
||||
7989ee9fe673a87f4db3917fa6a005732a6a9b85 jdk8-b03
|
||||
fc569517f3cf242f90ce3503b743eb5553938946 jdk8-b04
|
||||
0b32369b83d81c226a2e79e730f3a8c0d2595e92 jdk8-b05
|
||||
|
@ -47,7 +47,7 @@ FILES_copy = $(SERVICETAG_RESOURCES_DIR)/product_registration.xsd \
|
||||
# Add all properties files to the FILES_copy list
|
||||
SWORDFISH_properties := $(shell \
|
||||
$(CD) $(SHARE_SRC)/classes/com/sun/servicetag/resources; \
|
||||
$(FIND) . -name 'javase_*_swordfish.properties' -print ; \
|
||||
$(FIND) . -name 'javase_*.properties' -print ; \
|
||||
)
|
||||
FILES_copy += $(shell \
|
||||
for f in $(SWORDFISH_properties) ; do \
|
||||
|
@ -258,6 +258,15 @@ jprt.make.rule.all.test.targets= \
|
||||
windows_i586_5.1-product-c1-jdk_security3, \
|
||||
windows_x64_5.2-product-c2-jdk_security3, \
|
||||
\
|
||||
solaris_sparc_5.10-product-c1-jdk_sound, \
|
||||
solaris_sparcv9_5.10-product-c2-jdk_sound, \
|
||||
solaris_i586_5.10-product-c1-jdk_sound, \
|
||||
solaris_x64_5.10-product-c2-jdk_sound, \
|
||||
linux_i586_2.6-product-{c1|c2}-jdk_sound, \
|
||||
linux_x64_2.6-product-c2-jdk_sound, \
|
||||
windows_i586_5.1-product-c1-jdk_sound, \
|
||||
windows_x64_5.2-product-c2-jdk_sound, \
|
||||
\
|
||||
solaris_sparc_5.10-product-c1-jdk_swing, \
|
||||
solaris_sparcv9_5.10-product-c2-jdk_swing, \
|
||||
solaris_i586_5.10-product-c1-jdk_swing, \
|
||||
|
@ -763,7 +763,7 @@ class JFIFMarkerSegment extends MarkerSegment {
|
||||
}
|
||||
} catch (IllegalThumbException e) {
|
||||
// Should never happen
|
||||
throw new InternalError("Illegal thumb in setThumbnail!");
|
||||
throw new InternalError("Illegal thumb in setThumbnail!", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -186,7 +186,7 @@ public class SnmpCounter64 extends SnmpValue {
|
||||
newclone = (SnmpCounter64) super.clone() ;
|
||||
newclone.value = value ;
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new InternalError() ; // vm bug.
|
||||
throw new InternalError(e) ; // vm bug.
|
||||
}
|
||||
return newclone ;
|
||||
}
|
||||
|
@ -232,7 +232,7 @@ public class SnmpInt extends SnmpValue {
|
||||
newclone = (SnmpInt) super.clone() ;
|
||||
newclone.value = value ;
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new InternalError() ; // vm bug.
|
||||
throw new InternalError(e) ; // vm bug.
|
||||
}
|
||||
return newclone ;
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ public class SnmpNull extends SnmpValue {
|
||||
newclone = (SnmpNull) super.clone() ;
|
||||
newclone.tag = tag ;
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new InternalError() ; // vm bug.
|
||||
throw new InternalError(e) ; // vm bug.
|
||||
}
|
||||
return newclone ;
|
||||
}
|
||||
|
@ -250,7 +250,7 @@ public class SnmpString extends SnmpValue {
|
||||
newclone.value = new byte[value.length] ;
|
||||
System.arraycopy(value, 0, newclone.value, 0, value.length) ;
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new InternalError() ; // vm bug.
|
||||
throw new InternalError(e) ; // vm bug.
|
||||
}
|
||||
return newclone ;
|
||||
}
|
||||
|
@ -921,7 +921,7 @@ class SnmpRequestHandler extends ClientHandler implements SnmpDefinitions {
|
||||
SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag,
|
||||
"newTooBigMessage", "Internal error", x);
|
||||
}
|
||||
throw new InternalError() ;
|
||||
throw new InternalError(x) ;
|
||||
}
|
||||
|
||||
return result ;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -33,6 +33,7 @@ package com.sun.security.auth.module;
|
||||
public class NTSystem {
|
||||
|
||||
private native void getCurrent(boolean debug);
|
||||
private native long getImpersonationToken0();
|
||||
|
||||
private String userName;
|
||||
private String domain;
|
||||
@ -132,10 +133,14 @@ public class NTSystem {
|
||||
*
|
||||
* @return an impersonation token for the current NT user.
|
||||
*/
|
||||
public long getImpersonationToken() {
|
||||
public synchronized long getImpersonationToken() {
|
||||
if (impersonationToken == 0) {
|
||||
impersonationToken = getImpersonationToken0();
|
||||
}
|
||||
return impersonationToken;
|
||||
}
|
||||
|
||||
|
||||
private void loadNative() {
|
||||
System.loadLibrary("jaas_nt");
|
||||
}
|
||||
|
@ -77,9 +77,7 @@ class BrowserSupport {
|
||||
result = (Boolean) isDesktopSupportedMethod.invoke(null);
|
||||
} catch (IllegalAccessException e) {
|
||||
// should never reach here
|
||||
InternalError x =
|
||||
new InternalError("Desktop.getDesktop() method not found");
|
||||
x.initCause(e);
|
||||
throw new InternalError("Desktop.getDesktop() method not found", e);
|
||||
} catch (InvocationTargetException e) {
|
||||
// browser not supported
|
||||
if (Util.isVerbose()) {
|
||||
@ -101,28 +99,10 @@ class BrowserSupport {
|
||||
result = (Boolean) isSupportedMethod.invoke(desktopObj, browseField.get(null));
|
||||
supported = result.booleanValue();
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
// browser not supported
|
||||
if (Util.isVerbose()) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (NoSuchMethodException e) {
|
||||
// browser not supported
|
||||
if (Util.isVerbose()) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (NoSuchFieldException e) {
|
||||
// browser not supported
|
||||
if (Util.isVerbose()) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
// should never reach here
|
||||
InternalError x =
|
||||
new InternalError("Desktop.getDesktop() method not found");
|
||||
x.initCause(e);
|
||||
throw x;
|
||||
} catch (InvocationTargetException e) {
|
||||
throw new InternalError("Desktop.getDesktop() method not found", e);
|
||||
} catch (ReflectiveOperationException e) {
|
||||
// browser not supported
|
||||
if (Util.isVerbose()) {
|
||||
e.printStackTrace();
|
||||
@ -175,10 +155,7 @@ class BrowserSupport {
|
||||
browseMethod.invoke(desktop, uri);
|
||||
} catch (IllegalAccessException e) {
|
||||
// should never reach here
|
||||
InternalError x =
|
||||
new InternalError("Desktop.getDesktop() method not found");
|
||||
x.initCause(e);
|
||||
throw x;
|
||||
throw new InternalError("Desktop.getDesktop() method not found", e);
|
||||
} catch (InvocationTargetException e) {
|
||||
Throwable x = e.getCause();
|
||||
if (x != null) {
|
||||
|
@ -61,8 +61,8 @@ public class Installer {
|
||||
private static RegistrationData registration;
|
||||
private static boolean supportRegistration;
|
||||
private static String registerHtmlParent;
|
||||
private static Set<Locale> supportedLocales = new HashSet<Locale>();
|
||||
private static Properties swordfishProps = null;
|
||||
private static Set<Locale> supportedLocales = new HashSet<>();
|
||||
private static Properties svcTagProps = null;
|
||||
private static String[] jreArchs = null;
|
||||
static {
|
||||
String dir = System.getProperty(SVCTAG_DIR_PATH);
|
||||
@ -94,7 +94,7 @@ public class Installer {
|
||||
boolean cleanup = false;
|
||||
try {
|
||||
// Check if we have the swordfish entries for this JRE version
|
||||
if (loadSwordfishEntries() == null) {
|
||||
if (loadServiceTagProps() == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -144,18 +144,14 @@ public class Installer {
|
||||
return registration;
|
||||
}
|
||||
if (regXmlFile.exists()) {
|
||||
BufferedInputStream in = null;
|
||||
try {
|
||||
in = new BufferedInputStream(new FileInputStream(regXmlFile));
|
||||
try (BufferedInputStream in =
|
||||
new BufferedInputStream(new FileInputStream(regXmlFile)))
|
||||
{
|
||||
registration = RegistrationData.loadFromXML(in);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
System.err.println("Error: Bad registration data \"" +
|
||||
regXmlFile + "\":" + ex.getMessage());
|
||||
throw ex;
|
||||
} finally {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
registration = new RegistrationData();
|
||||
@ -186,18 +182,14 @@ public class Installer {
|
||||
deleteRegistrationHtmlPage();
|
||||
getRegistrationHtmlPage();
|
||||
|
||||
BufferedOutputStream out = null;
|
||||
try {
|
||||
out = new BufferedOutputStream(new FileOutputStream(regXmlFile));
|
||||
try (BufferedOutputStream out =
|
||||
new BufferedOutputStream(new FileOutputStream(regXmlFile)))
|
||||
{
|
||||
getRegistrationData().storeToXML(out);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
System.err.println("Error: Bad registration data \"" +
|
||||
regXmlFile + "\":" + ex.getMessage());
|
||||
throw ex;
|
||||
} finally {
|
||||
if (out != null) {
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -206,11 +198,9 @@ public class Installer {
|
||||
* or empty set if file not exists.
|
||||
*/
|
||||
private static Set<String> getInstalledURNs() throws IOException {
|
||||
Set<String> urnSet = new HashSet<String>();
|
||||
Set<String> urnSet = new HashSet<>();
|
||||
if (serviceTagFile.exists()) {
|
||||
BufferedReader in = null;
|
||||
try {
|
||||
in = new BufferedReader(new FileReader(serviceTagFile));
|
||||
try (BufferedReader in = new BufferedReader(new FileReader(serviceTagFile))) {
|
||||
String urn;
|
||||
while ((urn = in.readLine()) != null) {
|
||||
urn = urn.trim();
|
||||
@ -218,10 +208,6 @@ public class Installer {
|
||||
urnSet.add(urn);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
return urnSet;
|
||||
@ -237,9 +223,9 @@ public class Installer {
|
||||
private static ServiceTag[] getJavaServiceTagArray() throws IOException {
|
||||
RegistrationData regData = getRegistrationData();
|
||||
Set<ServiceTag> svcTags = regData.getServiceTags();
|
||||
Set<ServiceTag> result = new HashSet<ServiceTag>();
|
||||
Set<ServiceTag> result = new HashSet<>();
|
||||
|
||||
Properties props = loadSwordfishEntries();
|
||||
Properties props = loadServiceTagProps();
|
||||
String jdkUrn = props.getProperty("servicetag.jdk.urn");
|
||||
String jreUrn = props.getProperty("servicetag.jre.urn");
|
||||
for (ServiceTag st : svcTags) {
|
||||
@ -343,8 +329,7 @@ public class Installer {
|
||||
}
|
||||
|
||||
private static ServiceTag newServiceTag(String svcTagSource) throws IOException {
|
||||
// Load the swoRDFish information for the service tag creation
|
||||
Properties props = loadSwordfishEntries();
|
||||
Properties props = loadServiceTagProps();
|
||||
|
||||
// Determine the product URN and name
|
||||
String productURN;
|
||||
@ -442,52 +427,35 @@ public class Installer {
|
||||
return;
|
||||
}
|
||||
|
||||
PrintWriter out = null;
|
||||
try {
|
||||
out = new PrintWriter(serviceTagFile);
|
||||
|
||||
try (PrintWriter out = new PrintWriter(serviceTagFile)) {
|
||||
ServiceTag[] javaSvcTags = getJavaServiceTagArray();
|
||||
for (ServiceTag st : javaSvcTags) {
|
||||
// Write the instance_run to the servicetag file
|
||||
String instanceURN = st.getInstanceURN();
|
||||
out.println(instanceURN);
|
||||
}
|
||||
} finally {
|
||||
if (out != null) {
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the values associated with the swoRDFish metadata entries
|
||||
* for Java SE. The swoRDFish metadata entries are different for
|
||||
* different release.
|
||||
* Load the properties for generating Java SE service tags.
|
||||
*
|
||||
* @param version Version of Java SE
|
||||
*/
|
||||
private static synchronized Properties loadSwordfishEntries() throws IOException {
|
||||
if (swordfishProps != null) {
|
||||
return swordfishProps;
|
||||
private static synchronized Properties loadServiceTagProps() throws IOException {
|
||||
if (svcTagProps != null) {
|
||||
return svcTagProps;
|
||||
}
|
||||
|
||||
// The version string for Java SE 6 is 1.6.0
|
||||
// We just need the minor number in the version string
|
||||
int version = Util.getJdkVersion();
|
||||
|
||||
String filename = "/com/sun/servicetag/resources/javase_" +
|
||||
version + "_swordfish.properties";
|
||||
InputStream in = Installer.class.getResourceAsStream(filename);
|
||||
if (in == null) {
|
||||
return null;
|
||||
// For Java SE 8 and later releases, JDK and JRE both use
|
||||
// the same product number. The sworRDFish metadata were
|
||||
// for legacy Sun part number.
|
||||
String filename = "/com/sun/servicetag/resources/javase_servicetag.properties";
|
||||
try (InputStream in = Installer.class.getResourceAsStream(filename)) {
|
||||
svcTagProps = new Properties();
|
||||
svcTagProps.load(in);
|
||||
}
|
||||
swordfishProps = new Properties();
|
||||
try {
|
||||
swordfishProps.load(in);
|
||||
} finally {
|
||||
in.close();
|
||||
}
|
||||
return swordfishProps;
|
||||
return svcTagProps;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -546,7 +514,7 @@ public class Installer {
|
||||
return jreArchs;
|
||||
}
|
||||
|
||||
Set<String> archs = new HashSet<String>();
|
||||
Set<String> archs = new HashSet<>();
|
||||
|
||||
String os = System.getProperty("os.name");
|
||||
if (os.equals("SunOS") || os.equals("Linux")) {
|
||||
@ -681,16 +649,16 @@ public class Installer {
|
||||
String country = locale.getCountry();
|
||||
String variant = locale.getVariant();
|
||||
|
||||
List<Locale> locales = new ArrayList<Locale>(3);
|
||||
List<Locale> locales = new ArrayList<>(3);
|
||||
if (variant.length() > 0) {
|
||||
locales.add(locale);
|
||||
}
|
||||
if (country.length() > 0) {
|
||||
locales.add((locales.size() == 0) ?
|
||||
locales.add((locales.isEmpty()) ?
|
||||
locale : new Locale(language, country, ""));
|
||||
}
|
||||
if (language.length() > 0) {
|
||||
locales.add((locales.size() == 0) ?
|
||||
locales.add((locales.isEmpty()) ?
|
||||
locale : new Locale(language, "", ""));
|
||||
}
|
||||
return locales;
|
||||
@ -788,14 +756,11 @@ public class Installer {
|
||||
// Format the registration data in one single line
|
||||
StringBuilder payload = new StringBuilder();
|
||||
String xml = regData.toString().replaceAll("\"", "%22");
|
||||
BufferedReader reader = new BufferedReader(new StringReader(xml));
|
||||
try {
|
||||
try (BufferedReader reader = new BufferedReader(new StringReader(xml))) {
|
||||
String line = null;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
payload.append(line.trim());
|
||||
}
|
||||
} finally {
|
||||
reader.close();
|
||||
}
|
||||
|
||||
String resourceFilename = "/com/sun/servicetag/resources/register";
|
||||
|
@ -150,9 +150,7 @@ class RegistrationDocument {
|
||||
} catch (ParserConfigurationException pce) {
|
||||
// Parser with specific options can't be built
|
||||
// should not reach here
|
||||
InternalError x = new InternalError("Error in creating the new document");
|
||||
x.initCause(pce);
|
||||
throw x;
|
||||
throw new InternalError("Error in creating the new document", pce);
|
||||
}
|
||||
}
|
||||
|
||||
@ -172,9 +170,7 @@ class RegistrationDocument {
|
||||
} catch (ParserConfigurationException pce) {
|
||||
// Parser with specified options can't be built
|
||||
// should not reach here
|
||||
InternalError x = new InternalError("Error in creating the new document");
|
||||
x.initCause(pce);
|
||||
throw x;
|
||||
throw new InternalError("Error in creating the new document", pce);
|
||||
}
|
||||
}
|
||||
|
||||
@ -195,20 +191,14 @@ class RegistrationDocument {
|
||||
new StreamResult(new BufferedWriter(new OutputStreamWriter(os, "UTF-8"))));
|
||||
} catch (UnsupportedEncodingException ue) {
|
||||
// Should not reach here
|
||||
InternalError x = new InternalError("Error generated during transformation");
|
||||
x.initCause(ue);
|
||||
throw x;
|
||||
throw new InternalError("Error generated during transformation", ue);
|
||||
} catch (TransformerConfigurationException tce) {
|
||||
// Error generated by the parser
|
||||
// Should not reach here
|
||||
InternalError x = new InternalError("Error in creating the new document");
|
||||
x.initCause(tce);
|
||||
throw x;
|
||||
throw new InternalError("Error in creating the new document", tce);
|
||||
} catch (TransformerException te) {
|
||||
// Error generated by the transformer
|
||||
InternalError x = new InternalError("Error generated during transformation");
|
||||
x.initCause(te);
|
||||
throw x;
|
||||
throw new InternalError("Error generated during transformation", te);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,29 @@
|
||||
# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 only, as
|
||||
# published by the Free Software Foundation. Oracle designates this
|
||||
# particular file as subject to the "Classpath" exception as provided
|
||||
# by Oracle in the LICENSE file that accompanied this code.
|
||||
#
|
||||
# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
# version 2 for more details (a copy is included in the LICENSE file that
|
||||
# accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License version
|
||||
# 2 along with this work; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
|
||||
servicetag.jdk.urn = Q8549
|
||||
servicetag.jdk.name = Java Development Kit
|
||||
servicetag.jre.urn = Q8549
|
||||
servicetag.jre.name = Java Runtime Environment
|
||||
servicetag.parent.urn = Q8549
|
||||
servicetag.parent.name = Java Platform, Standard Edition
|
@ -137,7 +137,7 @@ public class BufferCapabilities implements Cloneable {
|
||||
return super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
// Since we implement Cloneable, this should never happen
|
||||
throw new InternalError();
|
||||
throw new InternalError(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3776,11 +3776,10 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
createBufferStrategy(numBuffers, bufferCaps);
|
||||
return; // Success
|
||||
} catch (AWTException e) {
|
||||
// Failed
|
||||
// Code should never reach here (an unaccelerated blitting
|
||||
// strategy should always work)
|
||||
throw new InternalError("Could not create a buffer strategy", e);
|
||||
}
|
||||
// Code should never reach here (an unaccelerated blitting
|
||||
// strategy should always work)
|
||||
throw new InternalError("Could not create a buffer strategy");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -653,7 +653,7 @@ public class GridBagConstraints implements Cloneable, java.io.Serializable {
|
||||
return c;
|
||||
} catch (CloneNotSupportedException e) {
|
||||
// this shouldn't happen, since we are Cloneable
|
||||
throw new InternalError();
|
||||
throw new InternalError(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ public class ImageCapabilities implements Cloneable {
|
||||
return super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
// Since we implement Cloneable, this should never happen
|
||||
throw new InternalError();
|
||||
throw new InternalError(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -177,7 +177,7 @@ public class Insets implements Cloneable, java.io.Serializable {
|
||||
return super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
// this shouldn't happen, since we are Cloneable
|
||||
throw new InternalError();
|
||||
throw new InternalError(e);
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
@ -361,7 +361,7 @@ public final class JobAttributes implements Cloneable {
|
||||
return super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
// Since we implement Cloneable, this should never happen
|
||||
throw new InternalError();
|
||||
throw new InternalError(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -969,7 +969,7 @@ public final class PageAttributes implements Cloneable {
|
||||
return super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
// Since we implement Cloneable, this should never happen
|
||||
throw new InternalError();
|
||||
throw new InternalError(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1276,7 +1276,7 @@ public class RenderingHints
|
||||
}
|
||||
} catch (CloneNotSupportedException e) {
|
||||
// this shouldn't happen, since we are Cloneable
|
||||
throw new InternalError();
|
||||
throw new InternalError(e);
|
||||
}
|
||||
|
||||
return rh;
|
||||
|
@ -753,7 +753,7 @@ public final class TextLayout implements Cloneable {
|
||||
return super.clone();
|
||||
}
|
||||
catch (CloneNotSupportedException e) {
|
||||
throw new InternalError();
|
||||
throw new InternalError(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3856,7 +3856,7 @@ public class AffineTransform implements Cloneable, java.io.Serializable {
|
||||
return super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
// this shouldn't happen, since we are Cloneable
|
||||
throw new InternalError();
|
||||
throw new InternalError(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1569,7 +1569,7 @@ public abstract class CubicCurve2D implements Shape, Cloneable {
|
||||
return super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
// this shouldn't happen, since we are Cloneable
|
||||
throw new InternalError();
|
||||
throw new InternalError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ public abstract class Dimension2D implements Cloneable {
|
||||
return super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
// this shouldn't happen, since we are Cloneable
|
||||
throw new InternalError();
|
||||
throw new InternalError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1122,7 +1122,7 @@ public abstract class Line2D implements Shape, Cloneable {
|
||||
return super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
// this shouldn't happen, since we are Cloneable
|
||||
throw new InternalError();
|
||||
throw new InternalError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -393,7 +393,7 @@ public abstract class Point2D implements Cloneable {
|
||||
return super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
// this shouldn't happen, since we are Cloneable
|
||||
throw new InternalError();
|
||||
throw new InternalError(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1395,7 +1395,7 @@ public abstract class QuadCurve2D implements Shape, Cloneable {
|
||||
return super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
// this shouldn't happen, since we are Cloneable
|
||||
throw new InternalError();
|
||||
throw new InternalError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -391,7 +391,7 @@ public abstract class RectangularShape implements Shape, Cloneable {
|
||||
return super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
// this shouldn't happen, since we are Cloneable
|
||||
throw new InternalError();
|
||||
throw new InternalError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -252,7 +252,7 @@ public class ImageFilter implements ImageConsumer, Cloneable {
|
||||
return super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
// this shouldn't happen, since we are Cloneable
|
||||
throw new InternalError();
|
||||
throw new InternalError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ public class Kernel implements Cloneable {
|
||||
return super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
// this shouldn't happen, since we are Cloneable
|
||||
throw new InternalError();
|
||||
throw new InternalError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -478,7 +478,7 @@ public class ObjectStreamClass implements Serializable {
|
||||
fieldRefl = getReflector(fields, this);
|
||||
} catch (InvalidClassException ex) {
|
||||
// field mismatches impossible when matching local fields vs. self
|
||||
throw new InternalError();
|
||||
throw new InternalError(ex);
|
||||
}
|
||||
|
||||
if (deserializeEx == null) {
|
||||
@ -941,7 +941,7 @@ public class ObjectStreamClass implements Serializable {
|
||||
return cons.newInstance();
|
||||
} catch (IllegalAccessException ex) {
|
||||
// should not occur, as access checks have been suppressed
|
||||
throw new InternalError();
|
||||
throw new InternalError(ex);
|
||||
}
|
||||
} else {
|
||||
throw new UnsupportedOperationException();
|
||||
@ -969,7 +969,7 @@ public class ObjectStreamClass implements Serializable {
|
||||
}
|
||||
} catch (IllegalAccessException ex) {
|
||||
// should not occur, as access checks have been suppressed
|
||||
throw new InternalError();
|
||||
throw new InternalError(ex);
|
||||
}
|
||||
} else {
|
||||
throw new UnsupportedOperationException();
|
||||
@ -1000,7 +1000,7 @@ public class ObjectStreamClass implements Serializable {
|
||||
}
|
||||
} catch (IllegalAccessException ex) {
|
||||
// should not occur, as access checks have been suppressed
|
||||
throw new InternalError();
|
||||
throw new InternalError(ex);
|
||||
}
|
||||
} else {
|
||||
throw new UnsupportedOperationException();
|
||||
@ -1028,7 +1028,7 @@ public class ObjectStreamClass implements Serializable {
|
||||
}
|
||||
} catch (IllegalAccessException ex) {
|
||||
// should not occur, as access checks have been suppressed
|
||||
throw new InternalError();
|
||||
throw new InternalError(ex);
|
||||
}
|
||||
} else {
|
||||
throw new UnsupportedOperationException();
|
||||
@ -1053,11 +1053,11 @@ public class ObjectStreamClass implements Serializable {
|
||||
throw (ObjectStreamException) th;
|
||||
} else {
|
||||
throwMiscException(th);
|
||||
throw new InternalError(); // never reached
|
||||
throw new InternalError(th); // never reached
|
||||
}
|
||||
} catch (IllegalAccessException ex) {
|
||||
// should not occur, as access checks have been suppressed
|
||||
throw new InternalError();
|
||||
throw new InternalError(ex);
|
||||
}
|
||||
} else {
|
||||
throw new UnsupportedOperationException();
|
||||
@ -1082,11 +1082,11 @@ public class ObjectStreamClass implements Serializable {
|
||||
throw (ObjectStreamException) th;
|
||||
} else {
|
||||
throwMiscException(th);
|
||||
throw new InternalError(); // never reached
|
||||
throw new InternalError(th); // never reached
|
||||
}
|
||||
} catch (IllegalAccessException ex) {
|
||||
// should not occur, as access checks have been suppressed
|
||||
throw new InternalError();
|
||||
throw new InternalError(ex);
|
||||
}
|
||||
} else {
|
||||
throw new UnsupportedOperationException();
|
||||
@ -1774,7 +1774,7 @@ public class ObjectStreamClass implements Serializable {
|
||||
}
|
||||
return hash;
|
||||
} catch (IOException ex) {
|
||||
throw new InternalError();
|
||||
throw new InternalError(ex);
|
||||
} catch (NoSuchAlgorithmException ex) {
|
||||
throw new SecurityException(ex.getMessage());
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ class CharacterName {
|
||||
dis.readFully(strPool);
|
||||
refStrPool = new SoftReference<>(strPool);
|
||||
} catch (Exception x) {
|
||||
throw new InternalError(x.getMessage());
|
||||
throw new InternalError(x.getMessage(), x);
|
||||
} finally {
|
||||
try {
|
||||
if (dis != null)
|
||||
|
@ -974,8 +974,7 @@ public final
|
||||
descriptor = (String) enclosingInfo[2];
|
||||
assert((name != null && descriptor != null) || name == descriptor);
|
||||
} catch (ClassCastException cce) {
|
||||
throw (InternalError)
|
||||
new InternalError("Invalid type in enclosing method information").initCause(cce);
|
||||
throw new InternalError("Invalid type in enclosing method information", cce);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1241,8 +1240,7 @@ public final
|
||||
try {
|
||||
return getName().substring(enclosingClass.getName().length());
|
||||
} catch (IndexOutOfBoundsException ex) {
|
||||
throw (InternalError)
|
||||
new InternalError("Malformed class name").initCause(ex);
|
||||
throw new InternalError("Malformed class name", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, asP
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
|
@ -27,7 +27,6 @@ package java.lang.invoke;
|
||||
|
||||
import sun.invoke.empty.Empty;
|
||||
import sun.misc.Unsafe;
|
||||
import static java.lang.invoke.MethodHandleStatics.*;
|
||||
import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
|
||||
|
||||
/**
|
||||
@ -244,8 +243,8 @@ public class CallSite {
|
||||
try {
|
||||
GET_TARGET = IMPL_LOOKUP.
|
||||
findVirtual(CallSite.class, "getTarget", MethodType.methodType(MethodHandle.class));
|
||||
} catch (ReflectiveOperationException ignore) {
|
||||
throw new InternalError();
|
||||
} catch (ReflectiveOperationException e) {
|
||||
throw new InternalError(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ class Invokers {
|
||||
try {
|
||||
invoker = IMPL_LOOKUP.findVirtual(MethodHandle.class, name, targetType);
|
||||
} catch (ReflectiveOperationException ex) {
|
||||
throw new InternalError("JVM cannot find invoker for "+targetType);
|
||||
throw new InternalError("JVM cannot find invoker for "+targetType, ex);
|
||||
}
|
||||
assert(invokerType(targetType) == invoker.type());
|
||||
assert(!invoker.isVarargsCollector());
|
||||
|
@ -382,7 +382,7 @@ import static java.lang.invoke.MethodHandleStatics.*;
|
||||
try {
|
||||
return (MemberName) super.clone();
|
||||
} catch (CloneNotSupportedException ex) {
|
||||
throw new InternalError();
|
||||
throw new InternalError(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -108,9 +108,7 @@ import java.security.PrivilegedAction;
|
||||
return new IllegalArgumentException(message(message, obj, obj2));
|
||||
}
|
||||
/*non-public*/ static Error uncaughtException(Exception ex) {
|
||||
Error err = new InternalError("uncaught exception");
|
||||
err.initCause(ex);
|
||||
return err;
|
||||
throw new InternalError("uncaught exception", ex);
|
||||
}
|
||||
private static String message(String message, Object obj) {
|
||||
if (obj != null) message = message + ": " + obj;
|
||||
|
@ -461,7 +461,7 @@ class MethodTypeForm {
|
||||
// Trigger adapter creation.
|
||||
genericInvoker = InvokeGeneric.generalInvokerOf(erasedType);
|
||||
} catch (Exception ex) {
|
||||
Error err = new InternalError("Exception while resolving inexact invoke");
|
||||
Error err = new InternalError("Exception while resolving inexact invoke", ex);
|
||||
err.initCause(ex);
|
||||
throw err;
|
||||
}
|
||||
|
@ -610,7 +610,7 @@ public class Proxy implements java.io.Serializable {
|
||||
IllegalAccessException |
|
||||
InstantiationException |
|
||||
InvocationTargetException e) {
|
||||
throw new InternalError(e.toString());
|
||||
throw new InternalError(e.toString(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ package java.lang.reflect;
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public interface TypeVariable<D extends GenericDeclaration> extends Type {
|
||||
public interface TypeVariable<D extends GenericDeclaration> extends Type, AnnotatedElement {
|
||||
/**
|
||||
* Returns an array of {@code Type} objects representing the
|
||||
* upper bound(s) of this type variable. Note that if no upper bound is
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -31,6 +31,7 @@ package java.math;
|
||||
|
||||
import java.util.Random;
|
||||
import java.io.*;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* Immutable arbitrary-precision integers. All operations behave as if
|
||||
@ -353,27 +354,17 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
||||
mag = trustedStripLeadingZeroInts(magnitude);
|
||||
}
|
||||
|
||||
// Constructs a new BigInteger using a char array with radix=10
|
||||
BigInteger(char[] val) {
|
||||
/*
|
||||
* Constructs a new BigInteger using a char array with radix=10.
|
||||
* Sign is precalculated outside and not allowed in the val.
|
||||
*/
|
||||
BigInteger(char[] val, int sign, int len) {
|
||||
int cursor = 0, numDigits;
|
||||
int len = val.length;
|
||||
|
||||
// Check for leading minus sign
|
||||
int sign = 1;
|
||||
if (val[0] == '-') {
|
||||
if (len == 1)
|
||||
throw new NumberFormatException("Zero length BigInteger");
|
||||
sign = -1;
|
||||
cursor = 1;
|
||||
} else if (val[0] == '+') {
|
||||
if (len == 1)
|
||||
throw new NumberFormatException("Zero length BigInteger");
|
||||
cursor = 1;
|
||||
}
|
||||
|
||||
// Skip leading zeros and compute number of digits in magnitude
|
||||
while (cursor < len && Character.digit(val[cursor], 10) == 0)
|
||||
while (cursor < len && Character.digit(val[cursor], 10) == 0) {
|
||||
cursor++;
|
||||
}
|
||||
if (cursor == len) {
|
||||
signum = 0;
|
||||
mag = ZERO.mag;
|
||||
@ -382,7 +373,6 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
||||
|
||||
numDigits = len - cursor;
|
||||
signum = sign;
|
||||
|
||||
// Pre-allocate array of expected size
|
||||
int numWords;
|
||||
if (len < 10) {
|
||||
@ -1057,6 +1047,73 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
||||
return new BigInteger(resultMag, cmp == signum ? 1 : -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Package private methods used by BigDecimal code to add a BigInteger
|
||||
* with a long. Assumes val is not equal to INFLATED.
|
||||
*/
|
||||
BigInteger add(long val) {
|
||||
if (val == 0)
|
||||
return this;
|
||||
if (signum == 0)
|
||||
return valueOf(val);
|
||||
if (Long.signum(val) == signum)
|
||||
return new BigInteger(add(mag, Math.abs(val)), signum);
|
||||
int cmp = compareMagnitude(val);
|
||||
if (cmp == 0)
|
||||
return ZERO;
|
||||
int[] resultMag = (cmp > 0 ? subtract(mag, Math.abs(val)) : subtract(Math.abs(val), mag));
|
||||
resultMag = trustedStripLeadingZeroInts(resultMag);
|
||||
return new BigInteger(resultMag, cmp == signum ? 1 : -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the contents of the int array x and long value val. This
|
||||
* method allocates a new int array to hold the answer and returns
|
||||
* a reference to that array. Assumes x.length > 0 and val is
|
||||
* non-negative
|
||||
*/
|
||||
private static int[] add(int[] x, long val) {
|
||||
int[] y;
|
||||
long sum = 0;
|
||||
int xIndex = x.length;
|
||||
int[] result;
|
||||
int highWord = (int)(val >>> 32);
|
||||
if (highWord==0) {
|
||||
result = new int[xIndex];
|
||||
sum = (x[--xIndex] & LONG_MASK) + val;
|
||||
result[xIndex] = (int)sum;
|
||||
} else {
|
||||
if (xIndex == 1) {
|
||||
result = new int[2];
|
||||
sum = val + (x[0] & LONG_MASK);
|
||||
result[1] = (int)sum;
|
||||
result[0] = (int)(sum >>> 32);
|
||||
return result;
|
||||
} else {
|
||||
result = new int[xIndex];
|
||||
sum = (x[--xIndex] & LONG_MASK) + (val & LONG_MASK);
|
||||
result[xIndex] = (int)sum;
|
||||
sum = (x[--xIndex] & LONG_MASK) + (highWord & LONG_MASK) + (sum >>> 32);
|
||||
result[xIndex] = (int)sum;
|
||||
}
|
||||
}
|
||||
// Copy remainder of longer number while carry propagation is required
|
||||
boolean carry = (sum >>> 32 != 0);
|
||||
while (xIndex > 0 && carry)
|
||||
carry = ((result[--xIndex] = x[xIndex] + 1) == 0);
|
||||
// Copy remainder of longer number
|
||||
while (xIndex > 0)
|
||||
result[--xIndex] = x[xIndex];
|
||||
// Grow result if necessary
|
||||
if (carry) {
|
||||
int bigger[] = new int[result.length + 1];
|
||||
System.arraycopy(result, 0, bigger, 1, result.length);
|
||||
bigger[0] = 0x01;
|
||||
return bigger;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the contents of the int arrays x and y. This method allocates
|
||||
* a new int array to hold the answer and returns a reference to that
|
||||
@ -1074,14 +1131,17 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
||||
int yIndex = y.length;
|
||||
int result[] = new int[xIndex];
|
||||
long sum = 0;
|
||||
|
||||
// Add common parts of both numbers
|
||||
while(yIndex > 0) {
|
||||
sum = (x[--xIndex] & LONG_MASK) +
|
||||
(y[--yIndex] & LONG_MASK) + (sum >>> 32);
|
||||
if(yIndex==1) {
|
||||
sum = (x[--xIndex] & LONG_MASK) + (y[0] & LONG_MASK) ;
|
||||
result[xIndex] = (int)sum;
|
||||
} else {
|
||||
// Add common parts of both numbers
|
||||
while(yIndex > 0) {
|
||||
sum = (x[--xIndex] & LONG_MASK) +
|
||||
(y[--yIndex] & LONG_MASK) + (sum >>> 32);
|
||||
result[xIndex] = (int)sum;
|
||||
}
|
||||
}
|
||||
|
||||
// Copy remainder of longer number while carry propagation is required
|
||||
boolean carry = (sum >>> 32 != 0);
|
||||
while (xIndex > 0 && carry)
|
||||
@ -1101,6 +1161,71 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
||||
return result;
|
||||
}
|
||||
|
||||
private static int[] subtract(long val, int[] little) {
|
||||
int highWord = (int)(val >>> 32);
|
||||
if (highWord==0) {
|
||||
int result[] = new int[1];
|
||||
result[0] = (int)(val - (little[0] & LONG_MASK));
|
||||
return result;
|
||||
} else {
|
||||
int result[] = new int[2];
|
||||
if(little.length==1) {
|
||||
long difference = ((int)val & LONG_MASK) - (little[0] & LONG_MASK);
|
||||
result[1] = (int)difference;
|
||||
// Subtract remainder of longer number while borrow propagates
|
||||
boolean borrow = (difference >> 32 != 0);
|
||||
if(borrow) {
|
||||
result[0] = highWord - 1;
|
||||
} else { // Copy remainder of longer number
|
||||
result[0] = highWord;
|
||||
}
|
||||
return result;
|
||||
} else { // little.length==2
|
||||
long difference = ((int)val & LONG_MASK) - (little[1] & LONG_MASK);
|
||||
result[1] = (int)difference;
|
||||
difference = (highWord & LONG_MASK) - (little[0] & LONG_MASK) + (difference >> 32);
|
||||
result[0] = (int)difference;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtracts the contents of the second argument (val) from the
|
||||
* first (big). The first int array (big) must represent a larger number
|
||||
* than the second. This method allocates the space necessary to hold the
|
||||
* answer.
|
||||
* assumes val >= 0
|
||||
*/
|
||||
private static int[] subtract(int[] big, long val) {
|
||||
int highWord = (int)(val >>> 32);
|
||||
int bigIndex = big.length;
|
||||
int result[] = new int[bigIndex];
|
||||
long difference = 0;
|
||||
|
||||
if (highWord==0) {
|
||||
difference = (big[--bigIndex] & LONG_MASK) - val;
|
||||
result[bigIndex] = (int)difference;
|
||||
} else {
|
||||
difference = (big[--bigIndex] & LONG_MASK) - (val & LONG_MASK);
|
||||
result[bigIndex] = (int)difference;
|
||||
difference = (big[--bigIndex] & LONG_MASK) - (highWord & LONG_MASK) + (difference >> 32);
|
||||
result[bigIndex] = (int)difference;
|
||||
}
|
||||
|
||||
|
||||
// Subtract remainder of longer number while borrow propagates
|
||||
boolean borrow = (difference >> 32 != 0);
|
||||
while (bigIndex > 0 && borrow)
|
||||
borrow = ((result[--bigIndex] = big[bigIndex] - 1) == -1);
|
||||
|
||||
// Copy remainder of longer number
|
||||
while (bigIndex > 0)
|
||||
result[--bigIndex] = big[bigIndex];
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a BigInteger whose value is {@code (this - val)}.
|
||||
*
|
||||
@ -1165,11 +1290,39 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
||||
public BigInteger multiply(BigInteger val) {
|
||||
if (val.signum == 0 || signum == 0)
|
||||
return ZERO;
|
||||
|
||||
int resultSign = signum == val.signum ? 1 : -1;
|
||||
if (val.mag.length == 1) {
|
||||
return multiplyByInt(mag,val.mag[0], resultSign);
|
||||
}
|
||||
if(mag.length == 1) {
|
||||
return multiplyByInt(val.mag,mag[0], resultSign);
|
||||
}
|
||||
int[] result = multiplyToLen(mag, mag.length,
|
||||
val.mag, val.mag.length, null);
|
||||
result = trustedStripLeadingZeroInts(result);
|
||||
return new BigInteger(result, signum == val.signum ? 1 : -1);
|
||||
return new BigInteger(result, resultSign);
|
||||
}
|
||||
|
||||
private static BigInteger multiplyByInt(int[] x, int y, int sign) {
|
||||
if(Integer.bitCount(y)==1) {
|
||||
return new BigInteger(shiftLeft(x,Integer.numberOfTrailingZeros(y)), sign);
|
||||
}
|
||||
int xlen = x.length;
|
||||
int[] rmag = new int[xlen + 1];
|
||||
long carry = 0;
|
||||
long yl = y & LONG_MASK;
|
||||
int rstart = rmag.length - 1;
|
||||
for (int i = xlen - 1; i >= 0; i--) {
|
||||
long product = (x[i] & LONG_MASK) * yl + carry;
|
||||
rmag[rstart--] = (int)product;
|
||||
carry = product >>> 32;
|
||||
}
|
||||
if (carry == 0L) {
|
||||
rmag = java.util.Arrays.copyOfRange(rmag, 1, rmag.length);
|
||||
} else {
|
||||
rmag[rstart] = (int)carry;
|
||||
}
|
||||
return new BigInteger(rmag, sign);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1339,8 +1492,8 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
||||
a = new MutableBigInteger(this.mag),
|
||||
b = new MutableBigInteger(val.mag);
|
||||
|
||||
a.divide(b, q);
|
||||
return q.toBigInteger(this.signum == val.signum ? 1 : -1);
|
||||
a.divide(b, q, false);
|
||||
return q.toBigInteger(this.signum * val.signum);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1460,14 +1613,12 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
||||
} else { // Array must be resized
|
||||
if (nBits <= (32-bitsInHighWord)) {
|
||||
int result[] = new int[nInts+len];
|
||||
for (int i=0; i<len; i++)
|
||||
result[i] = a[i];
|
||||
System.arraycopy(a, 0, result, 0, len);
|
||||
primitiveLeftShift(result, result.length, nBits);
|
||||
return result;
|
||||
} else {
|
||||
int result[] = new int[nInts+len+1];
|
||||
for (int i=0; i<len; i++)
|
||||
result[i] = a[i];
|
||||
System.arraycopy(a, 0, result, 0, len);
|
||||
primitiveRightShift(result, result.length, 32 - nBits);
|
||||
return result;
|
||||
}
|
||||
@ -1755,9 +1906,7 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
||||
b = montReduce(b, mod, modLen, inv);
|
||||
|
||||
// Set t to high half of b
|
||||
int[] t = new int[modLen];
|
||||
for(int i=0; i<modLen; i++)
|
||||
t[i] = b[i];
|
||||
int[] t = Arrays.copyOf(b, modLen);
|
||||
|
||||
// Fill in the table with odd powers of the base
|
||||
for (int i=1; i<tblmask; i++) {
|
||||
@ -1854,14 +2003,11 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
||||
|
||||
// Convert result out of Montgomery form and return
|
||||
int[] t2 = new int[2*modLen];
|
||||
for(int i=0; i<modLen; i++)
|
||||
t2[i+modLen] = b[i];
|
||||
System.arraycopy(b, 0, t2, modLen, modLen);
|
||||
|
||||
b = montReduce(t2, mod, modLen, inv);
|
||||
|
||||
t2 = new int[modLen];
|
||||
for(int i=0; i<modLen; i++)
|
||||
t2[i] = b[i];
|
||||
t2 = Arrays.copyOf(b, modLen);
|
||||
|
||||
return new BigInteger(1, t2);
|
||||
}
|
||||
@ -2002,8 +2148,7 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
||||
// Copy remaining ints of mag
|
||||
int numInts = (p + 31) >>> 5;
|
||||
int[] mag = new int[numInts];
|
||||
for (int i=0; i<numInts; i++)
|
||||
mag[i] = this.mag[i + (this.mag.length - numInts)];
|
||||
System.arraycopy(this.mag, (this.mag.length - numInts), mag, 0, numInts);
|
||||
|
||||
// Mask out any excess bits
|
||||
int excessBits = (numInts << 5) - p;
|
||||
@ -2069,7 +2214,12 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
||||
return shiftRight(-n);
|
||||
}
|
||||
}
|
||||
int[] newMag = shiftLeft(mag, n);
|
||||
|
||||
return new BigInteger(newMag, signum);
|
||||
}
|
||||
|
||||
private static int[] shiftLeft(int[] mag, int n) {
|
||||
int nInts = n >>> 5;
|
||||
int nBits = n & 0x1f;
|
||||
int magLen = mag.length;
|
||||
@ -2077,8 +2227,7 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
||||
|
||||
if (nBits == 0) {
|
||||
newMag = new int[magLen + nInts];
|
||||
for (int i=0; i<magLen; i++)
|
||||
newMag[i] = mag[i];
|
||||
System.arraycopy(mag, 0, newMag, 0, magLen);
|
||||
} else {
|
||||
int i = 0;
|
||||
int nBits2 = 32 - nBits;
|
||||
@ -2094,8 +2243,7 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
||||
newMag[i++] = mag[j++] << nBits | mag[j] >>> nBits2;
|
||||
newMag[i] = mag[j] << nBits;
|
||||
}
|
||||
|
||||
return new BigInteger(newMag, signum);
|
||||
return newMag;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2132,9 +2280,7 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
||||
|
||||
if (nBits == 0) {
|
||||
int newMagLen = magLen - nInts;
|
||||
newMag = new int[newMagLen];
|
||||
for (int i=0; i<newMagLen; i++)
|
||||
newMag[i] = mag[i];
|
||||
newMag = Arrays.copyOf(mag, newMagLen);
|
||||
} else {
|
||||
int i = 0;
|
||||
int highBits = mag[0] >>> nBits;
|
||||
@ -2405,7 +2551,7 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
||||
if (signum < 0) {
|
||||
// Check if magnitude is a power of two
|
||||
boolean pow2 = (Integer.bitCount(mag[0]) == 1);
|
||||
for(int i=1; i< len && pow2; i++)
|
||||
for (int i=1; i< len && pow2; i++)
|
||||
pow2 = (mag[i] == 0);
|
||||
|
||||
n = (pow2 ? magBitLength -1 : magBitLength);
|
||||
@ -2529,6 +2675,49 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Version of compareMagnitude that compares magnitude with long value.
|
||||
* val can't be Long.MIN_VALUE.
|
||||
*/
|
||||
final int compareMagnitude(long val) {
|
||||
assert val != Long.MIN_VALUE;
|
||||
int[] m1 = mag;
|
||||
int len = m1.length;
|
||||
if(len > 2) {
|
||||
return 1;
|
||||
}
|
||||
if (val < 0) {
|
||||
val = -val;
|
||||
}
|
||||
int highWord = (int)(val >>> 32);
|
||||
if (highWord==0) {
|
||||
if (len < 1)
|
||||
return -1;
|
||||
if (len > 1)
|
||||
return 1;
|
||||
int a = m1[0];
|
||||
int b = (int)val;
|
||||
if (a != b) {
|
||||
return ((a & LONG_MASK) < (b & LONG_MASK))? -1 : 1;
|
||||
}
|
||||
return 0;
|
||||
} else {
|
||||
if (len < 2)
|
||||
return -1;
|
||||
int a = m1[0];
|
||||
int b = highWord;
|
||||
if (a != b) {
|
||||
return ((a & LONG_MASK) < (b & LONG_MASK))? -1 : 1;
|
||||
}
|
||||
a = m1[1];
|
||||
b = (int)val;
|
||||
if (a != b) {
|
||||
return ((a & LONG_MASK) < (b & LONG_MASK))? -1 : 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares this BigInteger with the specified Object for equality.
|
||||
*
|
||||
@ -3114,25 +3303,35 @@ public class BigInteger extends Number implements Comparable<BigInteger> {
|
||||
}
|
||||
|
||||
// Commit final fields via Unsafe
|
||||
unsafe.putIntVolatile(this, signumOffset, sign);
|
||||
UnsafeHolder.putSign(this, sign);
|
||||
|
||||
// Calculate mag field from magnitude and discard magnitude
|
||||
unsafe.putObjectVolatile(this, magOffset,
|
||||
stripLeadingZeroBytes(magnitude));
|
||||
UnsafeHolder.putMag(this, stripLeadingZeroBytes(magnitude));
|
||||
}
|
||||
|
||||
// Support for resetting final fields while deserializing
|
||||
private static final sun.misc.Unsafe unsafe = sun.misc.Unsafe.getUnsafe();
|
||||
private static final long signumOffset;
|
||||
private static final long magOffset;
|
||||
static {
|
||||
try {
|
||||
signumOffset = unsafe.objectFieldOffset
|
||||
(BigInteger.class.getDeclaredField("signum"));
|
||||
magOffset = unsafe.objectFieldOffset
|
||||
(BigInteger.class.getDeclaredField("mag"));
|
||||
} catch (Exception ex) {
|
||||
throw new Error(ex);
|
||||
private static class UnsafeHolder {
|
||||
private static final sun.misc.Unsafe unsafe;
|
||||
private static final long signumOffset;
|
||||
private static final long magOffset;
|
||||
static {
|
||||
try {
|
||||
unsafe = sun.misc.Unsafe.getUnsafe();
|
||||
signumOffset = unsafe.objectFieldOffset
|
||||
(BigInteger.class.getDeclaredField("signum"));
|
||||
magOffset = unsafe.objectFieldOffset
|
||||
(BigInteger.class.getDeclaredField("mag"));
|
||||
} catch (Exception ex) {
|
||||
throw new ExceptionInInitializerError(ex);
|
||||
}
|
||||
}
|
||||
|
||||
static void putSign(BigInteger bi, int sign) {
|
||||
unsafe.putIntVolatile(bi, signumOffset, sign);
|
||||
}
|
||||
|
||||
static void putMag(BigInteger bi, int[] magnitude) {
|
||||
unsafe.putObjectVolatile(bi, magOffset, magnitude);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -160,7 +160,7 @@ class MutableBigInteger {
|
||||
*/
|
||||
BigDecimal toBigDecimal(int sign, int scale) {
|
||||
if (intLen == 0 || sign == 0)
|
||||
return BigDecimal.valueOf(0, scale);
|
||||
return BigDecimal.zeroValueOf(scale);
|
||||
int[] mag = getMagnitudeArray();
|
||||
int len = mag.length;
|
||||
int d = mag[0];
|
||||
@ -171,7 +171,28 @@ class MutableBigInteger {
|
||||
long v = (len == 2) ?
|
||||
((mag[1] & LONG_MASK) | (d & LONG_MASK) << 32) :
|
||||
d & LONG_MASK;
|
||||
return new BigDecimal(null, sign == -1 ? -v : v, scale, 0);
|
||||
return BigDecimal.valueOf(sign == -1 ? -v : v, scale);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is for internal use in converting from a MutableBigInteger
|
||||
* object into a long value given a specified sign.
|
||||
* returns INFLATED if value is not fit into long
|
||||
*/
|
||||
long toCompactValue(int sign) {
|
||||
if (intLen == 0 || sign == 0)
|
||||
return 0L;
|
||||
int[] mag = getMagnitudeArray();
|
||||
int len = mag.length;
|
||||
int d = mag[0];
|
||||
// If this MutableBigInteger can not be fitted into long, we need to
|
||||
// make a BigInteger object for the resultant BigDecimal object.
|
||||
if (len > 2 || (d < 0 && len == 2))
|
||||
return INFLATED;
|
||||
long v = (len == 2) ?
|
||||
((mag[1] & LONG_MASK) | (d & LONG_MASK) << 32) :
|
||||
d & LONG_MASK;
|
||||
return sign == -1 ? -v : v;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -543,6 +564,24 @@ class MutableBigInteger {
|
||||
return (int)carry;
|
||||
}
|
||||
|
||||
/**
|
||||
* The method is the same as mulsun, except the fact that q array is not
|
||||
* updated, the only result of the method is borrow flag.
|
||||
*/
|
||||
private int mulsubBorrow(int[] q, int[] a, int x, int len, int offset) {
|
||||
long xLong = x & LONG_MASK;
|
||||
long carry = 0;
|
||||
offset += len;
|
||||
for (int j=len-1; j >= 0; j--) {
|
||||
long product = (a[j] & LONG_MASK) * xLong + carry;
|
||||
long difference = q[offset--] - product;
|
||||
carry = (product >>> 32)
|
||||
+ (((difference & LONG_MASK) >
|
||||
(((~(int)product) & LONG_MASK))) ? 1:0);
|
||||
}
|
||||
return (int)carry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Right shift this MutableBigInteger n bits, where n is
|
||||
* less than 32.
|
||||
@ -842,20 +881,20 @@ class MutableBigInteger {
|
||||
rem = (int) (remLong - (quotient.value[0] * divisorLong));
|
||||
remLong = rem & LONG_MASK;
|
||||
}
|
||||
|
||||
int xlen = intLen;
|
||||
int[] qWord = new int[2];
|
||||
while (--xlen > 0) {
|
||||
long dividendEstimate = (remLong<<32) |
|
||||
(value[offset + intLen - xlen] & LONG_MASK);
|
||||
long dividendEstimate = (remLong << 32) |
|
||||
(value[offset + intLen - xlen] & LONG_MASK);
|
||||
int q;
|
||||
if (dividendEstimate >= 0) {
|
||||
qWord[0] = (int) (dividendEstimate / divisorLong);
|
||||
qWord[1] = (int) (dividendEstimate - qWord[0] * divisorLong);
|
||||
q = (int) (dividendEstimate / divisorLong);
|
||||
rem = (int) (dividendEstimate - q * divisorLong);
|
||||
} else {
|
||||
divWord(qWord, dividendEstimate, divisor);
|
||||
long tmp = divWord(dividendEstimate, divisor);
|
||||
q = (int) (tmp & LONG_MASK);
|
||||
rem = (int) (tmp >>> 32);
|
||||
}
|
||||
quotient.value[intLen - xlen] = qWord[0];
|
||||
rem = qWord[1];
|
||||
quotient.value[intLen - xlen] = q;
|
||||
remLong = rem & LONG_MASK;
|
||||
}
|
||||
|
||||
@ -879,40 +918,45 @@ class MutableBigInteger {
|
||||
*
|
||||
*/
|
||||
MutableBigInteger divide(MutableBigInteger b, MutableBigInteger quotient) {
|
||||
return divide(b,quotient,true);
|
||||
}
|
||||
|
||||
MutableBigInteger divide(MutableBigInteger b, MutableBigInteger quotient, boolean needReminder) {
|
||||
if (b.intLen == 0)
|
||||
throw new ArithmeticException("BigInteger divide by zero");
|
||||
|
||||
// Dividend is zero
|
||||
if (intLen == 0) {
|
||||
quotient.intLen = quotient.offset;
|
||||
return new MutableBigInteger();
|
||||
return needReminder ? new MutableBigInteger() : null;
|
||||
}
|
||||
|
||||
int cmp = compare(b);
|
||||
// Dividend less than divisor
|
||||
if (cmp < 0) {
|
||||
quotient.intLen = quotient.offset = 0;
|
||||
return new MutableBigInteger(this);
|
||||
return needReminder ? new MutableBigInteger(this) : null;
|
||||
}
|
||||
// Dividend equal to divisor
|
||||
if (cmp == 0) {
|
||||
quotient.value[0] = quotient.intLen = 1;
|
||||
quotient.offset = 0;
|
||||
return new MutableBigInteger();
|
||||
return needReminder ? new MutableBigInteger() : null;
|
||||
}
|
||||
|
||||
quotient.clear();
|
||||
// Special case one word divisor
|
||||
if (b.intLen == 1) {
|
||||
int r = divideOneWord(b.value[b.offset], quotient);
|
||||
if (r == 0)
|
||||
return new MutableBigInteger();
|
||||
return new MutableBigInteger(r);
|
||||
if(needReminder) {
|
||||
if (r == 0)
|
||||
return new MutableBigInteger();
|
||||
return new MutableBigInteger(r);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Copy divisor value to protect divisor
|
||||
int[] div = Arrays.copyOfRange(b.value, b.offset, b.offset + b.intLen);
|
||||
return divideMagnitude(div, quotient);
|
||||
return divideMagnitude(b, quotient, needReminder);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -940,30 +984,72 @@ class MutableBigInteger {
|
||||
if (d == 0)
|
||||
return divideOneWord((int)v, quotient) & LONG_MASK;
|
||||
else {
|
||||
int[] div = new int[]{ d, (int)(v & LONG_MASK) };
|
||||
return divideMagnitude(div, quotient).toLong();
|
||||
return divideLongMagnitude(v, quotient).toLong();
|
||||
}
|
||||
}
|
||||
|
||||
private static void copyAndShift(int[] src, int srcFrom, int srcLen, int[] dst, int dstFrom, int shift) {
|
||||
int n2 = 32 - shift;
|
||||
int c=src[srcFrom];
|
||||
for (int i=0; i < srcLen-1; i++) {
|
||||
int b = c;
|
||||
c = src[++srcFrom];
|
||||
dst[dstFrom+i] = (b << shift) | (c >>> n2);
|
||||
}
|
||||
dst[dstFrom+srcLen-1] = c << shift;
|
||||
}
|
||||
|
||||
/**
|
||||
* Divide this MutableBigInteger by the divisor represented by its magnitude
|
||||
* array. The quotient will be placed into the provided quotient object &
|
||||
* Divide this MutableBigInteger by the divisor.
|
||||
* The quotient will be placed into the provided quotient object &
|
||||
* the remainder object is returned.
|
||||
*/
|
||||
private MutableBigInteger divideMagnitude(int[] divisor,
|
||||
MutableBigInteger quotient) {
|
||||
|
||||
// Remainder starts as dividend with space for a leading zero
|
||||
MutableBigInteger rem = new MutableBigInteger(new int[intLen + 1]);
|
||||
System.arraycopy(value, offset, rem.value, 1, intLen);
|
||||
rem.intLen = intLen;
|
||||
rem.offset = 1;
|
||||
private MutableBigInteger divideMagnitude(MutableBigInteger div,
|
||||
MutableBigInteger quotient,
|
||||
boolean needReminder ) {
|
||||
// assert div.intLen > 1
|
||||
// D1 normalize the divisor
|
||||
int shift = Integer.numberOfLeadingZeros(div.value[div.offset]);
|
||||
// Copy divisor value to protect divisor
|
||||
final int dlen = div.intLen;
|
||||
int[] divisor;
|
||||
MutableBigInteger rem; // Remainder starts as dividend with space for a leading zero
|
||||
if (shift > 0) {
|
||||
divisor = new int[dlen];
|
||||
copyAndShift(div.value,div.offset,dlen,divisor,0,shift);
|
||||
if(Integer.numberOfLeadingZeros(value[offset])>=shift) {
|
||||
int[] remarr = new int[intLen + 1];
|
||||
rem = new MutableBigInteger(remarr);
|
||||
rem.intLen = intLen;
|
||||
rem.offset = 1;
|
||||
copyAndShift(value,offset,intLen,remarr,1,shift);
|
||||
} else {
|
||||
int[] remarr = new int[intLen + 2];
|
||||
rem = new MutableBigInteger(remarr);
|
||||
rem.intLen = intLen+1;
|
||||
rem.offset = 1;
|
||||
int rFrom = offset;
|
||||
int c=0;
|
||||
int n2 = 32 - shift;
|
||||
for (int i=1; i < intLen+1; i++,rFrom++) {
|
||||
int b = c;
|
||||
c = value[rFrom];
|
||||
remarr[i] = (b << shift) | (c >>> n2);
|
||||
}
|
||||
remarr[intLen+1] = c << shift;
|
||||
}
|
||||
} else {
|
||||
divisor = Arrays.copyOfRange(div.value, div.offset, div.offset + div.intLen);
|
||||
rem = new MutableBigInteger(new int[intLen + 1]);
|
||||
System.arraycopy(value, offset, rem.value, 1, intLen);
|
||||
rem.intLen = intLen;
|
||||
rem.offset = 1;
|
||||
}
|
||||
|
||||
int nlen = rem.intLen;
|
||||
|
||||
// Set the quotient size
|
||||
int dlen = divisor.length;
|
||||
int limit = nlen - dlen + 1;
|
||||
final int limit = nlen - dlen + 1;
|
||||
if (quotient.value.length < limit) {
|
||||
quotient.value = new int[limit];
|
||||
quotient.offset = 0;
|
||||
@ -971,14 +1057,6 @@ class MutableBigInteger {
|
||||
quotient.intLen = limit;
|
||||
int[] q = quotient.value;
|
||||
|
||||
// D1 normalize the divisor
|
||||
int shift = Integer.numberOfLeadingZeros(divisor[0]);
|
||||
if (shift > 0) {
|
||||
// First shift will not grow array
|
||||
BigInteger.primitiveLeftShift(divisor, dlen, shift);
|
||||
// But this one might
|
||||
rem.leftShift(shift);
|
||||
}
|
||||
|
||||
// Must insert leading 0 in rem if its length did not change
|
||||
if (rem.intLen == nlen) {
|
||||
@ -990,10 +1068,9 @@ class MutableBigInteger {
|
||||
int dh = divisor[0];
|
||||
long dhLong = dh & LONG_MASK;
|
||||
int dl = divisor[1];
|
||||
int[] qWord = new int[2];
|
||||
|
||||
// D2 Initialize j
|
||||
for(int j=0; j<limit; j++) {
|
||||
for(int j=0; j<limit-1; j++) {
|
||||
// D3 Calculate qhat
|
||||
// estimate qhat
|
||||
int qhat = 0;
|
||||
@ -1013,9 +1090,9 @@ class MutableBigInteger {
|
||||
qhat = (int) (nChunk / dhLong);
|
||||
qrem = (int) (nChunk - (qhat * dhLong));
|
||||
} else {
|
||||
divWord(qWord, nChunk, dh);
|
||||
qhat = qWord[0];
|
||||
qrem = qWord[1];
|
||||
long tmp = divWord(nChunk, dh);
|
||||
qhat = (int) (tmp & LONG_MASK);
|
||||
qrem = (int) (tmp >>> 32);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1053,6 +1130,181 @@ class MutableBigInteger {
|
||||
// Store the quotient digit
|
||||
q[j] = qhat;
|
||||
} // D7 loop on j
|
||||
// D3 Calculate qhat
|
||||
// estimate qhat
|
||||
int qhat = 0;
|
||||
int qrem = 0;
|
||||
boolean skipCorrection = false;
|
||||
int nh = rem.value[limit - 1 + rem.offset];
|
||||
int nh2 = nh + 0x80000000;
|
||||
int nm = rem.value[limit + rem.offset];
|
||||
|
||||
if (nh == dh) {
|
||||
qhat = ~0;
|
||||
qrem = nh + nm;
|
||||
skipCorrection = qrem + 0x80000000 < nh2;
|
||||
} else {
|
||||
long nChunk = (((long) nh) << 32) | (nm & LONG_MASK);
|
||||
if (nChunk >= 0) {
|
||||
qhat = (int) (nChunk / dhLong);
|
||||
qrem = (int) (nChunk - (qhat * dhLong));
|
||||
} else {
|
||||
long tmp = divWord(nChunk, dh);
|
||||
qhat = (int) (tmp & LONG_MASK);
|
||||
qrem = (int) (tmp >>> 32);
|
||||
}
|
||||
}
|
||||
if (qhat != 0) {
|
||||
if (!skipCorrection) { // Correct qhat
|
||||
long nl = rem.value[limit + 1 + rem.offset] & LONG_MASK;
|
||||
long rs = ((qrem & LONG_MASK) << 32) | nl;
|
||||
long estProduct = (dl & LONG_MASK) * (qhat & LONG_MASK);
|
||||
|
||||
if (unsignedLongCompare(estProduct, rs)) {
|
||||
qhat--;
|
||||
qrem = (int) ((qrem & LONG_MASK) + dhLong);
|
||||
if ((qrem & LONG_MASK) >= dhLong) {
|
||||
estProduct -= (dl & LONG_MASK);
|
||||
rs = ((qrem & LONG_MASK) << 32) | nl;
|
||||
if (unsignedLongCompare(estProduct, rs))
|
||||
qhat--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// D4 Multiply and subtract
|
||||
int borrow;
|
||||
rem.value[limit - 1 + rem.offset] = 0;
|
||||
if(needReminder)
|
||||
borrow = mulsub(rem.value, divisor, qhat, dlen, limit - 1 + rem.offset);
|
||||
else
|
||||
borrow = mulsubBorrow(rem.value, divisor, qhat, dlen, limit - 1 + rem.offset);
|
||||
|
||||
// D5 Test remainder
|
||||
if (borrow + 0x80000000 > nh2) {
|
||||
// D6 Add back
|
||||
if(needReminder)
|
||||
divadd(divisor, rem.value, limit - 1 + 1 + rem.offset);
|
||||
qhat--;
|
||||
}
|
||||
|
||||
// Store the quotient digit
|
||||
q[(limit - 1)] = qhat;
|
||||
}
|
||||
|
||||
|
||||
if(needReminder) {
|
||||
// D8 Unnormalize
|
||||
if (shift > 0)
|
||||
rem.rightShift(shift);
|
||||
rem.normalize();
|
||||
}
|
||||
quotient.normalize();
|
||||
return needReminder ? rem : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Divide this MutableBigInteger by the divisor represented by positive long
|
||||
* value. The quotient will be placed into the provided quotient object &
|
||||
* the remainder object is returned.
|
||||
*/
|
||||
private MutableBigInteger divideLongMagnitude(long ldivisor, MutableBigInteger quotient) {
|
||||
// Remainder starts as dividend with space for a leading zero
|
||||
MutableBigInteger rem = new MutableBigInteger(new int[intLen + 1]);
|
||||
System.arraycopy(value, offset, rem.value, 1, intLen);
|
||||
rem.intLen = intLen;
|
||||
rem.offset = 1;
|
||||
|
||||
int nlen = rem.intLen;
|
||||
|
||||
int limit = nlen - 2 + 1;
|
||||
if (quotient.value.length < limit) {
|
||||
quotient.value = new int[limit];
|
||||
quotient.offset = 0;
|
||||
}
|
||||
quotient.intLen = limit;
|
||||
int[] q = quotient.value;
|
||||
|
||||
// D1 normalize the divisor
|
||||
int shift = Long.numberOfLeadingZeros(ldivisor);
|
||||
if (shift > 0) {
|
||||
ldivisor<<=shift;
|
||||
rem.leftShift(shift);
|
||||
}
|
||||
|
||||
// Must insert leading 0 in rem if its length did not change
|
||||
if (rem.intLen == nlen) {
|
||||
rem.offset = 0;
|
||||
rem.value[0] = 0;
|
||||
rem.intLen++;
|
||||
}
|
||||
|
||||
int dh = (int)(ldivisor >>> 32);
|
||||
long dhLong = dh & LONG_MASK;
|
||||
int dl = (int)(ldivisor & LONG_MASK);
|
||||
|
||||
// D2 Initialize j
|
||||
for (int j = 0; j < limit; j++) {
|
||||
// D3 Calculate qhat
|
||||
// estimate qhat
|
||||
int qhat = 0;
|
||||
int qrem = 0;
|
||||
boolean skipCorrection = false;
|
||||
int nh = rem.value[j + rem.offset];
|
||||
int nh2 = nh + 0x80000000;
|
||||
int nm = rem.value[j + 1 + rem.offset];
|
||||
|
||||
if (nh == dh) {
|
||||
qhat = ~0;
|
||||
qrem = nh + nm;
|
||||
skipCorrection = qrem + 0x80000000 < nh2;
|
||||
} else {
|
||||
long nChunk = (((long) nh) << 32) | (nm & LONG_MASK);
|
||||
if (nChunk >= 0) {
|
||||
qhat = (int) (nChunk / dhLong);
|
||||
qrem = (int) (nChunk - (qhat * dhLong));
|
||||
} else {
|
||||
long tmp = divWord(nChunk, dh);
|
||||
qhat =(int)(tmp & LONG_MASK);
|
||||
qrem = (int)(tmp>>>32);
|
||||
}
|
||||
}
|
||||
|
||||
if (qhat == 0)
|
||||
continue;
|
||||
|
||||
if (!skipCorrection) { // Correct qhat
|
||||
long nl = rem.value[j + 2 + rem.offset] & LONG_MASK;
|
||||
long rs = ((qrem & LONG_MASK) << 32) | nl;
|
||||
long estProduct = (dl & LONG_MASK) * (qhat & LONG_MASK);
|
||||
|
||||
if (unsignedLongCompare(estProduct, rs)) {
|
||||
qhat--;
|
||||
qrem = (int) ((qrem & LONG_MASK) + dhLong);
|
||||
if ((qrem & LONG_MASK) >= dhLong) {
|
||||
estProduct -= (dl & LONG_MASK);
|
||||
rs = ((qrem & LONG_MASK) << 32) | nl;
|
||||
if (unsignedLongCompare(estProduct, rs))
|
||||
qhat--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// D4 Multiply and subtract
|
||||
rem.value[j + rem.offset] = 0;
|
||||
int borrow = mulsubLong(rem.value, dh, dl, qhat, j + rem.offset);
|
||||
|
||||
// D5 Test remainder
|
||||
if (borrow + 0x80000000 > nh2) {
|
||||
// D6 Add back
|
||||
divaddLong(dh,dl, rem.value, j + 1 + rem.offset);
|
||||
qhat--;
|
||||
}
|
||||
|
||||
// Store the quotient digit
|
||||
q[j] = qhat;
|
||||
} // D7 loop on j
|
||||
|
||||
// D8 Unnormalize
|
||||
if (shift > 0)
|
||||
@ -1063,6 +1315,46 @@ class MutableBigInteger {
|
||||
return rem;
|
||||
}
|
||||
|
||||
/**
|
||||
* A primitive used for division by long.
|
||||
* Specialized version of the method divadd.
|
||||
* dh is a high part of the divisor, dl is a low part
|
||||
*/
|
||||
private int divaddLong(int dh, int dl, int[] result, int offset) {
|
||||
long carry = 0;
|
||||
|
||||
long sum = (dl & LONG_MASK) + (result[1+offset] & LONG_MASK);
|
||||
result[1+offset] = (int)sum;
|
||||
|
||||
sum = (dh & LONG_MASK) + (result[offset] & LONG_MASK) + carry;
|
||||
result[offset] = (int)sum;
|
||||
carry = sum >>> 32;
|
||||
return (int)carry;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used for division by long.
|
||||
* Specialized version of the method sulsub.
|
||||
* dh is a high part of the divisor, dl is a low part
|
||||
*/
|
||||
private int mulsubLong(int[] q, int dh, int dl, int x, int offset) {
|
||||
long xLong = x & LONG_MASK;
|
||||
offset += 2;
|
||||
long product = (dl & LONG_MASK) * xLong;
|
||||
long difference = q[offset] - product;
|
||||
q[offset--] = (int)difference;
|
||||
long carry = (product >>> 32)
|
||||
+ (((difference & LONG_MASK) >
|
||||
(((~(int)product) & LONG_MASK))) ? 1:0);
|
||||
product = (dh & LONG_MASK) * xLong + carry;
|
||||
difference = q[offset] - product;
|
||||
q[offset--] = (int)difference;
|
||||
carry = (product >>> 32)
|
||||
+ (((difference & LONG_MASK) >
|
||||
(((~(int)product) & LONG_MASK))) ? 1:0);
|
||||
return (int)carry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two longs as if they were unsigned.
|
||||
* Returns true iff one is bigger than two.
|
||||
@ -1075,19 +1367,22 @@ class MutableBigInteger {
|
||||
* This method divides a long quantity by an int to estimate
|
||||
* qhat for two multi precision numbers. It is used when
|
||||
* the signed value of n is less than zero.
|
||||
* Returns long value where high 32 bits contain reminder value and
|
||||
* low 32 bits contain quotient value.
|
||||
*/
|
||||
private void divWord(int[] result, long n, int d) {
|
||||
static long divWord(long n, int d) {
|
||||
long dLong = d & LONG_MASK;
|
||||
|
||||
long r;
|
||||
long q;
|
||||
if (dLong == 1) {
|
||||
result[0] = (int)n;
|
||||
result[1] = 0;
|
||||
return;
|
||||
q = (int)n;
|
||||
r = 0;
|
||||
return (r << 32) | (q & LONG_MASK);
|
||||
}
|
||||
|
||||
// Approximate the quotient and remainder
|
||||
long q = (n >>> 1) / (dLong >>> 1);
|
||||
long r = n - q*dLong;
|
||||
q = (n >>> 1) / (dLong >>> 1);
|
||||
r = n - q*dLong;
|
||||
|
||||
// Correct the approximation
|
||||
while (r < 0) {
|
||||
@ -1098,10 +1393,8 @@ class MutableBigInteger {
|
||||
r -= dLong;
|
||||
q++;
|
||||
}
|
||||
|
||||
// n - q*dlong == r && 0 <= r <dLong, hence we're done.
|
||||
result[0] = (int)q;
|
||||
result[1] = (int)r;
|
||||
return (r << 32) | (q & LONG_MASK);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1473,5 +1766,4 @@ class MutableBigInteger {
|
||||
mod.subtract(t1);
|
||||
return mod;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -457,10 +457,10 @@ abstract class AbstractPlainSocketImpl extends SocketImpl
|
||||
}
|
||||
|
||||
/*
|
||||
* If connection has been reset then return 0 to indicate
|
||||
* there are no buffered bytes.
|
||||
* If connection has been reset or shut down for input, then return 0
|
||||
* to indicate there are no buffered bytes.
|
||||
*/
|
||||
if (isConnectionReset()) {
|
||||
if (isConnectionReset() || shut_rd) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -174,9 +174,7 @@ class DatagramSocket implements java.io.Closeable {
|
||||
* @see SecurityManager#checkListen
|
||||
*/
|
||||
public DatagramSocket() throws SocketException {
|
||||
// create a datagram socket.
|
||||
createImpl();
|
||||
bind(new InetSocketAddress(0));
|
||||
this(new InetSocketAddress(0));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -221,7 +219,12 @@ class DatagramSocket implements java.io.Closeable {
|
||||
// create a datagram socket.
|
||||
createImpl();
|
||||
if (bindaddr != null) {
|
||||
bind(bindaddr);
|
||||
try {
|
||||
bind(bindaddr);
|
||||
} finally {
|
||||
if (!isBound())
|
||||
close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -162,7 +162,12 @@ class MulticastSocket extends DatagramSocket {
|
||||
setReuseAddress(true);
|
||||
|
||||
if (bindaddr != null) {
|
||||
bind(bindaddr);
|
||||
try {
|
||||
bind(bindaddr);
|
||||
} finally {
|
||||
if (!isBound())
|
||||
close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,6 @@ package java.net;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InterruptedIOException;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
@ -421,10 +420,13 @@ class Socket implements java.io.Closeable {
|
||||
createImpl(stream);
|
||||
if (localAddr != null)
|
||||
bind(localAddr);
|
||||
if (address != null)
|
||||
connect(address);
|
||||
} catch (IOException e) {
|
||||
close();
|
||||
connect(address);
|
||||
} catch (IOException | IllegalArgumentException | SecurityException e) {
|
||||
try {
|
||||
close();
|
||||
} catch (IOException ce) {
|
||||
e.addSuppressed(ce);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
@ -1436,8 +1438,9 @@ class Socket implements java.io.Closeable {
|
||||
* Any data sent to the input stream side of the socket is acknowledged
|
||||
* and then silently discarded.
|
||||
* <p>
|
||||
* If you read from a socket input stream after invoking
|
||||
* shutdownInput() on the socket, the stream will return EOF.
|
||||
* If you read from a socket input stream after invoking this method on the
|
||||
* socket, the stream's {@code available} method will return 0, and its
|
||||
* {@code read} methods will return {@code -1} (end of stream).
|
||||
*
|
||||
* @exception IOException if an I/O error occurs when shutting down this
|
||||
* socket.
|
||||
|
@ -181,8 +181,9 @@ public abstract class SocketImpl implements SocketOptions {
|
||||
* Any data sent to this socket is acknowledged and then
|
||||
* silently discarded.
|
||||
*
|
||||
* If you read from a socket input stream after invoking
|
||||
* shutdownInput() on the socket, the stream will return EOF.
|
||||
* If you read from a socket input stream after invoking this method on the
|
||||
* socket, the stream's {@code available} method will return 0, and its
|
||||
* {@code read} methods will return {@code -1} (end of stream).
|
||||
*
|
||||
* @exception IOException if an I/O error occurs when shutting down this
|
||||
* socket.
|
||||
|
@ -1711,6 +1711,8 @@ public final class URI
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
if (d != '%')
|
||||
return false;
|
||||
i++;
|
||||
if (toLower(s.charAt(i)) != toLower(t.charAt(i)))
|
||||
return false;
|
||||
|
@ -170,7 +170,7 @@ public final class VMID implements java.io.Serializable {
|
||||
/* can't happen, but be deterministic anyway. */
|
||||
addrHash = new byte[0];
|
||||
} catch (NoSuchAlgorithmException complain) {
|
||||
throw new InternalError(complain.toString());
|
||||
throw new InternalError(complain.toString(), complain);
|
||||
}
|
||||
return addrHash;
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ public class CollectionCertStoreParameters
|
||||
return super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
/* Cannot happen */
|
||||
throw new InternalError(e.toString());
|
||||
throw new InternalError(e.toString(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,7 @@ public class LDAPCertStoreParameters implements CertStoreParameters {
|
||||
return super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
/* Cannot happen */
|
||||
throw new InternalError(e.toString());
|
||||
throw new InternalError(e.toString(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -175,7 +175,7 @@ public abstract class PKIXCertPathChecker implements Cloneable {
|
||||
return super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
/* Cannot happen */
|
||||
throw new InternalError(e.toString());
|
||||
throw new InternalError(e.toString(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ public class PKIXCertPathValidatorResult implements CertPathValidatorResult {
|
||||
return super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
/* Cannot happen */
|
||||
throw new InternalError(e.toString());
|
||||
throw new InternalError(e.toString(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -683,7 +683,7 @@ public class PKIXParameters implements CertPathParameters {
|
||||
return copy;
|
||||
} catch (CloneNotSupportedException e) {
|
||||
/* Cannot happen */
|
||||
throw new InternalError(e.toString());
|
||||
throw new InternalError(e.toString(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -708,7 +708,7 @@ public class X509CRLSelector implements CRLSelector {
|
||||
return copy;
|
||||
} catch (CloneNotSupportedException e) {
|
||||
/* Cannot happen */
|
||||
throw new InternalError(e.toString());
|
||||
throw new InternalError(e.toString(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2615,7 +2615,7 @@ public class X509CertSelector implements CertSelector {
|
||||
return copy;
|
||||
} catch (CloneNotSupportedException e) {
|
||||
/* Cannot happen */
|
||||
throw new InternalError(e.toString());
|
||||
throw new InternalError(e.toString(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -794,7 +794,7 @@ public class AttributedString {
|
||||
return other;
|
||||
}
|
||||
catch (CloneNotSupportedException e) {
|
||||
throw new InternalError();
|
||||
throw new InternalError(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,7 @@ class BreakDictionary {
|
||||
);
|
||||
}
|
||||
catch (PrivilegedActionException e) {
|
||||
throw new InternalError(e.toString());
|
||||
throw new InternalError(e.toString(), e);
|
||||
}
|
||||
|
||||
byte[] buf = new byte[8];
|
||||
|
@ -254,7 +254,7 @@ public abstract class BreakIterator implements Cloneable
|
||||
return super.clone();
|
||||
}
|
||||
catch (CloneNotSupportedException e) {
|
||||
throw new InternalError();
|
||||
throw new InternalError(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -617,7 +617,7 @@ public abstract class BreakIterator implements Cloneable
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new InternalError(e.toString());
|
||||
throw new InternalError(e.toString(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -461,7 +461,7 @@ public abstract class Collator
|
||||
try {
|
||||
return (Collator)super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new InternalError();
|
||||
throw new InternalError(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -597,7 +597,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
|
||||
copyMembers(this, other);
|
||||
return other;
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new InternalError();
|
||||
throw new InternalError(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1891,14 +1891,10 @@ public class DecimalFormat extends NumberFormat {
|
||||
* Standard override; no change in semantics.
|
||||
*/
|
||||
public Object clone() {
|
||||
try {
|
||||
DecimalFormat other = (DecimalFormat) super.clone();
|
||||
other.symbols = (DecimalFormatSymbols) symbols.clone();
|
||||
other.digitList = (DigitList) digitList.clone();
|
||||
return other;
|
||||
} catch (Exception e) {
|
||||
throw new InternalError();
|
||||
}
|
||||
DecimalFormat other = (DecimalFormat) super.clone();
|
||||
other.symbols = (DecimalFormatSymbols) symbols.clone();
|
||||
other.digitList = (DigitList) digitList.clone();
|
||||
return other;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -479,7 +479,7 @@ public class DecimalFormatSymbols implements Cloneable, Serializable {
|
||||
return (DecimalFormatSymbols)super.clone();
|
||||
// other fields are bit-copied
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new InternalError();
|
||||
throw new InternalError(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -632,7 +632,7 @@ final class DigitList implements Cloneable {
|
||||
other.tempBuffer = null;
|
||||
return other;
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new InternalError();
|
||||
throw new InternalError(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -258,7 +258,7 @@ public abstract class Format implements Serializable, Cloneable {
|
||||
return super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
// will never happen
|
||||
return null;
|
||||
throw new InternalError(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -453,7 +453,7 @@ class RuleBasedBreakIterator extends BreakIterator {
|
||||
);
|
||||
}
|
||||
catch (PrivilegedActionException e) {
|
||||
throw new InternalError(e.toString());
|
||||
throw new InternalError(e.toString(), e);
|
||||
}
|
||||
|
||||
int offset = 0;
|
||||
|
@ -272,7 +272,7 @@ public final class StringCharacterIterator implements CharacterIterator
|
||||
return other;
|
||||
}
|
||||
catch (CloneNotSupportedException e) {
|
||||
throw new InternalError();
|
||||
throw new InternalError(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -307,7 +307,7 @@ public class ArrayList<E> extends AbstractList<E>
|
||||
return v;
|
||||
} catch (CloneNotSupportedException e) {
|
||||
// this shouldn't happen, since we are Cloneable
|
||||
throw new InternalError();
|
||||
throw new InternalError(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1092,7 +1092,7 @@ public class BitSet implements Cloneable, java.io.Serializable {
|
||||
result.checkInvariants();
|
||||
return result;
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new InternalError();
|
||||
throw new InternalError(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2512,7 +2512,7 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable<Ca
|
||||
}
|
||||
catch (CloneNotSupportedException e) {
|
||||
// this shouldn't happen, since we are Cloneable
|
||||
throw new InternalError();
|
||||
throw new InternalError(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -221,9 +221,7 @@ public final class Currency implements Serializable {
|
||||
otherCurrenciesNumericCode = readIntArray(dis, ocCount);
|
||||
dis.close();
|
||||
} catch (IOException e) {
|
||||
InternalError ie = new InternalError();
|
||||
ie.initCause(e);
|
||||
throw ie;
|
||||
throw new InternalError(e);
|
||||
}
|
||||
|
||||
// look for the properties file for overrides
|
||||
|
@ -253,7 +253,7 @@ public class HashSet<E>
|
||||
newSet.map = (HashMap<E, Object>) map.clone();
|
||||
return newSet;
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new InternalError();
|
||||
throw new InternalError(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -537,7 +537,7 @@ public class Hashtable<K,V>
|
||||
return t;
|
||||
} catch (CloneNotSupportedException e) {
|
||||
// this shouldn't happen, since we are Cloneable
|
||||
throw new InternalError();
|
||||
throw new InternalError(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -703,7 +703,7 @@ public class IdentityHashMap<K,V>
|
||||
m.table = table.clone();
|
||||
return m;
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new InternalError();
|
||||
throw new InternalError(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -994,7 +994,7 @@ public class LinkedList<E>
|
||||
try {
|
||||
return (LinkedList<E>) super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new InternalError();
|
||||
throw new InternalError(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1859,7 +1859,7 @@ public final class Locale implements Cloneable, Serializable {
|
||||
Locale that = (Locale)super.clone();
|
||||
return that;
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new InternalError();
|
||||
throw new InternalError(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -614,7 +614,7 @@ public abstract class ResourceBundle {
|
||||
return clone;
|
||||
} catch (CloneNotSupportedException e) {
|
||||
//this should never happen
|
||||
throw new InternalError();
|
||||
throw new InternalError(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -739,7 +739,7 @@ abstract public class TimeZone implements Serializable, Cloneable {
|
||||
other.ID = ID;
|
||||
return other;
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new InternalError();
|
||||
throw new InternalError(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -622,7 +622,7 @@ public class TreeMap<K,V>
|
||||
try {
|
||||
clone = (TreeMap<K,V>) super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new InternalError();
|
||||
throw new InternalError(e);
|
||||
}
|
||||
|
||||
// Put clone into "virgin" state (except for comparator)
|
||||
|
@ -474,7 +474,7 @@ public class TreeSet<E> extends AbstractSet<E>
|
||||
try {
|
||||
clone = (TreeSet<E>) super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new InternalError();
|
||||
throw new InternalError(e);
|
||||
}
|
||||
|
||||
clone.m = new TreeMap<>(m);
|
||||
|
@ -165,7 +165,7 @@ public final class UUID implements java.io.Serializable, Comparable<UUID> {
|
||||
try {
|
||||
md = MessageDigest.getInstance("MD5");
|
||||
} catch (NoSuchAlgorithmException nsae) {
|
||||
throw new InternalError("MD5 not supported");
|
||||
throw new InternalError("MD5 not supported", nsae);
|
||||
}
|
||||
byte[] md5Bytes = md.digest(name);
|
||||
md5Bytes[6] &= 0x0f; /* clear version */
|
||||
|
@ -673,7 +673,7 @@ public class Vector<E>
|
||||
return v;
|
||||
} catch (CloneNotSupportedException e) {
|
||||
// this shouldn't happen, since we are Cloneable
|
||||
throw new InternalError();
|
||||
throw new InternalError(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -321,7 +321,7 @@ class ZipEntry implements ZipConstants, Cloneable {
|
||||
return e;
|
||||
} catch (CloneNotSupportedException e) {
|
||||
// This should never happen, since we are Cloneable
|
||||
throw new InternalError();
|
||||
throw new InternalError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -671,7 +671,7 @@ public class TabularDataSupport
|
||||
return c;
|
||||
}
|
||||
catch (CloneNotSupportedException e) {
|
||||
throw new InternalError(e.toString());
|
||||
throw new InternalError(e.toString(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -157,7 +157,7 @@ public class ElementIterator implements Cloneable {
|
||||
}
|
||||
return it;
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new InternalError();
|
||||
throw new InternalError(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -528,7 +528,7 @@ public void setCharacterSet(String name)
|
||||
try {
|
||||
translationTable = (char[])getCharacterSet("ansi");
|
||||
} catch (IOException e) {
|
||||
throw new InternalError("RTFReader: Unable to find character set resources (" + e + ")");
|
||||
throw new InternalError("RTFReader: Unable to find character set resources (" + e + ")", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1614,7 +1614,7 @@ class DocumentDestination
|
||||
} catch (BadLocationException ble) {
|
||||
/* This shouldn't be able to happen, of course */
|
||||
/* TODO is InternalError the correct error to throw? */
|
||||
throw new InternalError(ble.getMessage());
|
||||
throw new InternalError(ble.getMessage(), ble);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1628,7 +1628,7 @@ class DocumentDestination
|
||||
} catch (BadLocationException ble) {
|
||||
/* This shouldn't be able to happen, of course */
|
||||
/* TODO is InternalError the correct error to throw? */
|
||||
throw new InternalError(ble.getMessage());
|
||||
throw new InternalError(ble.getMessage(), ble);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -266,11 +266,20 @@ public abstract class FontConfiguration {
|
||||
private File findFontConfigFile(String javaLib) {
|
||||
String baseName = javaLib + File.separator + "fontconfig";
|
||||
File configFile;
|
||||
String osMajorVersion = null;
|
||||
if (osVersion != null && osName != null) {
|
||||
configFile = findImpl(baseName + "." + osName + "." + osVersion);
|
||||
if (configFile != null) {
|
||||
return configFile;
|
||||
}
|
||||
int decimalPointIndex = osVersion.indexOf(".");
|
||||
if (decimalPointIndex != -1) {
|
||||
osMajorVersion = osVersion.substring(0, osVersion.indexOf("."));
|
||||
configFile = findImpl(baseName + "." + osName + "." + osMajorVersion);
|
||||
if (configFile != null) {
|
||||
return configFile;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (osName != null) {
|
||||
configFile = findImpl(baseName + "." + osName);
|
||||
@ -283,6 +292,12 @@ public abstract class FontConfiguration {
|
||||
if (configFile != null) {
|
||||
return configFile;
|
||||
}
|
||||
if (osMajorVersion != null) {
|
||||
configFile = findImpl(baseName + "." + osMajorVersion);
|
||||
if (configFile != null) {
|
||||
return configFile;
|
||||
}
|
||||
}
|
||||
}
|
||||
foundOsSpecificFile = false;
|
||||
|
||||
|
@ -158,7 +158,7 @@ public class DuctusRenderingEngine extends RenderingEngine {
|
||||
feedConsumer(pi, consumer, normalize, 0.25f);
|
||||
} catch (PathException e) {
|
||||
throw new InternalError("Unable to Stroke shape ("+
|
||||
e.getMessage()+")");
|
||||
e.getMessage()+")", e);
|
||||
} finally {
|
||||
while (consumer != null && consumer != sr) {
|
||||
PathConsumer next = consumer.getConsumer();
|
||||
@ -763,7 +763,7 @@ public class DuctusRenderingEngine extends RenderingEngine {
|
||||
consumer.endPath();
|
||||
} catch (PathException e) {
|
||||
throw new InternalError("Unable to Stroke shape ("+
|
||||
e.getMessage()+")");
|
||||
e.getMessage()+")", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ public final class FontLineMetrics extends LineMetrics implements Cloneable {
|
||||
return super.clone();
|
||||
}
|
||||
catch (CloneNotSupportedException e) {
|
||||
throw new InternalError();
|
||||
throw new InternalError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -233,7 +233,7 @@ public final class GlyphLayout {
|
||||
invdtx = dtx.createInverse();
|
||||
}
|
||||
catch (NoninvertibleTransformException e) {
|
||||
throw new InternalError();
|
||||
throw new InternalError(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user