提交 903cc2eb 编写于 作者: L lana

Merge

# #
# Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved. # Copyright 2005-2010 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -1093,6 +1093,7 @@ endif ...@@ -1093,6 +1093,7 @@ endif
# Check for existence of misc Hotspot imported files # Check for existence of misc Hotspot imported files
###################################################### ######################################################
HOTSPOT_INCLUDE_FILE_LIST = jvmti.h HOTSPOT_INCLUDE_FILE_LIST = jvmti.h
HOTSPOT_INCLUDE_FILE_LIST += jvmticmlr.h
#HOTSPOT_INCLUDE_FILE_LIST += jni.h jni_md.h #HOTSPOT_INCLUDE_FILE_LIST += jni.h jni_md.h
#HOTSPOT_INCLUDE_FILE_LIST += jvm.h jvm_md.h #HOTSPOT_INCLUDE_FILE_LIST += jvm.h jvm_md.h
#HOTSPOT_INCLUDE_FILE_LIST += jmm.h #HOTSPOT_INCLUDE_FILE_LIST += jmm.h
......
# #
# Copyright 1995-2005 Sun Microsystems, Inc. All Rights Reserved. # Copyright 1995-2010 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -34,7 +34,8 @@ include $(BUILDDIR)/common/Defs.gmk ...@@ -34,7 +34,8 @@ include $(BUILDDIR)/common/Defs.gmk
FILES_h = $(INCLUDEDIR)/jni.h \ FILES_h = $(INCLUDEDIR)/jni.h \
$(PLATFORM_INCLUDE)/jni_md.h \ $(PLATFORM_INCLUDE)/jni_md.h \
$(INCLUDEDIR)/jvmti.h \ $(INCLUDEDIR)/jvmti.h \
$(INCLUDEDIR)/jvmticmlr.h \
$(INCLUDEDIR)/classfile_constants.h $(INCLUDEDIR)/classfile_constants.h
$(INCLUDEDIR)/%.h: $(SHARE_SRC)/javavm/export/%.h $(INCLUDEDIR)/%.h: $(SHARE_SRC)/javavm/export/%.h
......
...@@ -31,7 +31,7 @@ BUILDDIR = ../.. ...@@ -31,7 +31,7 @@ BUILDDIR = ../..
PACKAGE = sun.nio PACKAGE = sun.nio
PRODUCT = sun PRODUCT = sun
OTHER_JAVACFLAGS += -Xlint:serial -Werror OTHER_JAVACFLAGS += -Xlint:serial,-deprecation -Werror
include $(BUILDDIR)/common/Defs.gmk include $(BUILDDIR)/common/Defs.gmk
# #
......
# #
# Copyright 2004-2006 Sun Microsystems, Inc. All Rights Reserved. # Copyright 2004-2010 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -34,12 +34,13 @@ include $(BUILDDIR)/common/Defs.gmk ...@@ -34,12 +34,13 @@ include $(BUILDDIR)/common/Defs.gmk
# Can be built in any order, the JRE version of hprof and java_crw_demo are # Can be built in any order, the JRE version of hprof and java_crw_demo are
# really built in make/java. # really built in make/java.
# The hprof target here just deliveres the sources and README files. # The hprof target here just delivers the sources and README files.
# The java_crw_demo and agent_util files are copied into each demo that # The java_crw_demo and agent_util files are copied into each demo that
# uses them. # uses them.
SUBDIRS = \ SUBDIRS = \
versionCheck \ versionCheck \
gctest \ compiledMethodLoad \
gctest \
heapViewer \ heapViewer \
heapTracker \ heapTracker \
minst \ minst \
......
# #
# Copyright 2004 Sun Microsystems, Inc. All Rights Reserved. # Copyright 2004-2010 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -27,8 +27,8 @@ Instructions on adding a jvmti demo agent. ...@@ -27,8 +27,8 @@ Instructions on adding a jvmti demo agent.
Basically you want to mimic the jvmti demo agent "mtrace". Basically you want to mimic the jvmti demo agent "mtrace".
* Create and populate a source directory at src/demo/jvmti * Create and populate a source directory at src/share/demo/jvmti
(Try and re-use code in agent_util area like src/demo/jvmti/mtrace) (Try and re-use code in agent_util area like src/share/demo/jvmti/mtrace)
(This should include a small README.txt document on what this demo is) (This should include a small README.txt document on what this demo is)
* Make sure the appropriate "demo" copyright notice is added to all the * Make sure the appropriate "demo" copyright notice is added to all the
...@@ -44,7 +44,7 @@ Basically you want to mimic the jvmti demo agent "mtrace". ...@@ -44,7 +44,7 @@ Basically you want to mimic the jvmti demo agent "mtrace".
* Create test directory at test/demo/jvmti, create at least one test * Create test directory at test/demo/jvmti, create at least one test
(Use test/demo/jvmti/mtrace as a template) (Use test/demo/jvmti/mtrace as a template)
* Don't forget to SCCS in all the new files * Don't forget to check in all the new files
* Build and create images (cd make && gnumake && gnumake images) * Build and create images (cd make && gnumake && gnumake images)
(Do this on Solaris, Linux, and at least one Windows platform) (Do this on Solaris, Linux, and at least one Windows platform)
...@@ -54,5 +54,5 @@ Basically you want to mimic the jvmti demo agent "mtrace". ...@@ -54,5 +54,5 @@ Basically you want to mimic the jvmti demo agent "mtrace".
* Run the tests: cd test/demo/jvmti && runregress . * Run the tests: cd test/demo/jvmti && runregress .
(Do this on Solaris, Linux, and at least one Windows platform) (Do this on Solaris, Linux, and at least one Windows platform)
Contact: jk-svc-group@sun.com for more information or help. Contact: serviceability-dev@openjdk.java.net for more information or help.
#
# Copyright 2010 Sun Microsystems, Inc. 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. Sun designates this
# particular file as subject to the "Classpath" exception as provided
# by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
# CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions.
#
BUILDDIR = ../../..
PRODUCT = demo/jvmti
DEMONAME = compiledMethodLoad
include $(BUILDDIR)/common/Defs.gmk
DEMO_ROOT = $(SHARE_SRC)/demo/jvmti/$(DEMONAME)
DEMO_TOPFILES = ./README.txt
DEMO_DESTDIR = $(DEMODIR)/jvmti/$(DEMONAME)
DEMO_OBJECTS = agent_util.$(OBJECT_SUFFIX)
#
# Demo jar building rules.
#
include $(BUILDDIR)/common/Demo.gmk
/* /*
* Copyright 2000-2006 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -663,15 +663,23 @@ public class PKIXParameters implements CertPathParameters { ...@@ -663,15 +663,23 @@ public class PKIXParameters implements CertPathParameters {
*/ */
public Object clone() { public Object clone() {
try { try {
Object copy = super.clone(); PKIXParameters copy = (PKIXParameters)super.clone();
// Must clone these because addCertStore, et al. modify them
// must clone these because addCertStore, et al. modify them
if (certStores != null) { if (certStores != null) {
certStores = new ArrayList<CertStore>(certStores); copy.certStores = new ArrayList<CertStore>(certStores);
} }
if (certPathCheckers != null) { if (certPathCheckers != null) {
certPathCheckers = copy.certPathCheckers =
new ArrayList<PKIXCertPathChecker>(certPathCheckers); new ArrayList<PKIXCertPathChecker>(certPathCheckers.size());
for (PKIXCertPathChecker checker : certPathCheckers) {
copy.certPathCheckers.add(
(PKIXCertPathChecker)checker.clone());
}
} }
// other class fields are immutable to public, don't bother
// to clone the read-only fields.
return copy; return copy;
} catch (CloneNotSupportedException e) { } catch (CloneNotSupportedException e) {
/* Cannot happen */ /* Cannot happen */
......
...@@ -860,6 +860,14 @@ public final class Pattern ...@@ -860,6 +860,14 @@ public final class Pattern
*/ */
private transient int patternLength; private transient int patternLength;
/**
* If the Start node might possibly match supplementary characters.
* It is set to true during compiling if
* (1) There is supplementary char in pattern, or
* (2) There is complement node of Category or Block
*/
private transient boolean hasSupplementary;
/** /**
* Compiles the given regular expression into a pattern. </p> * Compiles the given regular expression into a pattern. </p>
* *
...@@ -1481,7 +1489,7 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) { ...@@ -1481,7 +1489,7 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
// Use double zero to terminate pattern // Use double zero to terminate pattern
temp = new int[patternLength + 2]; temp = new int[patternLength + 2];
boolean hasSupplementary = false; hasSupplementary = false;
int c, count = 0; int c, count = 0;
// Convert all chars into code points // Convert all chars into code points
for (int x = 0; x < patternLength; x += Character.charCount(c)) { for (int x = 0; x < patternLength; x += Character.charCount(c)) {
...@@ -1787,7 +1795,8 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) { ...@@ -1787,7 +1795,8 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
* character or unpaired surrogate. * character or unpaired surrogate.
*/ */
private static final boolean isSupplementary(int ch) { private static final boolean isSupplementary(int ch) {
return ch >= Character.MIN_SUPPLEMENTARY_CODE_POINT || isSurrogate(ch); return ch >= Character.MIN_SUPPLEMENTARY_CODE_POINT ||
Character.isSurrogate((char)ch);
} }
/** /**
...@@ -1885,7 +1894,7 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) { ...@@ -1885,7 +1894,7 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
} else { } else {
oneLetter = false; oneLetter = false;
} }
node = family(oneLetter).maybeComplement(comp); node = family(oneLetter, comp);
} else { } else {
unread(); unread();
node = atom(); node = atom();
...@@ -2001,7 +2010,7 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) { ...@@ -2001,7 +2010,7 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
unread(); unread();
else else
oneLetter = false; oneLetter = false;
return family(oneLetter).maybeComplement(comp); return family(oneLetter, comp);
} }
} }
unread(); unread();
...@@ -2404,7 +2413,7 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) { ...@@ -2404,7 +2413,7 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
unread(); unread();
else else
oneLetter = false; oneLetter = false;
return family(oneLetter).maybeComplement(comp); return family(oneLetter, comp);
} else { // ordinary escape } else { // ordinary escape
unread(); unread();
ch = escape(true, true); ch = escape(true, true);
...@@ -2450,9 +2459,12 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) { ...@@ -2450,9 +2459,12 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
/** /**
* Parses a Unicode character family and returns its representative node. * Parses a Unicode character family and returns its representative node.
*/ */
private CharProperty family(boolean singleLetter) { private CharProperty family(boolean singleLetter,
boolean maybeComplement)
{
next(); next();
String name; String name;
CharProperty node;
if (singleLetter) { if (singleLetter) {
int c = temp[cursor]; int c = temp[cursor];
...@@ -2477,12 +2489,18 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) { ...@@ -2477,12 +2489,18 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
} }
if (name.startsWith("In")) { if (name.startsWith("In")) {
return unicodeBlockPropertyFor(name.substring(2)); node = unicodeBlockPropertyFor(name.substring(2));
} else { } else {
if (name.startsWith("Is")) if (name.startsWith("Is"))
name = name.substring(2); name = name.substring(2);
return charPropertyNodeFor(name); node = charPropertyNodeFor(name);
}
if (maybeComplement) {
if (node instanceof Category || node instanceof Block)
hasSupplementary = true;
node = node.complement();
} }
return node;
} }
/** /**
...@@ -2495,9 +2513,7 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) { ...@@ -2495,9 +2513,7 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
} catch (IllegalArgumentException iae) { } catch (IllegalArgumentException iae) {
throw error("Unknown character block name {" + name + "}"); throw error("Unknown character block name {" + name + "}");
} }
return new CharProperty() { return new Block(block);
boolean isSatisfiedBy(int ch) {
return block == Character.UnicodeBlock.of(ch);}};
} }
/** /**
...@@ -2968,13 +2984,6 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) { ...@@ -2968,13 +2984,6 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
// Utility methods for code point support // Utility methods for code point support
// //
/**
* Tests a surrogate value.
*/
private static final boolean isSurrogate(int c) {
return c >= Character.MIN_HIGH_SURROGATE && c <= Character.MAX_LOW_SURROGATE;
}
private static final int countChars(CharSequence seq, int index, private static final int countChars(CharSequence seq, int index,
int lengthInCodePoints) { int lengthInCodePoints) {
// optimization // optimization
...@@ -3174,20 +3183,17 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) { ...@@ -3174,20 +3183,17 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
matcher.hitEnd = true; matcher.hitEnd = true;
return false; return false;
} }
boolean ret = false;
int guard = matcher.to - minLength; int guard = matcher.to - minLength;
for (; i <= guard; i++) { for (; i <= guard; i++) {
if (ret = next.match(matcher, i, seq)) if (next.match(matcher, i, seq)) {
break; matcher.first = i;
if (i == guard) matcher.groups[0] = matcher.first;
matcher.hitEnd = true; matcher.groups[1] = matcher.last;
} return true;
if (ret) { }
matcher.first = i;
matcher.groups[0] = matcher.first;
matcher.groups[1] = matcher.last;
} }
return ret; matcher.hitEnd = true;
return false;
} }
boolean study(TreeInfo info) { boolean study(TreeInfo info) {
next.study(info); next.study(info);
...@@ -3209,27 +3215,28 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) { ...@@ -3209,27 +3215,28 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
matcher.hitEnd = true; matcher.hitEnd = true;
return false; return false;
} }
boolean ret = false;
int guard = matcher.to - minLength; int guard = matcher.to - minLength;
while (i <= guard) { while (i <= guard) {
if ((ret = next.match(matcher, i, seq)) || i == guard) //if ((ret = next.match(matcher, i, seq)) || i == guard)
if (next.match(matcher, i, seq)) {
matcher.first = i;
matcher.groups[0] = matcher.first;
matcher.groups[1] = matcher.last;
return true;
}
if (i == guard)
break; break;
// Optimization to move to the next character. This is // Optimization to move to the next character. This is
// faster than countChars(seq, i, 1). // faster than countChars(seq, i, 1).
if (Character.isHighSurrogate(seq.charAt(i++))) { if (Character.isHighSurrogate(seq.charAt(i++))) {
if (i < seq.length() && Character.isLowSurrogate(seq.charAt(i))) { if (i < seq.length() &&
Character.isLowSurrogate(seq.charAt(i))) {
i++; i++;
} }
} }
if (i == guard)
matcher.hitEnd = true;
}
if (ret) {
matcher.first = i;
matcher.groups[0] = matcher.first;
matcher.groups[1] = matcher.last;
} }
return ret; matcher.hitEnd = true;
return false;
} }
} }
...@@ -3461,9 +3468,6 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) { ...@@ -3461,9 +3468,6 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
boolean isSatisfiedBy(int ch) { boolean isSatisfiedBy(int ch) {
return ! CharProperty.this.isSatisfiedBy(ch);}}; return ! CharProperty.this.isSatisfiedBy(ch);}};
} }
CharProperty maybeComplement(boolean complement) {
return complement ? complement() : this;
}
boolean match(Matcher matcher, int i, CharSequence seq) { boolean match(Matcher matcher, int i, CharSequence seq) {
if (i < matcher.to) { if (i < matcher.to) {
int ch = Character.codePointAt(seq, i); int ch = Character.codePointAt(seq, i);
...@@ -3548,6 +3552,20 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) { ...@@ -3548,6 +3552,20 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
} }
} }
/**
* Node class that matches a Unicode block.
*/
static final class Block extends CharProperty {
final Character.UnicodeBlock block;
Block(Character.UnicodeBlock block) {
this.block = block;
}
boolean isSatisfiedBy(int ch) {
return block == Character.UnicodeBlock.of(ch);
}
}
/** /**
* Node class that matches a Unicode category. * Node class that matches a Unicode category.
*/ */
......
...@@ -113,7 +113,7 @@ public class ByteToCharUTF8 extends ByteToCharConverter { ...@@ -113,7 +113,7 @@ public class ByteToCharUTF8 extends ByteToCharConverter {
savedSize = 1; savedSize = 1;
} else { } else {
savedSize = 2; savedSize = 2;
savedBytes[1] = (byte)input[byteOff++]; savedBytes[1] = input[byteOff++];
} }
break; break;
} }
...@@ -135,11 +135,11 @@ public class ByteToCharUTF8 extends ByteToCharConverter { ...@@ -135,11 +135,11 @@ public class ByteToCharUTF8 extends ByteToCharConverter {
savedSize = 1; savedSize = 1;
} else if (byteOff + 1 >= inEnd) { } else if (byteOff + 1 >= inEnd) {
savedSize = 2; savedSize = 2;
savedBytes[1] = (byte)input[byteOff++]; savedBytes[1] = input[byteOff++];
} else { } else {
savedSize = 3; savedSize = 3;
savedBytes[1] = (byte)input[byteOff++]; savedBytes[1] = input[byteOff++];
savedBytes[2] = (byte)input[byteOff++]; savedBytes[2] = input[byteOff++];
} }
break; break;
} }
...@@ -154,10 +154,10 @@ public class ByteToCharUTF8 extends ByteToCharConverter { ...@@ -154,10 +154,10 @@ public class ByteToCharUTF8 extends ByteToCharConverter {
throw new MalformedInputException(); throw new MalformedInputException();
} }
// this byte sequence is UTF16 character // this byte sequence is UTF16 character
int ucs4 = (int)(0x07 & byte1) << 18 | int ucs4 = (0x07 & byte1) << 18 |
(int)(0x3f & byte2) << 12 | (0x3f & byte2) << 12 |
(int)(0x3f & byte3) << 6 | (0x3f & byte3) << 6 |
(int)(0x3f & byte4); (0x3f & byte4);
outputChar[0] = (char)((ucs4 - 0x10000) / 0x400 + 0xd800); outputChar[0] = (char)((ucs4 - 0x10000) / 0x400 + 0xd800);
outputChar[1] = (char)((ucs4 - 0x10000) % 0x400 + 0xdc00); outputChar[1] = (char)((ucs4 - 0x10000) % 0x400 + 0xdc00);
outputSize = 2; outputSize = 2;
......
...@@ -46,7 +46,7 @@ public class CharToByteUnicode extends CharToByteConverter { ...@@ -46,7 +46,7 @@ public class CharToByteUnicode extends CharToByteConverter {
protected int byteOrder = UNKNOWN; protected int byteOrder = UNKNOWN;
public CharToByteUnicode() { public CharToByteUnicode() {
String enc = (String) java.security.AccessController.doPrivileged( String enc = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("sun.io.unicode.encoding", new sun.security.action.GetPropertyAction("sun.io.unicode.encoding",
"UnicodeBig")); "UnicodeBig"));
if (enc.equals("UnicodeBig")) if (enc.equals("UnicodeBig"))
......
...@@ -50,11 +50,11 @@ public class CharacterEncoding { ...@@ -50,11 +50,11 @@ public class CharacterEncoding {
private static boolean sjisIsMS932; private static boolean sjisIsMS932;
private static Map aliasTable; private static Map<String,String> aliasTable;
private static volatile boolean installedAll; private static volatile boolean installedAll;
static { static {
aliasTable = new HashMap(460, 1.0f); /* MDA */ aliasTable = new HashMap<>(460, 1.0f); /* MDA */
aliasTable.put("us-ascii", "ASCII"); aliasTable.put("us-ascii", "ASCII");
aliasTable.put("ascii", "ASCII"); aliasTable.put("ascii", "ASCII");
...@@ -119,11 +119,11 @@ public class CharacterEncoding { ...@@ -119,11 +119,11 @@ public class CharacterEncoding {
} }
// need to use Locale.US so we can load ISO converters in tr_TR locale // need to use Locale.US so we can load ISO converters in tr_TR locale
String lower = name.toLowerCase(Locale.US); String lower = name.toLowerCase(Locale.US);
String val = (String) aliasTable.get(lower); String val = aliasTable.get(lower);
if (val == null && !installedAll) { if (val == null && !installedAll) {
installAll(); installAll();
val = (String) aliasTable.get(lower); val = aliasTable.get(lower);
} }
return val; return val;
} }
...@@ -131,7 +131,7 @@ public class CharacterEncoding { ...@@ -131,7 +131,7 @@ public class CharacterEncoding {
private static synchronized void installAll() { private static synchronized void installAll() {
if (!installedAll) { if (!installedAll) {
GetPropertyAction a = new GetPropertyAction("sun.nio.cs.map"); GetPropertyAction a = new GetPropertyAction("sun.nio.cs.map");
String map = ((String)AccessController.doPrivileged(a)); String map = AccessController.doPrivileged(a);
if (map != null) { if (map != null) {
sjisIsMS932 = map.equalsIgnoreCase("Windows-31J/Shift_JIS"); sjisIsMS932 = map.equalsIgnoreCase("Windows-31J/Shift_JIS");
} else { } else {
...@@ -857,9 +857,9 @@ public class CharacterEncoding { ...@@ -857,9 +857,9 @@ public class CharacterEncoding {
* Auto Detect converter. * Auto Detect converter.
*/ */
static String getSJISName() { static String getSJISName() {
String encodeName = (String) AccessController.doPrivileged( String encodeName = AccessController.doPrivileged(
new PrivilegedAction() { new PrivilegedAction<String>() {
public Object run() { public String run() {
String osName = System.getProperty("os.name"); String osName = System.getProperty("os.name");
if (osName.equals("Solaris") || osName.equals("SunOS")){ if (osName.equals("Solaris") || osName.equals("SunOS")){
return "PCK"; return "PCK";
...@@ -880,9 +880,9 @@ public class CharacterEncoding { ...@@ -880,9 +880,9 @@ public class CharacterEncoding {
static String getEUCJPName() { static String getEUCJPName() {
String encodeName = (String) AccessController.doPrivileged( String encodeName = AccessController.doPrivileged(
new PrivilegedAction() { new PrivilegedAction<String>() {
public Object run() { public String run() {
String osName = System.getProperty("os.name"); String osName = System.getProperty("os.name");
if (osName.equals("Solaris") || osName.equals("SunOS")) if (osName.equals("Solaris") || osName.equals("SunOS"))
return "eucJP-open"; return "eucJP-open";
......
...@@ -85,10 +85,11 @@ public class Converters { ...@@ -85,10 +85,11 @@ public class Converters {
* this code can be involved in the startup sequence it's important to keep * this code can be involved in the startup sequence it's important to keep
* the footprint down. * the footprint down.
*/ */
private static SoftReference[][] classCache @SuppressWarnings("unchecked")
= new SoftReference[][] { private static SoftReference<Object[]>[][] classCache
new SoftReference[CACHE_SIZE], = (SoftReference<Object[]>[][]) new SoftReference<?>[][] {
new SoftReference[CACHE_SIZE] new SoftReference<?>[CACHE_SIZE],
new SoftReference<?>[CACHE_SIZE]
}; };
private static void moveToFront(Object[] oa, int i) { private static void moveToFront(Object[] oa, int i) {
...@@ -98,28 +99,28 @@ public class Converters { ...@@ -98,28 +99,28 @@ public class Converters {
oa[0] = ob; oa[0] = ob;
} }
private static Class cache(int type, Object encoding) { private static Class<?> cache(int type, Object encoding) {
SoftReference[] srs = classCache[type]; SoftReference<Object[]>[] srs = classCache[type];
for (int i = 0; i < CACHE_SIZE; i++) { for (int i = 0; i < CACHE_SIZE; i++) {
SoftReference sr = srs[i]; SoftReference<Object[]> sr = srs[i];
if (sr == null) if (sr == null)
continue; continue;
Object[] oa = (Object[])sr.get(); Object[] oa = sr.get();
if (oa == null) { if (oa == null) {
srs[i] = null; srs[i] = null;
continue; continue;
} }
if (oa[1].equals(encoding)) { if (oa[1].equals(encoding)) {
moveToFront(srs, i); moveToFront(srs, i);
return (Class)oa[0]; return (Class<?>)oa[0];
} }
} }
return null; return null;
} }
private static Class cache(int type, Object encoding, Class c) { private static Class<?> cache(int type, Object encoding, Class<?> c) {
SoftReference[] srs = classCache[type]; SoftReference<Object[]>[] srs = classCache[type];
srs[CACHE_SIZE - 1] = new SoftReference(new Object[] { c, encoding }); srs[CACHE_SIZE - 1] = new SoftReference<Object[]>(new Object[] { c, encoding });
moveToFront(srs, CACHE_SIZE - 1); moveToFront(srs, CACHE_SIZE - 1);
return c; return c;
} }
...@@ -129,12 +130,12 @@ public class Converters { ...@@ -129,12 +130,12 @@ public class Converters {
*/ */
public static boolean isCached(int type, String encoding) { public static boolean isCached(int type, String encoding) {
synchronized (lock) { synchronized (lock) {
SoftReference[] srs = classCache[type]; SoftReference<Object[]>[] srs = classCache[type];
for (int i = 0; i < CACHE_SIZE; i++) { for (int i = 0; i < CACHE_SIZE; i++) {
SoftReference sr = srs[i]; SoftReference<Object[]> sr = srs[i];
if (sr == null) if (sr == null)
continue; continue;
Object[] oa = (Object[])sr.get(); Object[] oa = sr.get();
if (oa == null) { if (oa == null) {
srs[i] = null; srs[i] = null;
continue; continue;
...@@ -152,9 +153,9 @@ public class Converters { ...@@ -152,9 +153,9 @@ public class Converters {
private static String getConverterPackageName() { private static String getConverterPackageName() {
String cp = converterPackageName; String cp = converterPackageName;
if (cp != null) return cp; if (cp != null) return cp;
java.security.PrivilegedAction pa = java.security.PrivilegedAction<String> pa =
new sun.security.action.GetPropertyAction("file.encoding.pkg"); new sun.security.action.GetPropertyAction("file.encoding.pkg");
cp = (String)java.security.AccessController.doPrivileged(pa); cp = java.security.AccessController.doPrivileged(pa);
if (cp != null) { if (cp != null) {
/* Property is set, so take it as the true converter package */ /* Property is set, so take it as the true converter package */
converterPackageName = cp; converterPackageName = cp;
...@@ -168,9 +169,9 @@ public class Converters { ...@@ -168,9 +169,9 @@ public class Converters {
public static String getDefaultEncodingName() { public static String getDefaultEncodingName() {
synchronized (lock) { synchronized (lock) {
if (defaultEncoding == null) { if (defaultEncoding == null) {
java.security.PrivilegedAction pa = java.security.PrivilegedAction<String> pa =
new sun.security.action.GetPropertyAction("file.encoding"); new sun.security.action.GetPropertyAction("file.encoding");
defaultEncoding = (String)java.security.AccessController.doPrivileged(pa); defaultEncoding = java.security.AccessController.doPrivileged(pa);
} }
} }
return defaultEncoding; return defaultEncoding;
...@@ -194,7 +195,7 @@ public class Converters { ...@@ -194,7 +195,7 @@ public class Converters {
* encoding, or throw an UnsupportedEncodingException if no such class can * encoding, or throw an UnsupportedEncodingException if no such class can
* be found * be found
*/ */
private static Class getConverterClass(int type, String encoding) private static Class<?> getConverterClass(int type, String encoding)
throws UnsupportedEncodingException throws UnsupportedEncodingException
{ {
String enc = null; String enc = null;
...@@ -241,7 +242,7 @@ public class Converters { ...@@ -241,7 +242,7 @@ public class Converters {
* Instantiate the given converter class, or throw an * Instantiate the given converter class, or throw an
* UnsupportedEncodingException if it cannot be instantiated * UnsupportedEncodingException if it cannot be instantiated
*/ */
private static Object newConverter(String enc, Class c) private static Object newConverter(String enc, Class<?> c)
throws UnsupportedEncodingException throws UnsupportedEncodingException
{ {
try { try {
...@@ -261,7 +262,7 @@ public class Converters { ...@@ -261,7 +262,7 @@ public class Converters {
static Object newConverter(int type, String enc) static Object newConverter(int type, String enc)
throws UnsupportedEncodingException throws UnsupportedEncodingException
{ {
Class c; Class<?> c;
synchronized (lock) { synchronized (lock) {
c = cache(type, enc); c = cache(type, enc);
if (c == null) { if (c == null) {
...@@ -279,9 +280,9 @@ public class Converters { ...@@ -279,9 +280,9 @@ public class Converters {
* not yet defined, return a class that implements the fallback default * not yet defined, return a class that implements the fallback default
* encoding, which is just ISO 8859-1. * encoding, which is just ISO 8859-1.
*/ */
private static Class getDefaultConverterClass(int type) { private static Class<?> getDefaultConverterClass(int type) {
boolean fillCache = false; boolean fillCache = false;
Class c; Class<?> c;
/* First check the class cache */ /* First check the class cache */
c = cache(type, DEFAULT_NAME); c = cache(type, DEFAULT_NAME);
...@@ -325,7 +326,7 @@ public class Converters { ...@@ -325,7 +326,7 @@ public class Converters {
* encoding cannot be determined. * encoding cannot be determined.
*/ */
static Object newDefaultConverter(int type) { static Object newDefaultConverter(int type) {
Class c; Class<?> c;
synchronized (lock) { synchronized (lock) {
c = getDefaultConverterClass(type); c = getDefaultConverterClass(type);
} }
......
...@@ -671,6 +671,10 @@ public class FtpClient extends sun.net.ftp.FtpClient { ...@@ -671,6 +671,10 @@ public class FtpClient extends sun.net.ftp.FtpClient {
} }
if (!issueCommand(cmd)) { if (!issueCommand(cmd)) {
s.close(); s.close();
if (getLastReplyCode() == FtpReplyCode.FILE_UNAVAILABLE) {
// Ensure backward compatibility
throw new FileNotFoundException(cmd);
}
throw new sun.net.ftp.FtpProtocolException(cmd + ":" + getResponseString(), getLastReplyCode()); throw new sun.net.ftp.FtpProtocolException(cmd + ":" + getResponseString(), getLastReplyCode());
} }
return s; return s;
...@@ -688,7 +692,16 @@ public class FtpClient extends sun.net.ftp.FtpClient { ...@@ -688,7 +692,16 @@ public class FtpClient extends sun.net.ftp.FtpClient {
Socket clientSocket; Socket clientSocket;
if (passiveMode) { if (passiveMode) {
return openPassiveDataConnection(cmd); try {
return openPassiveDataConnection(cmd);
} catch (sun.net.ftp.FtpProtocolException e) {
// If Passive mode failed, fall back on PORT
// Otherwise throw exception
String errmsg = e.getMessage();
if (!errmsg.startsWith("PASV") && !errmsg.startsWith("EPSV")) {
throw e;
}
}
} }
ServerSocket portSocket; ServerSocket portSocket;
InetAddress myAddress; InetAddress myAddress;
......
...@@ -48,23 +48,23 @@ public class AbstractCharsetProvider ...@@ -48,23 +48,23 @@ public class AbstractCharsetProvider
/* Maps canonical names to class names /* Maps canonical names to class names
*/ */
private Map classMap private Map<String,String> classMap
= new TreeMap(ASCIICaseInsensitiveComparator.CASE_INSENSITIVE_ORDER); = new TreeMap<>(ASCIICaseInsensitiveComparator.CASE_INSENSITIVE_ORDER);
/* Maps alias names to canonical names /* Maps alias names to canonical names
*/ */
private Map aliasMap private Map<String,String> aliasMap
= new TreeMap(ASCIICaseInsensitiveComparator.CASE_INSENSITIVE_ORDER); = new TreeMap<>(ASCIICaseInsensitiveComparator.CASE_INSENSITIVE_ORDER);
/* Maps canonical names to alias-name arrays /* Maps canonical names to alias-name arrays
*/ */
private Map aliasNameMap private Map<String,String[]> aliasNameMap
= new TreeMap(ASCIICaseInsensitiveComparator.CASE_INSENSITIVE_ORDER); = new TreeMap<>(ASCIICaseInsensitiveComparator.CASE_INSENSITIVE_ORDER);
/* Maps canonical names to soft references that hold cached instances /* Maps canonical names to soft references that hold cached instances
*/ */
private Map cache private Map<String,SoftReference<Charset>> cache
= new TreeMap(ASCIICaseInsensitiveComparator.CASE_INSENSITIVE_ORDER); = new TreeMap<>(ASCIICaseInsensitiveComparator.CASE_INSENSITIVE_ORDER);
private String packagePrefix; private String packagePrefix;
...@@ -79,13 +79,13 @@ public class AbstractCharsetProvider ...@@ -79,13 +79,13 @@ public class AbstractCharsetProvider
/* Add an entry to the given map, but only if no mapping yet exists /* Add an entry to the given map, but only if no mapping yet exists
* for the given name. * for the given name.
*/ */
private static void put(Map m, String name, Object value) { private static <K,V> void put(Map<K,V> m, K name, V value) {
if (!m.containsKey(name)) if (!m.containsKey(name))
m.put(name, value); m.put(name, value);
} }
private static void remove(Map m, String name) { private static <K,V> void remove(Map<K,V> m, K name) {
Object x = m.remove(name); V x = m.remove(name);
assert (x != null); assert (x != null);
} }
...@@ -116,22 +116,22 @@ public class AbstractCharsetProvider ...@@ -116,22 +116,22 @@ public class AbstractCharsetProvider
protected void init() { } protected void init() { }
private String canonicalize(String charsetName) { private String canonicalize(String charsetName) {
String acn = (String)aliasMap.get(charsetName); String acn = aliasMap.get(charsetName);
return (acn != null) ? acn : charsetName; return (acn != null) ? acn : charsetName;
} }
private Charset lookup(String csn) { private Charset lookup(String csn) {
// Check cache first // Check cache first
SoftReference sr = (SoftReference)cache.get(csn); SoftReference<Charset> sr = cache.get(csn);
if (sr != null) { if (sr != null) {
Charset cs = (Charset)sr.get(); Charset cs = sr.get();
if (cs != null) if (cs != null)
return cs; return cs;
} }
// Do we even support this charset? // Do we even support this charset?
String cln = (String)classMap.get(csn); String cln = classMap.get(csn);
if (cln == null) if (cln == null)
return null; return null;
...@@ -139,12 +139,12 @@ public class AbstractCharsetProvider ...@@ -139,12 +139,12 @@ public class AbstractCharsetProvider
// Instantiate the charset and cache it // Instantiate the charset and cache it
try { try {
Class c = Class.forName(packagePrefix + "." + cln, Class<?> c = Class.forName(packagePrefix + "." + cln,
true, true,
this.getClass().getClassLoader()); this.getClass().getClassLoader());
Charset cs = (Charset)c.newInstance(); Charset cs = (Charset)c.newInstance();
cache.put(csn, new SoftReference(cs)); cache.put(csn, new SoftReference<Charset>(cs));
return cs; return cs;
} catch (ClassNotFoundException x) { } catch (ClassNotFoundException x) {
return null; return null;
...@@ -164,21 +164,21 @@ public class AbstractCharsetProvider ...@@ -164,21 +164,21 @@ public class AbstractCharsetProvider
public final Iterator<Charset> charsets() { public final Iterator<Charset> charsets() {
final ArrayList ks; final ArrayList<String> ks;
synchronized (this) { synchronized (this) {
init(); init();
ks = new ArrayList(classMap.keySet()); ks = new ArrayList<>(classMap.keySet());
} }
return new Iterator<Charset>() { return new Iterator<Charset>() {
Iterator i = ks.iterator(); Iterator<String> i = ks.iterator();
public boolean hasNext() { public boolean hasNext() {
return i.hasNext(); return i.hasNext();
} }
public Charset next() { public Charset next() {
String csn = (String)i.next(); String csn = i.next();
return lookup(csn); return lookup(csn);
} }
...@@ -191,7 +191,7 @@ public class AbstractCharsetProvider ...@@ -191,7 +191,7 @@ public class AbstractCharsetProvider
public final String[] aliases(String charsetName) { public final String[] aliases(String charsetName) {
synchronized (this) { synchronized (this) {
init(); init();
return (String[])aliasNameMap.get(charsetName); return aliasNameMap.get(charsetName);
} }
} }
......
/* /*
* Portions Copyright 2000-2005 Sun Microsystems, Inc. All Rights Reserved. * Portions Copyright 2000-2010 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -49,7 +49,7 @@ import java.io.InputStream; ...@@ -49,7 +49,7 @@ import java.io.InputStream;
public class KeyTabInputStream extends KrbDataInputStream implements KeyTabConstants { public class KeyTabInputStream extends KrbDataInputStream implements KeyTabConstants {
boolean DEBUG = Krb5.DEBUG; boolean DEBUG = Krb5.DEBUG;
static int index; int index;
public KeyTabInputStream(InputStream is) { public KeyTabInputStream(InputStream is) {
super(is); super(is);
......
...@@ -40,6 +40,8 @@ import static sun.security.pkcs11.TemplateManager.*; ...@@ -40,6 +40,8 @@ import static sun.security.pkcs11.TemplateManager.*;
import sun.security.pkcs11.wrapper.*; import sun.security.pkcs11.wrapper.*;
import static sun.security.pkcs11.wrapper.PKCS11Constants.*; import static sun.security.pkcs11.wrapper.PKCS11Constants.*;
import sun.security.util.DerValue;
/** /**
* EC KeyFactory implemenation. * EC KeyFactory implemenation.
* *
...@@ -201,7 +203,16 @@ final class P11ECKeyFactory extends P11KeyFactory { ...@@ -201,7 +203,16 @@ final class P11ECKeyFactory extends P11KeyFactory {
private PublicKey generatePublic(ECPoint point, ECParameterSpec params) throws PKCS11Exception { private PublicKey generatePublic(ECPoint point, ECParameterSpec params) throws PKCS11Exception {
byte[] encodedParams = ECParameters.encodeParameters(params); byte[] encodedParams = ECParameters.encodeParameters(params);
byte[] encodedPoint = ECParameters.encodePoint(point, params.getCurve()); byte[] encodedPoint = null;
DerValue pkECPoint = new DerValue(DerValue.tag_OctetString,
ECParameters.encodePoint(point, params.getCurve()));
try {
encodedPoint = pkECPoint.toByteArray();
} catch (IOException e) {
throw new IllegalArgumentException("Could not DER encode point", e);
}
CK_ATTRIBUTE[] attributes = new CK_ATTRIBUTE[] { CK_ATTRIBUTE[] attributes = new CK_ATTRIBUTE[] {
new CK_ATTRIBUTE(CKA_CLASS, CKO_PUBLIC_KEY), new CK_ATTRIBUTE(CKA_CLASS, CKO_PUBLIC_KEY),
new CK_ATTRIBUTE(CKA_KEY_TYPE, CKK_EC), new CK_ATTRIBUTE(CKA_KEY_TYPE, CKK_EC),
......
...@@ -45,6 +45,8 @@ import sun.security.internal.interfaces.TlsMasterSecret; ...@@ -45,6 +45,8 @@ import sun.security.internal.interfaces.TlsMasterSecret;
import sun.security.pkcs11.wrapper.*; import sun.security.pkcs11.wrapper.*;
import static sun.security.pkcs11.wrapper.PKCS11Constants.*; import static sun.security.pkcs11.wrapper.PKCS11Constants.*;
import sun.security.util.DerValue;
/** /**
* Key implementation classes. * Key implementation classes.
* *
...@@ -998,10 +1000,18 @@ abstract class P11Key implements Key { ...@@ -998,10 +1000,18 @@ abstract class P11Key implements Key {
}; };
fetchAttributes(attributes); fetchAttributes(attributes);
try { try {
params = P11ECKeyFactory.decodeParameters
(attributes[1].getByteArray());
DerValue wECPoint = new DerValue(attributes[0].getByteArray());
if (wECPoint.getTag() != DerValue.tag_OctetString)
throw new IOException("Unexpected tag: " +
wECPoint.getTag());
params = P11ECKeyFactory.decodeParameters params = P11ECKeyFactory.decodeParameters
(attributes[1].getByteArray()); (attributes[1].getByteArray());
w = P11ECKeyFactory.decodePoint w = P11ECKeyFactory.decodePoint
(attributes[0].getByteArray(), params.getCurve()); (wECPoint.getDataBytes(), params.getCurve());
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException("Could not parse key values", e); throw new RuntimeException("Could not parse key values", e);
} }
......
/* /*
* Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1997-2010 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -77,6 +77,7 @@ import sun.security.x509.*; ...@@ -77,6 +77,7 @@ import sun.security.x509.*;
import static java.security.KeyStore.*; import static java.security.KeyStore.*;
import static sun.security.tools.KeyTool.Command.*; import static sun.security.tools.KeyTool.Command.*;
import static sun.security.tools.KeyTool.Option.*;
/** /**
* This tool manages keystores. * This tool manages keystores.
...@@ -150,77 +151,77 @@ public final class KeyTool { ...@@ -150,77 +151,77 @@ public final class KeyTool {
enum Command { enum Command {
CERTREQ("Generates a certificate request", CERTREQ("Generates a certificate request",
"-alias", "-sigalg", "-file", "-keypass", "-keystore", ALIAS, SIGALG, FILEOUT, KEYPASS, KEYSTORE,
"-storepass", "-storetype", "-providername", "-providerclass", STOREPASS, STORETYPE, PROVIDERNAME, PROVIDERCLASS,
"-providerarg", "-providerpath", "-v", "-protected"), PROVIDERARG, PROVIDERPATH, V, PROTECTED),
CHANGEALIAS("Changes an entry's alias", CHANGEALIAS("Changes an entry's alias",
"-alias", "-destalias", "-keypass", "-keystore", "-storepass", ALIAS, DESTALIAS, KEYPASS, KEYSTORE, STOREPASS,
"-storetype", "-providername", "-providerclass", "-providerarg", STORETYPE, PROVIDERNAME, PROVIDERCLASS, PROVIDERARG,
"-providerpath", "-v", "-protected"), PROVIDERPATH, V, PROTECTED),
DELETE("Deletes an entry", DELETE("Deletes an entry",
"-alias", "-keystore", "-storepass", "-storetype", ALIAS, KEYSTORE, STOREPASS, STORETYPE,
"-providername", "-providerclass", "-providerarg", PROVIDERNAME, PROVIDERCLASS, PROVIDERARG,
"-providerpath", "-v", "-protected"), PROVIDERPATH, V, PROTECTED),
EXPORTCERT("Exports certificate", EXPORTCERT("Exports certificate",
"-rfc", "-alias", "-file", "-keystore", "-storepass", RFC, ALIAS, FILEOUT, KEYSTORE, STOREPASS,
"-storetype", "-providername", "-providerclass", "-providerarg", STORETYPE, PROVIDERNAME, PROVIDERCLASS, PROVIDERARG,
"-providerpath", "-v", "-protected"), PROVIDERPATH, V, PROTECTED),
GENKEYPAIR("Generates a key pair", GENKEYPAIR("Generates a key pair",
"-alias", "-keyalg", "-keysize", "-sigalg", "-destalias", ALIAS, KEYALG, KEYSIZE, SIGALG, DESTALIAS,
"-startdate", "-ext", "-validity", "-keypass", "-keystore", STARTDATE, EXT, VALIDITY, KEYPASS, KEYSTORE,
"-storepass", "-storetype", "-providername", "-providerclass", STOREPASS, STORETYPE, PROVIDERNAME, PROVIDERCLASS,
"-providerarg", "-providerpath", "-v", "-protected"), PROVIDERARG, PROVIDERPATH, V, PROTECTED),
GENSECKEY("Generates a secret key", GENSECKEY("Generates a secret key",
"-alias", "-keypass", "-keyalg", "-keysize", "-keystore", ALIAS, KEYPASS, KEYALG, KEYSIZE, KEYSTORE,
"-storepass", "-storetype", "-providername", "-providerclass", STOREPASS, STORETYPE, PROVIDERNAME, PROVIDERCLASS,
"-providerarg", "-providerpath", "-v", "-protected"), PROVIDERARG, PROVIDERPATH, V, PROTECTED),
GENCERT("Generates certificate from a certificate request", GENCERT("Generates certificate from a certificate request",
"-rfc", "-infile", "-outfile", "-alias", "-sigalg", RFC, INFILE, OUTFILE, ALIAS, SIGALG,
"-startdate", "-ext", "-validity", "-keypass", "-keystore", STARTDATE, EXT, VALIDITY, KEYPASS, KEYSTORE,
"-storepass", "-storetype", "-providername", "-providerclass", STOREPASS, STORETYPE, PROVIDERNAME, PROVIDERCLASS,
"-providerarg", "-providerpath", "-v", "-protected"), PROVIDERARG, PROVIDERPATH, V, PROTECTED),
IDENTITYDB("Imports entries from a JDK 1.1.x-style identity database", IDENTITYDB("Imports entries from a JDK 1.1.x-style identity database",
"-file", "-storetype", "-keystore", "-storepass", "-providername", FILEIN, STORETYPE, KEYSTORE, STOREPASS, PROVIDERNAME,
"-providerclass", "-providerarg", "-providerpath", "-v"), PROVIDERCLASS, PROVIDERARG, PROVIDERPATH, V),
IMPORTCERT("Imports a certificate or a certificate chain", IMPORTCERT("Imports a certificate or a certificate chain",
"-noprompt", "-trustcacerts", "-protected", "-alias", "-file", NOPROMPT, TRUSTCACERTS, PROTECTED, ALIAS, FILEIN,
"-keypass", "-keystore", "-storepass", "-storetype", KEYPASS, KEYSTORE, STOREPASS, STORETYPE,
"-providername", "-providerclass", "-providerarg", PROVIDERNAME, PROVIDERCLASS, PROVIDERARG,
"-providerpath", "-v"), PROVIDERPATH, V),
IMPORTKEYSTORE("Imports one or all entries from another keystore", IMPORTKEYSTORE("Imports one or all entries from another keystore",
"-srckeystore", "-destkeystore", "-srcstoretype", SRCKEYSTORE, DESTKEYSTORE, SRCSTORETYPE,
"-deststoretype", "-srcstorepass", "-deststorepass", DESTSTORETYPE, SRCSTOREPASS, DESTSTOREPASS,
"-srcprotected", "-srcprovidername", "-destprovidername", SRCPROTECTED, SRCPROVIDERNAME, DESTPROVIDERNAME,
"-srcalias", "-destalias", "-srckeypass", "-destkeypass", SRCALIAS, DESTALIAS, SRCKEYPASS, DESTKEYPASS,
"-noprompt", "-providerclass", "-providerarg", "-providerpath", NOPROMPT, PROVIDERCLASS, PROVIDERARG, PROVIDERPATH,
"-v"), V),
KEYCLONE("Clones a key entry", KEYCLONE("Clones a key entry",
"-alias", "-destalias", "-keypass", "-new", "-storetype", ALIAS, DESTALIAS, KEYPASS, NEW, STORETYPE,
"-keystore", "-storepass", "-providername", "-providerclass", KEYSTORE, STOREPASS, PROVIDERNAME, PROVIDERCLASS,
"-providerarg", "-providerpath", "-v"), PROVIDERARG, PROVIDERPATH, V),
KEYPASSWD("Changes the key password of an entry", KEYPASSWD("Changes the key password of an entry",
"-alias", "-keypass", "-new", "-keystore", "-storepass", ALIAS, KEYPASS, NEW, KEYSTORE, STOREPASS,
"-storetype", "-providername", "-providerclass", "-providerarg", STORETYPE, PROVIDERNAME, PROVIDERCLASS, PROVIDERARG,
"-providerpath", "-v"), PROVIDERPATH, V),
LIST("Lists entries in a keystore", LIST("Lists entries in a keystore",
"-rfc", "-alias", "-keystore", "-storepass", "-storetype", RFC, ALIAS, KEYSTORE, STOREPASS, STORETYPE,
"-providername", "-providerclass", "-providerarg", PROVIDERNAME, PROVIDERCLASS, PROVIDERARG,
"-providerpath", "-v", "-protected"), PROVIDERPATH, V, PROTECTED),
PRINTCERT("Prints the content of a certificate", PRINTCERT("Prints the content of a certificate",
"-rfc", "-file", "-sslserver", "-jarfile", "-v"), RFC, FILEIN, SSLSERVER, JARFILE, V),
PRINTCERTREQ("Prints the content of a certificate request", PRINTCERTREQ("Prints the content of a certificate request",
"-file", "-v"), FILEIN, V),
SELFCERT("Generates a self-signed certificate", SELFCERT("Generates a self-signed certificate",
"-alias", "-sigalg", "-dname", "-startdate", "-validity", "-keypass", ALIAS, SIGALG, DNAME, STARTDATE, VALIDITY, KEYPASS,
"-storetype", "-keystore", "-storepass", "-providername", STORETYPE, KEYSTORE, STOREPASS, PROVIDERNAME,
"-providerclass", "-providerarg", "-providerpath", "-v"), PROVIDERCLASS, PROVIDERARG, PROVIDERPATH, V),
STOREPASSWD("Changes the store password of a keystore", STOREPASSWD("Changes the store password of a keystore",
"-new", "-keystore", "-storepass", "-storetype", "-providername", NEW, KEYSTORE, STOREPASS, STORETYPE, PROVIDERNAME,
"-providerclass", "-providerarg", "-providerpath", "-v"); PROVIDERCLASS, PROVIDERARG, PROVIDERPATH, V);
final String description; final String description;
final String[] options; final Option[] options;
Command(String d, String... o) { Command(String d, Option... o) {
description = d; description = d;
options = o; options = o;
} }
...@@ -230,50 +231,60 @@ public final class KeyTool { ...@@ -230,50 +231,60 @@ public final class KeyTool {
} }
}; };
private static String[][] options = { enum Option {
// name, arg, description ALIAS("alias", "<alias>", "alias name of the entry to process"),
{"-alias", "<alias>", "alias name of the entry to process"}, DESTALIAS("destalias", "<destalias>", "destination alias"),
{"-destalias", "<destalias>", "destination alias"}, DESTKEYPASS("destkeypass", "<arg>", "destination key password"),
{"-destkeypass", "<arg>", "destination key password"}, DESTKEYSTORE("destkeystore", "<destkeystore>", "destination keystore name"),
{"-destkeystore", "<destkeystore>", "destination keystore name"}, DESTPROTECTED("destprotected", null, "destination keystore password protected"),
{"-destprotected", null, "destination keystore password protected"}, DESTPROVIDERNAME("destprovidername", "<destprovidername>", "destination keystore provider name"),
{"-destprovidername", "<destprovidername>", "destination keystore provider name"}, DESTSTOREPASS("deststorepass", "<arg>", "destination keystore password"),
{"-deststorepass", "<arg>", "destination keystore password"}, DESTSTORETYPE("deststoretype", "<deststoretype>", "destination keystore type"),
{"-deststoretype", "<deststoretype>", "destination keystore type"}, DNAME("dname", "<dname>", "distinguished name"),
{"-dname", "<dname>", "distinguished name"}, EXT("ext", "<value>", "X.509 extension"),
{"-ext", "<value>", "X.509 extension"}, FILEOUT("file", "<filename>", "output file name"),
{"-file", "<filename>", "output file name"}, FILEIN("file", "<filename>", "input file name"),
{"-file", "<filename>", "input file name"}, INFILE("infile", "<filename>", "input file name"),
{"-infile", "<filename>", "input file name"}, KEYALG("keyalg", "<keyalg>", "key algorithm name"),
{"-keyalg", "<keyalg>", "key algorithm name"}, KEYPASS("keypass", "<arg>", "key password"),
{"-keypass", "<arg>", "key password"}, KEYSIZE("keysize", "<keysize>", "key bit size"),
{"-keysize", "<keysize>", "key bit size"}, KEYSTORE("keystore", "<keystore>", "keystore name"),
{"-keystore", "<keystore>", "keystore name"}, NEW("new", "<arg>", "new password"),
{"-new", "<arg>", "new password"}, NOPROMPT("noprompt", null, "do not prompt"),
{"-noprompt", null, "do not prompt"}, OUTFILE("outfile", "<filename>", "output file name"),
{"-outfile", "<filename>", "output file name"}, PROTECTED("protected", null, "password through protected mechanism"),
{"-protected", null, "password through protected mechanism"}, PROVIDERARG("providerarg", "<arg>", "provider argument"),
{"-providerarg", "<arg>", "provider argument"}, PROVIDERCLASS("providerclass", "<providerclass>", "provider class name"),
{"-providerclass", "<providerclass>", "provider class name"}, PROVIDERNAME("providername", "<providername>", "provider name"),
{"-providername", "<providername>", "provider name"}, PROVIDERPATH("providerpath", "<pathlist>", "provider classpath"),
{"-providerpath", "<pathlist>", "provider classpath"}, RFC("rfc", null, "output in RFC style"),
{"-rfc", null, "output in RFC style"}, SIGALG("sigalg", "<sigalg>", "signature algorithm name"),
{"-sigalg", "<sigalg>", "signature algorithm name"}, SRCALIAS("srcalias", "<srcalias>", "source alias"),
{"-srcalias", "<srcalias>", "source alias"}, SRCKEYPASS("srckeypass", "<arg>", "source keystore password"),
{"-srckeypass", "<arg>", "source keystore password"}, SRCKEYSTORE("srckeystore", "<srckeystore>", "source keystore name"),
{"-srckeystore", "<srckeystore>", "source keystore name"}, SRCPROTECTED("srcprotected", null, "source keystore password protected"),
{"-srcprotected", null, "source keystore password protected"}, SRCPROVIDERNAME("srcprovidername", "<srcprovidername>", "source keystore provider name"),
{"-srcprovidername", "<srcprovidername>", "source keystore provider name"}, SRCSTOREPASS("srcstorepass", "<arg>", "source keystore password"),
{"-srcstorepass", "<arg>", "source keystore password"}, SRCSTORETYPE("srcstoretype", "<srcstoretype>", "source keystore type"),
{"-srcstoretype", "<srcstoretype>", "source keystore type"}, SSLSERVER("sslserver", "<server[:port]>", "SSL server host and port"),
{"-sslserver", "<server[:port]>", "SSL server host and port"}, JARFILE("jarfile", "<filename>", "signed jar file"),
{"-jarfile", "<filename>", "signed jar file"}, STARTDATE("startdate", "<startdate>", "certificate validity start date/time"),
{"-startdate", "<startdate>", "certificate validity start date/time"}, STOREPASS("storepass", "<arg>", "keystore password"),
{"-storepass", "<arg>", "keystore password"}, STORETYPE("storetype", "<storetype>", "keystore type"),
{"-storetype", "<storetype>", "keystore type"}, TRUSTCACERTS("trustcacerts", null, "trust certificates from cacerts"),
{"-trustcacerts", null, "trust certificates from cacerts"}, V("v", null, "verbose output"),
{"-v", null, "verbose output"}, VALIDITY("validity", "<valDays>", "validity number of days");
{"-validity", "<valDays>", "validity number of days"},
final String name, arg, description;
Option(String name, String arg, String description) {
this.name = name;
this.arg = arg;
this.description = description;
}
@Override
public String toString() {
return "-" + name;
}
}; };
private static final Class[] PARAM_STRING = { String.class }; private static final Class[] PARAM_STRING = { String.class };
...@@ -344,10 +355,10 @@ public final class KeyTool { ...@@ -344,10 +355,10 @@ public final class KeyTool {
// Check if the last option needs an arg // Check if the last option needs an arg
if (i == args.length - 1) { if (i == args.length - 1) {
for (String[] option: options) { for (Option option: Option.values()) {
// Only options with an arg need to be checked // Only options with an arg need to be checked
if (collator.compare(flags, option[0]) == 0) { if (collator.compare(flags, option.toString()) == 0) {
if (option[1] != null) errorNeedArgument(flags); if (option.arg != null) errorNeedArgument(flags);
break; break;
} }
} }
...@@ -3792,21 +3803,13 @@ public final class KeyTool { ...@@ -3792,21 +3803,13 @@ public final class KeyTool {
// Length of left side of options list // Length of left side of options list
int lenLeft = 0; int lenLeft = 0;
for (int j=0; j<left.length; j++) { for (int j=0; j<left.length; j++) {
for (String[] opt: options) { Option opt = command.options[j];
if (collator.compare(opt[0], command.options[j]) == 0) { left[j] = opt.toString();
left[j] = opt[0]; if (opt.arg != null) left[j] += " " + opt.arg;
if (opt[1] != null) left[j] += " " + opt[1]; if (left[j].length() > lenLeft) {
if (left[j].length() > lenLeft) { lenLeft = left[j].length();
lenLeft = left[j].length();
}
right[j] = rb.getString(opt[2]);
found = true;
break;
}
}
if (!found) {
throw new RuntimeException("ERROR: CANNOT FIND " + command.options[j]);
} }
right[j] = rb.getString(opt.description);
} }
for (int j=0; j<left.length; j++) { for (int j=0; j<left.length; j++) {
System.err.printf(" %-" + lenLeft + "s %s\n", System.err.printf(" %-" + lenLeft + "s %s\n",
......
#
# Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# - Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# - Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# - Neither the name of Sun Microsystems nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
compiledMethodLoad
This agent library traces CompiledMethodLoad events along
with the HotSpot specific compile_info parameter.
You can use this agent library as follows:
java -agentlib:compiledMethodLoad ...
See ${JAVA_HOME}/demo/jvmti/index.html for help running and building agents.
/*
* Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* - Neither the name of Sun Microsystems nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "jni.h"
#include "jvmti.h"
#include "jvmticmlr.h"
#include "agent_util.h"
/* Global static data */
static char OUTPUT_FILE[] = "compiledMethodLoad.txt";
static FILE *fp;
static jvmtiEnv *jvmti;
static jrawMonitorID lock;
/* print a jvmtiCompiledMethodLoadDummyRecord */
void
print_dummy_record(jvmtiCompiledMethodLoadDummyRecord* record,
jvmtiEnv* jvmti, FILE* fp) {
if (record != NULL) {
fprintf(fp, "Dummy record detected containing message: %s\n",
(char *)record->message);
}
}
/* print the specified stack frames */
void
print_stack_frames(PCStackInfo* record, jvmtiEnv *jvmti, FILE* fp) {
if (record != NULL && record->methods != NULL) {
int i;
for (i = 0; i < record->numstackframes; i++) {
jvmtiError err;
char* method_name = NULL;
char* class_name = NULL;
char* method_signature = NULL;
char* class_signature = NULL;
char* generic_ptr_method = NULL;
char* generic_ptr_class = NULL;
jmethodID id;
jclass declaringclassptr;
id = record->methods[i];
err = (*jvmti)->GetMethodDeclaringClass(jvmti, id,
&declaringclassptr);
check_jvmti_error(jvmti, err, "get method declaring class");
err = (*jvmti)->GetClassSignature(jvmti, declaringclassptr,
&class_signature, &generic_ptr_class);
check_jvmti_error(jvmti, err, "get class signature");
err = (*jvmti)->GetMethodName(jvmti, id, &method_name,
&method_signature, &generic_ptr_method);
check_jvmti_error(jvmti, err, "get method name");
fprintf(fp, "%s::%s %s %s @%d\n", class_signature, method_name,
method_signature,
generic_ptr_method == NULL ? "" : generic_ptr_method,
record->bcis[i]);
if (method_name != NULL) {
err = (*jvmti)->Deallocate(jvmti, (unsigned char*)method_name);
check_jvmti_error(jvmti, err, "deallocate method_name");
}
if (method_signature != NULL) {
err = (*jvmti)->Deallocate(jvmti,
(unsigned char*)method_signature);
check_jvmti_error(jvmti, err, "deallocate method_signature");
}
if (generic_ptr_method != NULL) {
err = (*jvmti)->Deallocate(jvmti,
(unsigned char*)generic_ptr_method);
check_jvmti_error(jvmti, err, "deallocate generic_ptr_method");
}
if (class_name != NULL) {
err = (*jvmti)->Deallocate(jvmti, (unsigned char*)class_name);
check_jvmti_error(jvmti, err, "deallocate class_name");
}
if (class_signature != NULL) {
err = (*jvmti)->Deallocate(jvmti,
(unsigned char*)class_signature);
check_jvmti_error(jvmti, err, "deallocate class_signature");
}
if (generic_ptr_class != NULL) {
err = (*jvmti)->Deallocate(jvmti,
(unsigned char*)generic_ptr_class);
check_jvmti_error(jvmti, err, "deallocate generic_ptr_class");
}
}
}
}
/* print a jvmtiCompiledMethodLoadInlineRecord */
void
print_inline_info_record(jvmtiCompiledMethodLoadInlineRecord* record,
jvmtiEnv *jvmti, FILE* fp) {
if (record != NULL && record->pcinfo != NULL) {
int numpcs = record->numpcs;
int i;
for (i = 0; i < numpcs; i++) {
PCStackInfo pcrecord = (record->pcinfo[i]);
fprintf(fp, "PcDescriptor(pc=0x%lx):\n", (jint)(pcrecord.pc));
print_stack_frames(&pcrecord, jvmti, fp);
}
}
}
/* decode kind of CompiledMethodLoadRecord and print */
void
print_records(jvmtiCompiledMethodLoadRecordHeader* list, jvmtiEnv *jvmti,
FILE* fp)
{
jvmtiCompiledMethodLoadRecordHeader* curr = list;
fprintf(fp, "\nPrinting PC Descriptors\n\n");
while (curr != NULL) {
switch (curr->kind) {
case JVMTI_CMLR_DUMMY:
print_dummy_record((jvmtiCompiledMethodLoadDummyRecord *)curr,
jvmti, fp);
break;
case JVMTI_CMLR_INLINE_INFO:
print_inline_info_record(
(jvmtiCompiledMethodLoadInlineRecord *)curr, jvmti, fp);
break;
default:
fprintf(fp, "Warning: unrecognized record: kind=%d\n", curr->kind);
break;
}
curr = (jvmtiCompiledMethodLoadRecordHeader *)curr->next;
}
}
/* Callback for JVMTI_EVENT_COMPILED_METHOD_LOAD */
void JNICALL
compiled_method_load(jvmtiEnv *jvmti, jmethodID method, jint code_size,
const void* code_addr, jint map_length, const jvmtiAddrLocationMap* map,
const void* compile_info)
{
jvmtiError err;
char* name = NULL;
char* signature = NULL;
char* generic_ptr = NULL;
jvmtiCompiledMethodLoadRecordHeader* pcs;
err = (*jvmti)->RawMonitorEnter(jvmti, lock);
check_jvmti_error(jvmti, err, "raw monitor enter");
err = (*jvmti)->GetMethodName(jvmti, method, &name, &signature,
&generic_ptr);
check_jvmti_error(jvmti, err, "get method name");
fprintf(fp, "\nCompiled method load event\n");
fprintf(fp, "Method name %s %s %s\n\n", name, signature,
generic_ptr == NULL ? "" : generic_ptr);
pcs = (jvmtiCompiledMethodLoadRecordHeader *)compile_info;
if (pcs != NULL) {
print_records(pcs, jvmti, fp);
}
if (name != NULL) {
err = (*jvmti)->Deallocate(jvmti, (unsigned char*)name);
check_jvmti_error(jvmti, err, "deallocate name");
}
if (signature != NULL) {
err = (*jvmti)->Deallocate(jvmti, (unsigned char*)signature);
check_jvmti_error(jvmti, err, "deallocate signature");
}
if (generic_ptr != NULL) {
err = (*jvmti)->Deallocate(jvmti, (unsigned char*)generic_ptr);
check_jvmti_error(jvmti, err, "deallocate generic_ptr");
}
err = (*jvmti)->RawMonitorExit(jvmti, lock);
check_jvmti_error(jvmti, err, "raw monitor exit");
}
/* Agent_OnLoad() is called first, we prepare for a COMPILED_METHOD_LOAD
* event here.
*/
JNIEXPORT jint JNICALL
Agent_OnLoad(JavaVM *vm, char *options, void *reserved)
{
jint rc;
jvmtiError err;
jvmtiCapabilities capabilities;
jvmtiEventCallbacks callbacks;
fp = fopen(OUTPUT_FILE, "w");
if (fp == NULL) {
fatal_error("ERROR: %s: Unable to create output file\n", OUTPUT_FILE);
return -1;
}
/* Get JVMTI environment */
rc = (*vm)->GetEnv(vm, (void **)&jvmti, JVMTI_VERSION);
if (rc != JNI_OK) {
fatal_error(
"ERROR: Unable to create jvmtiEnv, GetEnv failed, error=%d\n", rc);
return -1;
}
/* add JVMTI capabilities */
memset(&capabilities,0, sizeof(capabilities));
capabilities.can_generate_compiled_method_load_events = 1;
err = (*jvmti)->AddCapabilities(jvmti, &capabilities);
check_jvmti_error(jvmti, err, "add capabilities");
/* set JVMTI callbacks for events */
memset(&callbacks, 0, sizeof(callbacks));
callbacks.CompiledMethodLoad = &compiled_method_load;
err = (*jvmti)->SetEventCallbacks(jvmti, &callbacks, sizeof(callbacks));
check_jvmti_error(jvmti, err, "set event callbacks");
/* enable JVMTI events */
err = (*jvmti)->SetEventNotificationMode(jvmti, JVMTI_ENABLE,
JVMTI_EVENT_COMPILED_METHOD_LOAD, NULL);
check_jvmti_error(jvmti, err, "set event notify");
/* create coordination monitor */
err = (*jvmti)->CreateRawMonitor(jvmti, "agent lock", &lock);
check_jvmti_error(jvmti, err, "create raw monitor");
return 0;
}
/* Agent_OnUnload() is called last */
JNIEXPORT void JNICALL
Agent_OnUnload(JavaVM *vm)
{
}
#
# Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# - Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# - Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# - Neither the name of Sun Microsystems nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
########################################################################
#
# Sample GNU Makefile for building JVMTI Demo compiledMethodLoad
#
# Example uses:
# gnumake JDK=<java_home> OSNAME=solaris [OPT=true] [LIBARCH=sparc]
# gnumake JDK=<java_home> OSNAME=solaris [OPT=true] [LIBARCH=sparcv9]
# gnumake JDK=<java_home> OSNAME=linux [OPT=true]
# gnumake JDK=<java_home> OSNAME=win32 [OPT=true]
#
########################################################################
# Source lists
LIBNAME=compiledMethodLoad
SOURCES=compiledMethodLoad.c ../agent_util/agent_util.c
# Solaris Sun C Compiler Version 5.5
ifeq ($(OSNAME), solaris)
# Sun Solaris Compiler options needed
COMMON_FLAGS=-mt -KPIC
# Options that help find errors
COMMON_FLAGS+= -Xa -v -xstrconst -xc99=%none
# Check LIBARCH for any special compiler options
LIBARCH=$(shell uname -p)
ifeq ($(LIBARCH), sparc)
COMMON_FLAGS+=-xarch=v8 -xregs=no%appl
endif
ifeq ($(LIBARCH), sparcv9)
COMMON_FLAGS+=-xarch=v9 -xregs=no%appl
endif
ifeq ($(OPT), true)
CFLAGS=-xO2 $(COMMON_FLAGS)
else
CFLAGS=-g $(COMMON_FLAGS)
endif
# Object files needed to create library
OBJECTS=$(SOURCES:%.c=%.o)
# Library name and options needed to build it
LIBRARY=lib$(LIBNAME).so
LDFLAGS=-z defs -ztext
# Libraries we are dependent on
LIBRARIES= -lc
# Building a shared library
LINK_SHARED=$(LINK.c) -G -o $@
endif
# Linux GNU C Compiler
ifeq ($(OSNAME), linux)
# GNU Compiler options needed to build it
COMMON_FLAGS=-fno-strict-aliasing -fPIC -fno-omit-frame-pointer
# Options that help find errors
COMMON_FLAGS+= -W -Wall -Wno-unused -Wno-parentheses
ifeq ($(OPT), true)
CFLAGS=-O2 $(COMMON_FLAGS)
else
CFLAGS=-g $(COMMON_FLAGS)
endif
# Object files needed to create library
OBJECTS=$(SOURCES:%.c=%.o)
# Library name and options needed to build it
LIBRARY=lib$(LIBNAME).so
LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc -mimpure-text
# Libraries we are dependent on
LIBRARIES=-lc
# Building a shared library
LINK_SHARED=$(LINK.c) -shared -o $@
endif
# Windows Microsoft C/C++ Optimizing Compiler Version 12
ifeq ($(OSNAME), win32)
CC=cl
# Compiler options needed to build it
COMMON_FLAGS=-Gy -DWIN32
# Options that help find errors
COMMON_FLAGS+=-W0 -WX
ifeq ($(OPT), true)
CFLAGS= -Ox -Op -Zi $(COMMON_FLAGS)
else
CFLAGS= -Od -Zi $(COMMON_FLAGS)
endif
# Object files needed to create library
OBJECTS=$(SOURCES:%.c=%.obj)
# Library name and options needed to build it
LIBRARY=$(LIBNAME).dll
LDFLAGS=
# Libraries we are dependent on
LIBRARIES=
# Building a shared library
LINK_SHARED=link -dll -out:$@
endif
# Common -I options
CFLAGS += -I.
CFLAGS += -I../agent_util
CFLAGS += -I$(JDK)/include -I$(JDK)/include/$(OSNAME)
# Default rule
all: $(LIBRARY)
# Build native library
$(LIBRARY): $(OBJECTS)
$(LINK_SHARED) $(OBJECTS) $(LIBRARIES)
# Cleanup the built bits
clean:
rm -f $(LIBRARY) $(OBJECTS)
# Simple tester
test: all
LD_LIBRARY_PATH=`pwd` $(JDK)/bin/java -agentlib:$(LIBNAME) -version
# Compilation rule only needed on Windows
ifeq ($(OSNAME), win32)
%.obj: %.c
$(COMPILE.c) $<
endif
...@@ -99,6 +99,13 @@ version string supplied in the jvmti.h file, with the version ...@@ -99,6 +99,13 @@ version string supplied in the jvmti.h file, with the version
number supplied by the VM at runtime. number supplied by the VM at runtime.
</li> </li>
<li>
<A HREF="compiledMethodLoad">compiledMethodLoad</A>
<br>
This is a small agent that traces CompiledMethodLoad events along
with the HotSpot specific compile_info parameter.
</li>
<li> <li>
<A HREF="mtrace">mtrace</A> <A HREF="mtrace">mtrace</A>
<br> <br>
......
/*
* Copyright 2010 Sun Microsystems, Inc. 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. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* This header file defines the data structures sent by the VM
* through the JVMTI CompiledMethodLoad callback function via the
* "void * compile_info" parameter. The memory pointed to by the
* compile_info parameter may not be referenced after returning from
* the CompiledMethodLoad callback. These are VM implementation
* specific data structures that may evolve in future releases. A
* JVMTI agent should interpret a non-NULL compile_info as a pointer
* to a region of memory containing a list of records. In a typical
* usage scenario, a JVMTI agent would cast each record to a
* jvmtiCompiledMethodLoadRecordHeader, a struct that represents
* arbitrary information. This struct contains a kind field to indicate
* the kind of information being passed, and a pointer to the next
* record. If the kind field indicates inlining information, then the
* agent would cast the record to a jvmtiCompiledMethodLoadInlineRecord.
* This record contains an array of PCStackInfo structs, which indicate
* for every pc address what are the methods on the invocation stack.
* The "methods" and "bcis" fields in each PCStackInfo struct specify a
* 1-1 mapping between these inlined methods and their bytecode indices.
* This can be used to derive the proper source lines of the inlined
* methods.
*/
#ifndef _JVMTI_CMLR_H_
#define _JVMTI_CMLR_H_
enum {
JVMTI_CMLR_MAJOR_VERSION_1 = 0x00000001,
JVMTI_CMLR_MINOR_VERSION_0 = 0x00000000,
JVMTI_CMLR_MAJOR_VERSION = 0x00000001,
JVMTI_CMLR_MINOR_VERSION = 0x00000000
/*
* This comment is for the "JDK import from HotSpot" sanity check:
* version: 1.0.0
*/
};
typedef enum {
JVMTI_CMLR_DUMMY = 1,
JVMTI_CMLR_INLINE_INFO = 2
} jvmtiCMLRKind;
/*
* Record that represents arbitrary information passed through JVMTI
* CompiledMethodLoadEvent void pointer.
*/
typedef struct _jvmtiCompiledMethodLoadRecordHeader {
jvmtiCMLRKind kind; /* id for the kind of info passed in the record */
jint majorinfoversion; /* major and minor info version values. Init'ed */
jint minorinfoversion; /* to current version value in jvmtiExport.cpp. */
struct _jvmtiCompiledMethodLoadRecordHeader* next;
} jvmtiCompiledMethodLoadRecordHeader;
/*
* Record that gives information about the methods on the compile-time
* stack at a specific pc address of a compiled method. Each element in
* the methods array maps to same element in the bcis array.
*/
typedef struct _PCStackInfo {
void* pc; /* the pc address for this compiled method */
jint numstackframes; /* number of methods on the stack */
jmethodID* methods; /* array of numstackframes method ids */
jint* bcis; /* array of numstackframes bytecode indices */
} PCStackInfo;
/*
* Record that contains inlining information for each pc address of
* an nmethod.
*/
typedef struct _jvmtiCompiledMethodLoadInlineRecord {
jvmtiCompiledMethodLoadRecordHeader header; /* common header for casting */
jint numpcs; /* number of pc descriptors in this nmethod */
PCStackInfo* pcinfo; /* array of numpcs pc descriptors */
} jvmtiCompiledMethodLoadInlineRecord;
/*
* Dummy record used to test that we can pass records with different
* information through the void pointer provided that they can be cast
* to a jvmtiCompiledMethodLoadRecordHeader.
*/
typedef struct _jvmtiCompiledMethodLoadDummyRecord {
jvmtiCompiledMethodLoadRecordHeader header; /* common header for casting */
char message[50];
} jvmtiCompiledMethodLoadDummyRecord;
#endif
...@@ -162,10 +162,11 @@ NET_SockaddrToInetAddress(JNIEnv *env, struct sockaddr *him, int *port) { ...@@ -162,10 +162,11 @@ NET_SockaddrToInetAddress(JNIEnv *env, struct sockaddr *him, int *port) {
JNIEXPORT jint JNICALL JNIEXPORT jint JNICALL
NET_SockaddrEqualsInetAddress(JNIEnv *env, struct sockaddr *him, jobject iaObj) NET_SockaddrEqualsInetAddress(JNIEnv *env, struct sockaddr *him, jobject iaObj)
{ {
jint family = (*env)->GetIntField(env, iaObj, ia_familyID) == IPv4? jint family = AF_INET;
AF_INET : AF_INET6;
#ifdef AF_INET6 #ifdef AF_INET6
family = (*env)->GetIntField(env, iaObj, ia_familyID) == IPv4?
AF_INET : AF_INET6;
if (him->sa_family == AF_INET6) { if (him->sa_family == AF_INET6) {
#ifdef WIN32 #ifdef WIN32
struct SOCKADDR_IN6 *him6 = (struct SOCKADDR_IN6 *)him; struct SOCKADDR_IN6 *him6 = (struct SOCKADDR_IN6 *)him;
......
...@@ -46,11 +46,6 @@ ...@@ -46,11 +46,6 @@
#define HENT_BUF_SIZE 1024 #define HENT_BUF_SIZE 1024
#define BIG_HENT_BUF_SIZE 10240 /* a jumbo-sized one */ #define BIG_HENT_BUF_SIZE 10240 /* a jumbo-sized one */
#ifndef __GLIBC__
/* gethostname() is in libc.so but I can't find a header file for it */
extern int gethostname(char *buf, int buf_len);
#endif
/************************************************************************ /************************************************************************
* Inet4AddressImpl * Inet4AddressImpl
*/ */
......
...@@ -49,10 +49,6 @@ ...@@ -49,10 +49,6 @@
#define NI_MAXHOST 1025 #define NI_MAXHOST 1025
#endif #endif
#ifndef __GLIBC__
/* gethostname() is in libc.so but I can't find a header file for it */
extern int gethostname(char *buf, int buf_len);
#endif
/************************************************************************ /************************************************************************
* Inet6AddressImpl * Inet6AddressImpl
...@@ -360,8 +356,6 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this, ...@@ -360,8 +356,6 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
} }
} }
#endif /* AF_INET6 */
cleanupAndReturn: cleanupAndReturn:
{ {
struct addrinfo *iterator, *tmp; struct addrinfo *iterator, *tmp;
...@@ -374,7 +368,6 @@ cleanupAndReturn: ...@@ -374,7 +368,6 @@ cleanupAndReturn:
JNU_ReleaseStringPlatformChars(env, host, hostname); JNU_ReleaseStringPlatformChars(env, host, hostname);
} }
#ifdef AF_INET6
if (NET_addrtransAvailable()) if (NET_addrtransAvailable())
(*freeaddrinfo_ptr)(res); (*freeaddrinfo_ptr)(res);
#endif /* AF_INET6 */ #endif /* AF_INET6 */
......
...@@ -253,8 +253,12 @@ JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByInetAddress0 ...@@ -253,8 +253,12 @@ JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByInetAddress0
(JNIEnv *env, jclass cls, jobject iaObj) { (JNIEnv *env, jclass cls, jobject iaObj) {
netif *ifs, *curr; netif *ifs, *curr;
#ifdef AF_INET6
int family = (*env)->GetIntField(env, iaObj, ni_iafamilyID) == IPv4? int family = (*env)->GetIntField(env, iaObj, ni_iafamilyID) == IPv4?
AF_INET : AF_INET6; AF_INET : AF_INET6;
#else
int family = AF_INET;
#endif
jobject obj = NULL; jobject obj = NULL;
jboolean match = JNI_FALSE; jboolean match = JNI_FALSE;
...@@ -1528,6 +1532,7 @@ JNIEXPORT jint JNICALL Java_java_net_NetworkInterface_getMTU0(JNIEnv *env, jclas ...@@ -1528,6 +1532,7 @@ JNIEXPORT jint JNICALL Java_java_net_NetworkInterface_getMTU0(JNIEnv *env, jclas
strcpy((caddr_t)&(lifr.lifr_name), name_utf); strcpy((caddr_t)&(lifr.lifr_name), name_utf);
if (ioctl(sock, SIOCGLIFMTU, (caddr_t)&lifr) >= 0) { if (ioctl(sock, SIOCGLIFMTU, (caddr_t)&lifr) >= 0) {
ret = lifr.lifr_mtu; ret = lifr.lifr_mtu;
#ifdef AF_INET6
} else { } else {
/* Try wIth an IPv6 socket in case the interface has only IPv6 addresses assigned to it */ /* Try wIth an IPv6 socket in case the interface has only IPv6 addresses assigned to it */
close(sock); close(sock);
...@@ -1547,6 +1552,12 @@ JNIEXPORT jint JNICALL Java_java_net_NetworkInterface_getMTU0(JNIEnv *env, jclas ...@@ -1547,6 +1552,12 @@ JNIEXPORT jint JNICALL Java_java_net_NetworkInterface_getMTU0(JNIEnv *env, jclas
"IOCTL failed"); "IOCTL failed");
} }
} }
#else
} else {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"IOCTL failed");
}
#endif
#endif #endif
close(sock); close(sock);
} }
......
...@@ -605,8 +605,12 @@ Java_java_net_PlainDatagramSocketImpl_peek(JNIEnv *env, jobject this, ...@@ -605,8 +605,12 @@ Java_java_net_PlainDatagramSocketImpl_peek(JNIEnv *env, jobject this,
} }
iaObj = NET_SockaddrToInetAddress(env, (struct sockaddr *)&remote_addr, &port); iaObj = NET_SockaddrToInetAddress(env, (struct sockaddr *)&remote_addr, &port);
#ifdef AF_INET6
family = (*env)->GetIntField(env, iaObj, ia_familyID) == IPv4? family = (*env)->GetIntField(env, iaObj, ia_familyID) == IPv4?
AF_INET : AF_INET6; AF_INET : AF_INET6;
#else
family = AF_INET;
#endif
if (family == AF_INET) { /* this api can't handle IPV6 addresses */ if (family == AF_INET) { /* this api can't handle IPV6 addresses */
int address = (*env)->GetIntField(env, iaObj, ia_addressID); int address = (*env)->GetIntField(env, iaObj, ia_addressID);
(*env)->SetIntField(env, addressObj, ia_addressID, address); (*env)->SetIntField(env, addressObj, ia_addressID, address);
...@@ -812,9 +816,9 @@ Java_java_net_PlainDatagramSocketImpl_receive0(JNIEnv *env, jobject this, ...@@ -812,9 +816,9 @@ Java_java_net_PlainDatagramSocketImpl_receive0(JNIEnv *env, jobject this,
jboolean retry; jboolean retry;
#ifdef __linux__ #ifdef __linux__
jboolean connected = JNI_FALSE; jboolean connected = JNI_FALSE;
jobject connectedAddress; jobject connectedAddress = NULL;
jint connectedPort; jint connectedPort = 0;
jlong prevTime; jlong prevTime = 0;
#endif #endif
if (IS_NULL(fdObj)) { if (IS_NULL(fdObj)) {
...@@ -1186,6 +1190,7 @@ static void mcast_set_if_by_if_v4(JNIEnv *env, jobject this, int fd, jobject val ...@@ -1186,6 +1190,7 @@ static void mcast_set_if_by_if_v4(JNIEnv *env, jobject this, int fd, jobject val
* Set outgoing multicast interface designated by a NetworkInterface. * Set outgoing multicast interface designated by a NetworkInterface.
* Throw exception if failed. * Throw exception if failed.
*/ */
#ifdef AF_INET6
static void mcast_set_if_by_if_v6(JNIEnv *env, jobject this, int fd, jobject value) { static void mcast_set_if_by_if_v6(JNIEnv *env, jobject this, int fd, jobject value) {
static jfieldID ni_indexID; static jfieldID ni_indexID;
int index; int index;
...@@ -1222,6 +1227,7 @@ static void mcast_set_if_by_if_v6(JNIEnv *env, jobject this, int fd, jobject val ...@@ -1222,6 +1227,7 @@ static void mcast_set_if_by_if_v6(JNIEnv *env, jobject this, int fd, jobject val
} }
#endif #endif
} }
#endif /* AF_INET6 */
/* /*
* Set outgoing multicast interface designated by an InetAddress. * Set outgoing multicast interface designated by an InetAddress.
...@@ -1251,6 +1257,7 @@ static void mcast_set_if_by_addr_v4(JNIEnv *env, jobject this, int fd, jobject v ...@@ -1251,6 +1257,7 @@ static void mcast_set_if_by_addr_v4(JNIEnv *env, jobject this, int fd, jobject v
* Set outgoing multicast interface designated by an InetAddress. * Set outgoing multicast interface designated by an InetAddress.
* Throw exception if failed. * Throw exception if failed.
*/ */
#ifdef AF_INET6
static void mcast_set_if_by_addr_v6(JNIEnv *env, jobject this, int fd, jobject value) { static void mcast_set_if_by_addr_v6(JNIEnv *env, jobject this, int fd, jobject value) {
static jclass ni_class; static jclass ni_class;
if (ni_class == NULL) { if (ni_class == NULL) {
...@@ -1272,6 +1279,7 @@ static void mcast_set_if_by_addr_v6(JNIEnv *env, jobject this, int fd, jobject v ...@@ -1272,6 +1279,7 @@ static void mcast_set_if_by_addr_v6(JNIEnv *env, jobject this, int fd, jobject v
mcast_set_if_by_if_v6(env, this, fd, value); mcast_set_if_by_if_v6(env, this, fd, value);
} }
#endif
/* /*
* Sets the multicast interface. * Sets the multicast interface.
...@@ -1307,6 +1315,7 @@ static void setMulticastInterface(JNIEnv *env, jobject this, int fd, ...@@ -1307,6 +1315,7 @@ static void setMulticastInterface(JNIEnv *env, jobject this, int fd,
/* /*
* value is an InetAddress. * value is an InetAddress.
*/ */
#ifdef AF_INET6
#ifdef __solaris__ #ifdef __solaris__
if (ipv6_available()) { if (ipv6_available()) {
mcast_set_if_by_addr_v6(env, this, fd, value); mcast_set_if_by_addr_v6(env, this, fd, value);
...@@ -1320,12 +1329,16 @@ static void setMulticastInterface(JNIEnv *env, jobject this, int fd, ...@@ -1320,12 +1329,16 @@ static void setMulticastInterface(JNIEnv *env, jobject this, int fd,
mcast_set_if_by_addr_v6(env, this, fd, value); mcast_set_if_by_addr_v6(env, this, fd, value);
} }
#endif #endif
#else
mcast_set_if_by_addr_v4(env, this, fd, value);
#endif /* AF_INET6 */
} }
if (opt == java_net_SocketOptions_IP_MULTICAST_IF2) { if (opt == java_net_SocketOptions_IP_MULTICAST_IF2) {
/* /*
* value is a NetworkInterface. * value is a NetworkInterface.
*/ */
#ifdef AF_INET6
#ifdef __solaris__ #ifdef __solaris__
if (ipv6_available()) { if (ipv6_available()) {
mcast_set_if_by_if_v6(env, this, fd, value); mcast_set_if_by_if_v6(env, this, fd, value);
...@@ -1339,6 +1352,9 @@ static void setMulticastInterface(JNIEnv *env, jobject this, int fd, ...@@ -1339,6 +1352,9 @@ static void setMulticastInterface(JNIEnv *env, jobject this, int fd,
mcast_set_if_by_if_v6(env, this, fd, value); mcast_set_if_by_if_v6(env, this, fd, value);
} }
#endif #endif
#else
mcast_set_if_by_if_v4(env, this, fd, value);
#endif /* AF_INET6 */
} }
} }
...@@ -1368,6 +1384,7 @@ static void mcast_set_loop_v4(JNIEnv *env, jobject this, int fd, jobject value) ...@@ -1368,6 +1384,7 @@ static void mcast_set_loop_v4(JNIEnv *env, jobject this, int fd, jobject value)
/* /*
* Enable/disable local loopback of multicast datagrams. * Enable/disable local loopback of multicast datagrams.
*/ */
#ifdef AF_INET6
static void mcast_set_loop_v6(JNIEnv *env, jobject this, int fd, jobject value) { static void mcast_set_loop_v6(JNIEnv *env, jobject this, int fd, jobject value) {
jclass cls; jclass cls;
jfieldID fid; jfieldID fid;
...@@ -1397,12 +1414,14 @@ static void mcast_set_loop_v6(JNIEnv *env, jobject this, int fd, jobject value) ...@@ -1397,12 +1414,14 @@ static void mcast_set_loop_v6(JNIEnv *env, jobject this, int fd, jobject value)
} }
#endif #endif
} }
#endif /* AF_INET6 */
/* /*
* Sets the multicast loopback mode. * Sets the multicast loopback mode.
*/ */
static void setMulticastLoopbackMode(JNIEnv *env, jobject this, int fd, static void setMulticastLoopbackMode(JNIEnv *env, jobject this, int fd,
jint opt, jobject value) { jint opt, jobject value) {
#ifdef AF_INET6
#ifdef __solaris__ #ifdef __solaris__
if (ipv6_available()) { if (ipv6_available()) {
mcast_set_loop_v6(env, this, fd, value); mcast_set_loop_v6(env, this, fd, value);
...@@ -1416,6 +1435,9 @@ static void setMulticastLoopbackMode(JNIEnv *env, jobject this, int fd, ...@@ -1416,6 +1435,9 @@ static void setMulticastLoopbackMode(JNIEnv *env, jobject this, int fd,
mcast_set_loop_v6(env, this, fd, value); mcast_set_loop_v6(env, this, fd, value);
} }
#endif #endif
#else
mcast_set_loop_v4(env, this, fd, value);
#endif /* AF_INET6 */
} }
/* /*
...@@ -1838,7 +1860,7 @@ Java_java_net_PlainDatagramSocketImpl_socketGetOption(JNIEnv *env, jobject this, ...@@ -1838,7 +1860,7 @@ Java_java_net_PlainDatagramSocketImpl_socketGetOption(JNIEnv *env, jobject this,
if (opt == java_net_SocketOptions_SO_BINDADDR) { if (opt == java_net_SocketOptions_SO_BINDADDR) {
/* find out local IP address */ /* find out local IP address */
SOCKADDR him; SOCKADDR him;
int len = 0; socklen_t len = 0;
int port; int port;
jobject iaObj; jobject iaObj;
...@@ -1941,6 +1963,7 @@ static void setTTL(JNIEnv *env, int fd, jint ttl) { ...@@ -1941,6 +1963,7 @@ static void setTTL(JNIEnv *env, int fd, jint ttl) {
/* /*
* Set hops limit for a socket. Throw exception if failed. * Set hops limit for a socket. Throw exception if failed.
*/ */
#ifdef AF_INET6
static void setHopLimit(JNIEnv *env, int fd, jint ttl) { static void setHopLimit(JNIEnv *env, int fd, jint ttl) {
int ittl = (int)ttl; int ittl = (int)ttl;
if (JVM_SetSockOpt(fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, if (JVM_SetSockOpt(fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS,
...@@ -1949,6 +1972,7 @@ static void setHopLimit(JNIEnv *env, int fd, jint ttl) { ...@@ -1949,6 +1972,7 @@ static void setHopLimit(JNIEnv *env, int fd, jint ttl) {
"Error setting socket option"); "Error setting socket option");
} }
} }
#endif
/* /*
* Class: java_net_PlainDatagramSocketImpl * Class: java_net_PlainDatagramSocketImpl
...@@ -1971,6 +1995,7 @@ Java_java_net_PlainDatagramSocketImpl_setTimeToLive(JNIEnv *env, jobject this, ...@@ -1971,6 +1995,7 @@ Java_java_net_PlainDatagramSocketImpl_setTimeToLive(JNIEnv *env, jobject this,
fd = (*env)->GetIntField(env, fdObj, IO_fd_fdID); fd = (*env)->GetIntField(env, fdObj, IO_fd_fdID);
} }
/* setsockopt to be correct ttl */ /* setsockopt to be correct ttl */
#ifdef AF_INET6
#ifdef __solaris__ #ifdef __solaris__
if (ipv6_available()) { if (ipv6_available()) {
setHopLimit(env, fd, ttl); setHopLimit(env, fd, ttl);
...@@ -1986,7 +2011,10 @@ Java_java_net_PlainDatagramSocketImpl_setTimeToLive(JNIEnv *env, jobject this, ...@@ -1986,7 +2011,10 @@ Java_java_net_PlainDatagramSocketImpl_setTimeToLive(JNIEnv *env, jobject this,
(*env)->SetIntField(env, this, pdsi_ttlID, ttl); (*env)->SetIntField(env, this, pdsi_ttlID, ttl);
} }
} }
#endif #endif // __linux__
#else
setTTL(env, fd, ttl);
#endif /* AF_INET6 */
} }
/* /*
......
...@@ -319,8 +319,6 @@ jint IPv6_supported() ...@@ -319,8 +319,6 @@ jint IPv6_supported()
#endif /* __solaris */ #endif /* __solaris */
#endif /* AF_INET6 */
/* /*
* OK we may have the stack available in the kernel, * OK we may have the stack available in the kernel,
* we should also check if the APIs are available. * we should also check if the APIs are available.
...@@ -354,6 +352,7 @@ jint IPv6_supported() ...@@ -354,6 +352,7 @@ jint IPv6_supported()
close(fd); close(fd);
return JNI_TRUE; return JNI_TRUE;
#endif /* AF_INET6 */
} }
void void
......
...@@ -133,7 +133,7 @@ extern jint NET_Wait(JNIEnv *env, jint fd, jint flags, jint timeout); ...@@ -133,7 +133,7 @@ extern jint NET_Wait(JNIEnv *env, jint fd, jint flags, jint timeout);
#else #else
#define SOCKADDR union { struct sockaddr_in him4 } #define SOCKADDR union { struct sockaddr_in him4; }
#define SOCKADDR_LEN sizeof(SOCKADDR) #define SOCKADDR_LEN sizeof(SOCKADDR)
#endif #endif
......
...@@ -44,7 +44,11 @@ JNIEXPORT void JNICALL ...@@ -44,7 +44,11 @@ JNIEXPORT void JNICALL
Java_sun_net_spi_SdpProvider_convert(JNIEnv *env, jclass cls, jint fd) Java_sun_net_spi_SdpProvider_convert(JNIEnv *env, jclass cls, jint fd)
{ {
#ifdef PROTO_SDP #ifdef PROTO_SDP
#ifdef AF_INET6
int domain = ipv6_available() ? AF_INET6 : AF_INET; int domain = ipv6_available() ? AF_INET6 : AF_INET;
#else
int domain = AF_INET;
#endif
int s = socket(domain, SOCK_STREAM, PROTO_SDP); int s = socket(domain, SOCK_STREAM, PROTO_SDP);
if (s < 0) { if (s < 0) {
JNU_ThrowIOExceptionWithLastError(env, "socket"); JNU_ThrowIOExceptionWithLastError(env, "socket");
......
...@@ -124,6 +124,7 @@ struct my_group_source_req { ...@@ -124,6 +124,7 @@ struct my_group_source_req {
* Copy IPv6 group, interface index, and IPv6 source address * Copy IPv6 group, interface index, and IPv6 source address
* into group_source_req structure. * into group_source_req structure.
*/ */
#ifdef AF_INET6
static void initGroupSourceReq(JNIEnv* env, jbyteArray group, jint index, static void initGroupSourceReq(JNIEnv* env, jbyteArray group, jint index,
jbyteArray source, struct my_group_source_req* req) jbyteArray source, struct my_group_source_req* req)
{ {
...@@ -139,7 +140,7 @@ static void initGroupSourceReq(JNIEnv* env, jbyteArray group, jint index, ...@@ -139,7 +140,7 @@ static void initGroupSourceReq(JNIEnv* env, jbyteArray group, jint index,
sin6->sin6_family = AF_INET6; sin6->sin6_family = AF_INET6;
COPY_INET6_ADDRESS(env, source, (jbyte*)&(sin6->sin6_addr)); COPY_INET6_ADDRESS(env, source, (jbyte*)&(sin6->sin6_addr));
} }
#endif
JNIEXPORT void JNICALL JNIEXPORT void JNICALL
Java_sun_nio_ch_Net_initIDs(JNIEnv *env, jclass clazz) Java_sun_nio_ch_Net_initIDs(JNIEnv *env, jclass clazz)
...@@ -159,7 +160,11 @@ Java_sun_nio_ch_Net_socket0(JNIEnv *env, jclass cl, jboolean preferIPv6, ...@@ -159,7 +160,11 @@ Java_sun_nio_ch_Net_socket0(JNIEnv *env, jclass cl, jboolean preferIPv6,
{ {
int fd; int fd;
int type = (stream ? SOCK_STREAM : SOCK_DGRAM); int type = (stream ? SOCK_STREAM : SOCK_DGRAM);
#ifdef AF_INET6
int domain = (ipv6_available() && preferIPv6) ? AF_INET6 : AF_INET; int domain = (ipv6_available() && preferIPv6) ? AF_INET6 : AF_INET;
#else
int domain = AF_INET;
#endif
fd = socket(domain, type, 0); fd = socket(domain, type, 0);
if (fd < 0) { if (fd < 0) {
...@@ -176,7 +181,7 @@ Java_sun_nio_ch_Net_socket0(JNIEnv *env, jclass cl, jboolean preferIPv6, ...@@ -176,7 +181,7 @@ Java_sun_nio_ch_Net_socket0(JNIEnv *env, jclass cl, jboolean preferIPv6,
return -1; return -1;
} }
} }
#ifdef __linux__ #if defined(__linux__) && defined(AF_INET6)
/* By default, Linux uses the route default */ /* By default, Linux uses the route default */
if (domain == AF_INET6 && type == SOCK_DGRAM) { if (domain == AF_INET6 && type == SOCK_DGRAM) {
int arg = 1; int arg = 1;
...@@ -424,6 +429,7 @@ JNIEXPORT jint JNICALL ...@@ -424,6 +429,7 @@ JNIEXPORT jint JNICALL
Java_sun_nio_ch_Net_joinOrDrop6(JNIEnv *env, jobject this, jboolean join, jobject fdo, Java_sun_nio_ch_Net_joinOrDrop6(JNIEnv *env, jobject this, jboolean join, jobject fdo,
jbyteArray group, jint index, jbyteArray source) jbyteArray group, jint index, jbyteArray source)
{ {
#ifdef AF_INET6
struct ipv6_mreq mreq6; struct ipv6_mreq mreq6;
struct my_group_source_req req; struct my_group_source_req req;
int opt, n, optlen; int opt, n, optlen;
...@@ -454,12 +460,17 @@ Java_sun_nio_ch_Net_joinOrDrop6(JNIEnv *env, jobject this, jboolean join, jobjec ...@@ -454,12 +460,17 @@ Java_sun_nio_ch_Net_joinOrDrop6(JNIEnv *env, jobject this, jboolean join, jobjec
handleSocketError(env, errno); handleSocketError(env, errno);
} }
return 0; return 0;
#else
JNU_ThrowInternalError(env, "Should not get here");
return IOS_THROWN;
#endif /* AF_INET6 */
} }
JNIEXPORT jint JNICALL JNIEXPORT jint JNICALL
Java_sun_nio_ch_Net_blockOrUnblock6(JNIEnv *env, jobject this, jboolean block, jobject fdo, Java_sun_nio_ch_Net_blockOrUnblock6(JNIEnv *env, jobject this, jboolean block, jobject fdo,
jbyteArray group, jint index, jbyteArray source) jbyteArray group, jint index, jbyteArray source)
{ {
#ifdef AF_INET6
struct my_group_source_req req; struct my_group_source_req req;
int n; int n;
int opt = (block) ? MCAST_BLOCK_SOURCE : MCAST_UNBLOCK_SOURCE; int opt = (block) ? MCAST_BLOCK_SOURCE : MCAST_UNBLOCK_SOURCE;
...@@ -474,6 +485,10 @@ Java_sun_nio_ch_Net_blockOrUnblock6(JNIEnv *env, jobject this, jboolean block, j ...@@ -474,6 +485,10 @@ Java_sun_nio_ch_Net_blockOrUnblock6(JNIEnv *env, jobject this, jboolean block, j
handleSocketError(env, errno); handleSocketError(env, errno);
} }
return 0; return 0;
#else
JNU_ThrowInternalError(env, "Should not get here");
return IOS_THROWN;
#endif
} }
JNIEXPORT void JNICALL JNIEXPORT void JNICALL
......
...@@ -168,14 +168,18 @@ JNIEXPORT jint JNICALL Java_sun_nio_ch_SctpNet_socket0 ...@@ -168,14 +168,18 @@ JNIEXPORT jint JNICALL Java_sun_nio_ch_SctpNet_socket0
(JNIEnv *env, jclass klass, jboolean oneToOne) { (JNIEnv *env, jclass klass, jboolean oneToOne) {
int fd; int fd;
struct sctp_event_subscribe event; struct sctp_event_subscribe event;
#ifdef AF_INET6
int domain = ipv6_available() ? AF_INET6 : AF_INET;
#else
int domain = AF_INET;
#endif
/* Try to load the socket API extension functions */ /* Try to load the socket API extension functions */
if (!funcsLoaded && !loadSocketExtensionFuncs(env)) { if (!funcsLoaded && !loadSocketExtensionFuncs(env)) {
return 0; return 0;
} }
fd = socket(ipv6_available() ? AF_INET6 : AF_INET, fd = socket(domain, (oneToOne ? SOCK_STREAM : SOCK_SEQPACKET), IPPROTO_SCTP);
(oneToOne ? SOCK_STREAM : SOCK_SEQPACKET), IPPROTO_SCTP);
if (fd < 0) { if (fd < 0) {
return handleSocketError(env, errno); return handleSocketError(env, errno);
......
...@@ -172,7 +172,7 @@ int getAllInterfacesAndAddresses (JNIEnv *env, netif **netifPP) ...@@ -172,7 +172,7 @@ int getAllInterfacesAndAddresses (JNIEnv *env, netif **netifPP)
DWORD ret; DWORD ret;
IP_ADAPTER_ADDRESSES *ptr, *adapters=0; IP_ADAPTER_ADDRESSES *ptr, *adapters=0;
ULONG len=ipinflen, count=0; ULONG len=ipinflen, count=0;
netif *nif=0, *dup_nif, *last=0, *loopif=0; netif *nif=0, *dup_nif, *last=0, *loopif=0, *curr;
int tun=0, net=0; int tun=0, net=0;
*netifPP = 0; *netifPP = 0;
...@@ -197,6 +197,20 @@ int getAllInterfacesAndAddresses (JNIEnv *env, netif **netifPP) ...@@ -197,6 +197,20 @@ int getAllInterfacesAndAddresses (JNIEnv *env, netif **netifPP)
last = nif; last = nif;
} }
// Retrieve IPv4 addresses with the IP Helper API
curr = *netifPP;
while (curr != NULL) {
netaddr *netaddrP;
ret = enumAddresses_win(env, curr, &netaddrP);
if ((*env)->ExceptionOccurred(env)) {
free_netaddr(netaddrP);
return -1;
}
curr->addrs = netaddrP;
curr->naddrs += ret;
curr = curr->next;
}
ret = getAdapters (env, &adapters); ret = getAdapters (env, &adapters);
if (ret != ERROR_SUCCESS) { if (ret != ERROR_SUCCESS) {
goto err; goto err;
...@@ -350,6 +364,14 @@ static int getAddrsFromAdapter(IP_ADAPTER_ADDRESSES *ptr, netaddr **netaddrPP) { ...@@ -350,6 +364,14 @@ static int getAddrsFromAdapter(IP_ADAPTER_ADDRESSES *ptr, netaddr **netaddrPP) {
/* address is only usable if dad state is preferred or deprecated */ /* address is only usable if dad state is preferred or deprecated */
if (uni_addr->DadState == IpDadStateDeprecated || if (uni_addr->DadState == IpDadStateDeprecated ||
uni_addr->DadState == IpDadStatePreferred) { uni_addr->DadState == IpDadStatePreferred) {
sock = uni_addr->Address.lpSockaddr;
// IPv4 addresses already retrieved with enumAddresses_win
if (sock->sa_family == AF_INET) {
uni_addr = uni_addr->Next;
continue;
}
curr = (netaddr *)calloc (1, sizeof (netaddr)); curr = (netaddr *)calloc (1, sizeof (netaddr));
if (curr == 0) { if (curr == 0) {
return -1; return -1;
...@@ -361,15 +383,9 @@ static int getAddrsFromAdapter(IP_ADAPTER_ADDRESSES *ptr, netaddr **netaddrPP) { ...@@ -361,15 +383,9 @@ static int getAddrsFromAdapter(IP_ADAPTER_ADDRESSES *ptr, netaddr **netaddrPP) {
prev->next = curr; prev->next = curr;
} }
prev = curr; prev = curr;
sock = uni_addr->Address.lpSockaddr;
SOCKETADDRESS_COPY (&curr->addr, sock); SOCKETADDRESS_COPY (&curr->addr, sock);
if (prefix != NULL) { if (prefix != NULL) {
curr->mask = (short)prefix->PrefixLength; curr->mask = (short)prefix->PrefixLength;
if (sock->sa_family == AF_INET) {
sock = prefix->Address.lpSockaddr;
SOCKETADDRESS_COPY(&curr->brdcast, sock);
curr->brdcast.him4.sin_addr.s_addr |= htonl((0xffffffff >> curr->mask));
}
prefix = prefix->Next; prefix = prefix->Next;
} }
count ++; count ++;
......
...@@ -28,7 +28,12 @@ ...@@ -28,7 +28,12 @@
* LoginContext * LoginContext
* @author Brad Wetmore * @author Brad Wetmore
* *
* @run main/othervm -Xmx2m TestProviderLeak * @run main/othervm -Xmx2m -XX:OldSize=1m -XX:NewSize=512k TestProviderLeak
*
* The original test invocation is below, but had to use the above
* workaround for bug 6923123.
*
* run main/othervm -Xmx2m TestProviderLeak
*/ */
/* /*
......
/*
* Copyright 2010 Sun Microsystems, Inc. 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.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* @test
* @bug 6580131
* @summary Test jvmti demo compiledMethodLoad
*
* @compile ../DemoRun.java ../Hello.java
* @build CompiledMethodLoadTest
* @run main CompiledMethodLoadTest Hello
*/
public class CompiledMethodLoadTest {
public static void main(String args[]) throws Exception {
DemoRun demo;
/* Run demo that uses JVMTI compiledMethodLoad agent (no options) */
demo = new DemoRun("compiledMethodLoad", "" /* options to compiledMethodLoad */ );
demo.runit(args[0]);
/* Make sure patterns in output look ok */
if (demo.output_contains("ERROR")) {
throw new RuntimeException("Test failed - ERROR seen in output");
}
/* Must be a pass. */
System.out.println("Test passed - cleanly terminated");
}
}
/* /*
* Copyright 2004-2005 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2004-2010 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -43,7 +43,7 @@ public class HeapTrackerTest { ...@@ -43,7 +43,7 @@ public class HeapTrackerTest {
/* Make sure patterns in output look ok */ /* Make sure patterns in output look ok */
if (demo.output_contains("ERROR")) { if (demo.output_contains("ERROR")) {
throw new RuntimeException("Test failed - ERROR seen in oputput"); throw new RuntimeException("Test failed - ERROR seen in output");
} }
/* Must be a pass. */ /* Must be a pass. */
......
/* /*
* Copyright 2004-2005 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2004-2010 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -44,7 +44,7 @@ public class CpuTimesDefineClassTest { ...@@ -44,7 +44,7 @@ public class CpuTimesDefineClassTest {
/* Make sure patterns in output look ok */ /* Make sure patterns in output look ok */
if (hprof.output_contains("ERROR")) { if (hprof.output_contains("ERROR")) {
throw new RuntimeException("Test failed - ERROR seen in oputput"); throw new RuntimeException("Test failed - ERROR seen in output");
} }
/* Must be a pass. */ /* Must be a pass. */
......
/* /*
* Copyright 2004-2005 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2004-2010 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -42,7 +42,7 @@ public class CpuTimesTest { ...@@ -42,7 +42,7 @@ public class CpuTimesTest {
/* Make sure patterns in output look ok */ /* Make sure patterns in output look ok */
if (hprof.output_contains("ERROR")) { if (hprof.output_contains("ERROR")) {
throw new RuntimeException("Test failed - ERROR seen in oputput"); throw new RuntimeException("Test failed - ERROR seen in output");
} }
/* Must be a pass. */ /* Must be a pass. */
......
/* /*
* Copyright 2006 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2006-2010 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -43,7 +43,7 @@ public class MinstTest { ...@@ -43,7 +43,7 @@ public class MinstTest {
/* Make sure patterns in output look ok */ /* Make sure patterns in output look ok */
if (demo.output_contains("ERROR")) { if (demo.output_contains("ERROR")) {
throw new RuntimeException("Test failed - ERROR seen in oputput"); throw new RuntimeException("Test failed - ERROR seen in output");
} }
/* Must be a pass. */ /* Must be a pass. */
......
/* /*
* Copyright 2004-2005 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2004-2010 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -43,7 +43,7 @@ public class TraceJFrame { ...@@ -43,7 +43,7 @@ public class TraceJFrame {
/* Make sure patterns in output look ok */ /* Make sure patterns in output look ok */
if (demo.output_contains("ERROR")) { if (demo.output_contains("ERROR")) {
throw new RuntimeException("Test failed - ERROR seen in oputput"); throw new RuntimeException("Test failed - ERROR seen in output");
} }
/* Must be a pass. */ /* Must be a pass. */
......
...@@ -56,6 +56,7 @@ public class SelectionAutoscrollTest extends Applet { ...@@ -56,6 +56,7 @@ public class SelectionAutoscrollTest extends Applet {
TextArea textArea; TextArea textArea;
Robot robot; Robot robot;
final int desiredSelectionEnd = ('z'-'a'+1)*2; // 52 final int desiredSelectionEnd = ('z'-'a'+1)*2; // 52
final static int SCROLL_DELAY = 10; // ms
public void start () { public void start () {
createObjects(); createObjects();
...@@ -126,6 +127,8 @@ public class SelectionAutoscrollTest extends Applet { ...@@ -126,6 +127,8 @@ public class SelectionAutoscrollTest extends Applet {
moveMouseBelowTextArea( tremble%2!=0 ); moveMouseBelowTextArea( tremble%2!=0 );
Util.waitForIdle( robot ); Util.waitForIdle( robot );
// it is needed to add some small delay on Gnome
waitUntilScrollIsPerformed(robot);
} }
robot.mouseRelease( MouseEvent.BUTTON1_MASK ); robot.mouseRelease( MouseEvent.BUTTON1_MASK );
...@@ -141,9 +144,19 @@ public class SelectionAutoscrollTest extends Applet { ...@@ -141,9 +144,19 @@ public class SelectionAutoscrollTest extends Applet {
void moveMouseBelowTextArea( boolean shift ) { void moveMouseBelowTextArea( boolean shift ) {
Dimension d = textArea.getSize(); Dimension d = textArea.getSize();
Point l = textArea.getLocationOnScreen(); Point l = textArea.getLocationOnScreen();
int x = (int)(l.x+d.width*.5);
int y = (int)(l.y+d.height*1.5); int y = (int)(l.y+d.height*1.5);
if( shift ) y+=15; if( shift ) y+=15;
robot.mouseMove( (int)(l.x+d.width*.5), y ); robot.mouseMove( x, y );
}
void waitUntilScrollIsPerformed(Robot robot) {
try {
Thread.sleep( SCROLL_DELAY );
}
catch( Exception e ) {
throw new RuntimeException( e );
}
} }
void checkResults() { void checkResults() {
......
/*
* Copyright 2010 Sun Microsystems, Inc. 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.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* @test
* @bug 6707289
* @summary InterfaceAddress.getNetworkPrefixLength() does not conform to Javadoc
*/
import java.net.InetAddress;
import java.net.Inet4Address;
import java.net.InterfaceAddress;
import java.net.NetworkInterface;
import java.util.Enumeration;
import static java.lang.System.out;
public class NetworkPrefixLength {
static boolean passed = true;
public static void main(String[] args) throws Exception {
Enumeration<NetworkInterface> nics = NetworkInterface.getNetworkInterfaces();
while (nics.hasMoreElements()) {
NetworkInterface nic = nics.nextElement();
for (InterfaceAddress iaddr : nic.getInterfaceAddresses()) {
boolean valid = checkPrefix(iaddr);
if (!valid) {
passed = false;
debug(nic.getName(), iaddr);
}
}
}
if (!passed)
throw new RuntimeException("Failed: some interfaces have invalid prefix lengths");
}
static boolean checkPrefix(InterfaceAddress iaddr) {
InetAddress addr = iaddr.getAddress();
if (addr instanceof Inet4Address)
return checkIPv4PrefixLength(iaddr.getNetworkPrefixLength());
else
return checkIPv6PrefixLength(iaddr.getNetworkPrefixLength());
}
static boolean checkIPv4PrefixLength(int prefix) {
if (prefix >=0 && prefix <= 32)
return true;
return false;
}
static boolean checkIPv6PrefixLength(int prefix) {
if (prefix >=0 && prefix <= 128)
return true;
return false;
}
static void debug(String nicName, InterfaceAddress iaddr) {
out.println("NIC " + nicName + " has an address with an invalid prefix length:\n" + iaddr);
}
}
/*
* Copyright 2010 Sun Microsystems, Inc. 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.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* @test
* @bug 4422044
* @summary Ensure that keys in available-charset map
* are identical to canonical names
*/
import java.io.*;
import java.nio.*;
import java.nio.charset.*;
import java.util.*;
public class AvailableCharsetNames {
public static void main(String[] args) throws Exception {
Iterator charsetIterator = Charset.availableCharsets().keySet().iterator();
while (charsetIterator.hasNext()) {
String charsetName = (String) charsetIterator.next();
Charset charset = Charset.forName(charsetName);
if (!charset.name().equals(charsetName)) {
throw new Exception("Error: Charset name mismatch - expected "
+ charsetName + ", got " + charset.name());
}
}
}
}
/*
* Copyright 2010 Sun Microsystems, Inc. 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.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* @test
@bug 4626545 4696726
@summary Checks the inter containment relationships between NIO charsets
*/
import java.nio.charset.*;
public class CharsetContainmentTest {
static String[] encodings =
{ "US-ASCII", "UTF-16", "UTF-16BE", "UTF-16LE", "UTF-8",
"windows-1252", "ISO-8859-1", "ISO-8859-15", "ISO-8859-2",
"ISO-8859-3", "ISO-8859-4", "ISO-8859-5", "ISO-8859-6",
"ISO-8859-7", "ISO-8859-8", "ISO-8859-9", "ISO-8859-13",
"ISO-2022-JP", "ISO-2022-KR",
// Temporarily remove ISO-2022-CN-* charsets until full encoder/decoder
// support is added (4673614)
// "x-ISO-2022-CN-CNS", "x-ISO-2022-CN-GB",
"x-ISCII91", "GBK", "GB18030", "Big5",
"x-EUC-TW", "GB2312", "EUC-KR", "x-Johab", "Big5-HKSCS",
"x-MS950-HKSCS", "windows-1251", "windows-1253", "windows-1254",
"windows-1255", "windows-1256", "windows-1257", "windows-1258",
"x-mswin-936", "x-windows-949", "x-windows-950", "windows-31j",
"Shift_JIS", "EUC-JP", "KOI8-R", "TIS-620"
};
static String[][] contains = {
{ "US-ASCII"},
encodings,
encodings,
encodings,
encodings,
{"US-ASCII", "windows-1252"},
{"US-ASCII", "ISO-8859-1"},
{"US-ASCII", "ISO-8859-15"},
{"US-ASCII", "ISO-8859-2"},
{"US-ASCII", "ISO-8859-3"},
{"US-ASCII", "ISO-8859-4"},
{"US-ASCII", "ISO-8859-5"},
{"US-ASCII", "ISO-8859-6"},
{"US-ASCII", "ISO-8859-7"},
{"US-ASCII", "ISO-8859-8"},
{"US-ASCII", "ISO-8859-9"},
{"US-ASCII", "ISO-8859-13"},
{"ISO-2022-JP"},
{"ISO-2022-KR"},
// Temporarily remove ISO-2022-CN-* charsets until full encoder/decoder
// support is added (4673614)
//{"x-ISO-2022-CN-CNS"},
//{"x-ISO-2022-CN-GB"},
{"US-ASCII", "x-ISCII91"},
{"US-ASCII", "GBK"},
encodings,
{"US-ASCII", "Big5"},
{"US-ASCII", "x-EUC-TW"},
{"US-ASCII", "GB2312"},
{"US-ASCII", "EUC-KR"},
{"US-ASCII", "x-Johab"},
{"US-ASCII", "Big5-HKSCS", "Big5"},
{"US-ASCII", "x-MS950-HKSCS", "x-windows-950"},
{"US-ASCII", "windows-1251"},
{"US-ASCII", "windows-1253"},
{"US-ASCII", "windows-1254"},
{"US-ASCII", "windows-1255"},
{"US-ASCII", "windows-1256"},
{"US-ASCII", "windows-1257"},
{"US-ASCII", "windows-1258"},
{"US-ASCII", "x-mswin-936"},
{"US-ASCII", "x-windows-949"},
{"US-ASCII", "x-windows-950"},
{"US-ASCII", "windows-31j" },
{"US-ASCII", "Shift_JIS"},
{"US-ASCII", "EUC-JP"},
{"US-ASCII", "KOI8-R"},
{"US-ASCII", "TIS-620"}};
public static void main(String[] args) throws Exception {
for (int i = 0; i < encodings.length; i++) {
Charset c = Charset.forName(encodings[i]);
for (int j = 0 ; j < contains[i].length; j++) {
if (c.contains(Charset.forName(contains[i][j])))
continue;
else {
throw new Exception ("Error: charset " + encodings[i] +
"doesn't contain " + contains[i][j]);
}
}
}
}
}
/*
* Copyright 2010 Sun Microsystems, Inc. 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.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* @test
* @summary Unit test for charset containment
* @bug 6798572
*/
import java.nio.charset.*;
public class Contains {
static void ck(Charset cs1, Charset cs2, boolean cont) throws Exception {
if ((cs1.contains(cs2)) != cont)
throw new Exception("Wrong answer: "
+ cs1.name() + " contains " + cs2.name());
System.err.println(cs1.name()
+ (cont ? " contains " : " does not contain ")
+ cs2.name());
}
public static void main(String[] args) throws Exception {
Charset us_ascii = Charset.forName("US-ASCII");
Charset iso_8859_1 = Charset.forName("ISO-8859-1");
Charset iso_8859_15 = Charset.forName("ISO-8859-15");
Charset utf_8 = Charset.forName("UTF-8");
Charset utf_16be = Charset.forName("UTF-16BE");
Charset cp1252 = Charset.forName("CP1252");
ck(us_ascii, us_ascii, true);
ck(us_ascii, iso_8859_1, false);
ck(us_ascii, iso_8859_15, false);
ck(us_ascii, utf_8, false);
ck(us_ascii, utf_16be, false);
ck(us_ascii, cp1252, false);
ck(iso_8859_1, us_ascii, true);
ck(iso_8859_1, iso_8859_1, true);
ck(iso_8859_1, iso_8859_15, false);
ck(iso_8859_1, utf_8, false);
ck(iso_8859_1, utf_16be, false);
ck(iso_8859_1, cp1252, false);
ck(iso_8859_15, us_ascii, true);
ck(iso_8859_15, iso_8859_1, false);
ck(iso_8859_15, iso_8859_15, true);
ck(iso_8859_15, utf_8, false);
ck(iso_8859_15, utf_16be, false);
ck(iso_8859_15, cp1252, false);
ck(utf_8, us_ascii, true);
ck(utf_8, iso_8859_1, true);
ck(utf_8, iso_8859_15, true);
ck(utf_8, utf_8, true);
ck(utf_8, utf_16be, true);
ck(utf_8, cp1252, true);
ck(utf_16be, us_ascii, true);
ck(utf_16be, iso_8859_1, true);
ck(utf_16be, iso_8859_15, true);
ck(utf_16be, utf_8, true);
ck(utf_16be, utf_16be, true);
ck(utf_16be, cp1252, true);
ck(cp1252, us_ascii, true);
ck(cp1252, iso_8859_1, false);
ck(cp1252, iso_8859_15, false);
ck(cp1252, utf_8, false);
ck(cp1252, utf_16be, false);
ck(cp1252, cp1252, true);
checkUTF();
}
static void checkUTF() throws Exception {
for (String utfName : utfNames)
for (String csName : charsetNames)
ck(Charset.forName(utfName),
Charset.forName(csName),
true);
}
static String[] utfNames = {"utf-16",
"utf-8",
"utf-16le",
"utf-16be",
"x-utf-16le-bom"};
static String[] charsetNames = {
"US-ASCII",
"UTF-8",
"UTF-16",
"UTF-16BE",
"UTF-16LE",
"x-UTF-16LE-BOM",
"GBK",
"GB18030",
"ISO-8859-1",
"ISO-8859-15",
"ISO-8859-2",
"ISO-8859-3",
"ISO-8859-4",
"ISO-8859-5",
"ISO-8859-6",
"ISO-8859-7",
"ISO-8859-8",
"ISO-8859-9",
"ISO-8859-13",
"JIS_X0201",
"x-JIS0208",
"JIS_X0212-1990",
"GB2312",
"EUC-KR",
"x-EUC-TW",
"EUC-JP",
"x-euc-jp-linux",
"KOI8-R",
"TIS-620",
"x-ISCII91",
"windows-1251",
"windows-1252",
"windows-1253",
"windows-1254",
"windows-1255",
"windows-1256",
"windows-1257",
"windows-1258",
"windows-932",
"x-mswin-936",
"x-windows-949",
"x-windows-950",
"windows-31j",
"Big5",
"Big5-HKSCS",
"x-MS950-HKSCS",
"ISO-2022-JP",
"ISO-2022-KR",
"x-ISO-2022-CN-CNS",
"x-ISO-2022-CN-GB",
"Big5-HKSCS",
"x-Johab",
"Shift_JIS"
};
}
/*
* Copyright 2010 Sun Microsystems, Inc. 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.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
*/
import java.nio.charset.*;
public class Default {
public static void main(String[] args) {
System.out.println(Charset.defaultCharset());
}
}
/*
* Copyright 2010 Sun Microsystems, Inc. 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.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* @test
* @bug 4786884
* @summary Ensure that passing the empty string to Charset methods and
* constructors causes an IllegalArgumentException to be thrown
*
* @build EmptyCharsetName
* @run main EmptyCharsetName
* @run main/othervm -Dsun.nio.cs.bugLevel=1.4 EmptyCharsetName
*/
import java.io.*;
import java.nio.*;
import java.nio.charset.*;
public class EmptyCharsetName {
static boolean compat;
static abstract class Test {
public abstract void go() throws Exception;
Test() throws Exception {
try {
go();
} catch (Exception x) {
if (compat) {
if (x instanceof UnsupportedCharsetException) {
System.err.println("Thrown as expected: " + x);
return;
}
throw new Exception("Exception thrown", x);
}
if (x instanceof IllegalCharsetNameException) {
System.err.println("Thrown as expected: " + x);
return;
}
throw new Exception("Incorrect exception: "
+ x.getClass().getName(),
x);
}
if (!compat)
throw new Exception("No exception thrown");
}
}
public static void main(String[] args) throws Exception {
// If sun.nio.cs.bugLevel == 1.4 then we want the 1.4 behavior
String bl = System.getProperty("sun.nio.cs.bugLevel");
compat = (bl != null && bl.equals("1.4"));
new Test() {
public void go() throws Exception {
Charset.forName("");
}};
new Test() {
public void go() throws Exception {
Charset.isSupported("");
}};
new Test() {
public void go() throws Exception {
new Charset("", new String[] { }) {
public CharsetDecoder newDecoder() {
return null;
}
public CharsetEncoder newEncoder() {
return null;
}
public boolean contains(Charset cs) {
return false;
}
};
}};
}
}
/*
* Copyright 2010 Sun Microsystems, Inc. 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.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* @test
* @summary Unit test for encode/decode convenience methods
*/
import java.nio.*;
import java.nio.charset.*;
public class EncDec {
public static void main(String[] args) throws Exception {
String s = "Hello, world!";
ByteBuffer bb = ByteBuffer.allocate(100);
bb.put(Charset.forName("ISO-8859-15").encode(s)).flip();
String t = Charset.forName("UTF-8").decode(bb).toString();
System.err.println(t);
if (!t.equals(s))
throw new Exception("Mismatch: " + s + " != " + t);
}
}
/*
* Copyright 2010 Sun Microsystems, Inc. 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.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* @test
* @bug 6330020
* @summary Ensure Charset.forName/isSupport throws the correct exception
* if the charset names passed in are illegal.
*/
import java.io.*;
import java.nio.*;
import java.nio.charset.*;
import java.util.*;
public class IllegalCharsetName {
public static void main(String[] args) throws Exception {
String[] illegalNames = {
".",
"_",
":",
"-",
".name",
"_name",
":name",
"-name",
"name*name",
"name?name"
};
for (int i = 0; i < illegalNames.length; i++) {
try {
Charset.forName(illegalNames[i]);
throw new Exception("Charset.forName(): No exception thrown");
} catch (IllegalCharsetNameException x) { //expected
}
try {
Charset.isSupported(illegalNames[i]);
throw new Exception("Charset.isSupported(): No exception thrown");
} catch (IllegalCharsetNameException x) { //expected
}
}
}
}
/*
* Copyright 2010 Sun Microsystems, Inc. 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.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 4777124 6920545
* @summary Verify that all Charset subclasses are available through the API
*/
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.charset.Charset;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.Vector;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import sun.misc.Launcher;
public class NIOCharsetAvailabilityTest {
public static void main(String[] args) throws Exception {
// build the set of all Charset subclasses in the
// two known charset implementation packages
Set charsets = new HashSet();
addCharsets(charsets, "sun.nio.cs");
addCharsets(charsets, "sun.nio.cs.ext");
// remove the charsets that the API says are available
Collection availableCharsets = Charset.availableCharsets().values();
Iterator iter = availableCharsets.iterator();
while (iter.hasNext()) {
charsets.remove(((Charset) iter.next()).getClass());
}
// remove the known pseudo-charsets that serve only to implement
// other charsets, but shouldn't be known to the public
charsets.remove(Class.forName("sun.nio.cs.Unicode"));
charsets.remove(Class.forName("sun.nio.cs.ext.HKSCS"));
charsets.remove(Class.forName("sun.nio.cs.ext.HKSCS_2001"));
charsets.remove(Class.forName("sun.nio.cs.ext.ISO2022"));
charsets.remove(Class.forName("sun.nio.cs.ext.ISO2022_CN_GB"));
charsets.remove(Class.forName("sun.nio.cs.ext.ISO2022_CN_CNS"));
// report the charsets that are implemented but not available
iter = charsets.iterator();
while (iter.hasNext()) {
System.out.println("Unused Charset subclass: " + ((Class) iter.next()).getName());
}
if (charsets.size() > 0) {
throw new RuntimeException();
}
}
private static Vector classPathSegments = new Vector();
private static void addCharsets(Set charsets, final String packageName)
throws Exception {
String classPath =
(String) java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("sun.boot.class.path"));
String s =
(String) java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("java.class.path"));
// Search combined system and application class path
if (s != null && s.length() != 0) {
classPath += File.pathSeparator + s;
}
while (classPath != null && classPath.length() != 0) {
int i = classPath.lastIndexOf(java.io.File.pathSeparatorChar);
String dir = classPath.substring(i + 1);
if (i == -1) {
classPath = null;
} else {
classPath = classPath.substring(0, i);
}
classPathSegments.insertElementAt(dir, 0);
}
// add extensions from the extension class loader
ClassLoader appLoader = Launcher.getLauncher().getClassLoader();
URLClassLoader extLoader = (URLClassLoader) appLoader.getParent();
URL[] urls = extLoader.getURLs();
for (int i = 0; i < urls.length; i++) {
try {
URI uri = new URI(urls[i].toString());
classPathSegments.insertElementAt(uri.getPath(), 0);
} catch (URISyntaxException e) {
}
}
String[] classList = (String[])
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() {
public Object run() {
return getClassList(packageName, "");
}
});
for (int i = 0; i < classList.length; i++) {
try {
Class clazz = Class.forName(packageName + "." + classList[i]);
Class superclazz = clazz.getSuperclass();
while (superclazz != null && !superclazz.equals(Object.class)) {
if (superclazz.equals(Charset.class)) {
charsets.add(clazz);
break;
} else {
superclazz = superclazz.getSuperclass();
}
}
} catch (ClassNotFoundException e) {
}
}
}
private static final char ZIPSEPARATOR = '/';
/**
* Walk through CLASSPATH and find class list from a package.
* The class names start with prefix string
* @param package name, class name prefix
* @return class list in an array of String
*/
private static String[] getClassList(String pkgName, String prefix) {
Vector listBuffer = new Vector();
String packagePath = pkgName.replace('.', File.separatorChar)
+ File.separatorChar;
String zipPackagePath = pkgName.replace('.', ZIPSEPARATOR)
+ ZIPSEPARATOR;
for (int i = 0; i < classPathSegments.size(); i++){
String onePath = (String) classPathSegments.elementAt(i);
File f = new File(onePath);
if (!f.exists())
continue;
if (f.isFile())
scanFile(f, zipPackagePath, listBuffer, prefix);
else if (f.isDirectory()) {
String fullPath;
if (onePath.endsWith(File.separator))
fullPath = onePath + packagePath;
else
fullPath = onePath + File.separatorChar + packagePath;
File dir = new File(fullPath);
if (dir.exists() && dir.isDirectory())
scanDir(dir, listBuffer, prefix);
}
}
String[] classNames = new String[listBuffer.size()];
listBuffer.copyInto(classNames);
return classNames;
}
private static void addClass (String className, Vector listBuffer, String prefix) {
if (className != null && className.startsWith(prefix)
&& !listBuffer.contains(className))
listBuffer.addElement(className);
}
private static String midString(String str, String pre, String suf) {
String midStr;
if (str.startsWith(pre) && str.endsWith(suf))
midStr = str.substring(pre.length(), str.length() - suf.length());
else
midStr = null;
return midStr;
}
private static void scanDir(File dir, Vector listBuffer, String prefix) {
String[] fileList = dir.list();
for (int i = 0; i < fileList.length; i++) {
addClass(midString(fileList[i], "", ".class"), listBuffer, prefix);
}
}
private static void scanFile(File f, String packagePath, Vector listBuffer,
String prefix) {
try {
ZipInputStream zipFile = new ZipInputStream(new FileInputStream(f));
ZipEntry entry;
while ((entry = zipFile.getNextEntry()) != null) {
String eName = entry.getName();
if (eName.startsWith(packagePath)) {
if (eName.endsWith(".class")) {
addClass(midString(eName, packagePath, ".class"),
listBuffer, prefix);
}
}
}
} catch (FileNotFoundException e) {
System.out.println("file not found:" + e);
} catch (IOException e) {
System.out.println("file IO Exception:" + e);
} catch (Exception e) {
System.out.println("Exception:" + e);
}
}
}
/*
* Copyright 2010 Sun Microsystems, Inc. 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.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* @test
* @bug 4448594
* @summary Ensure passing null to Charset.forName throws the correct exception
*/
import java.io.*;
import java.nio.*;
import java.nio.charset.*;
import java.util.*;
public class NullCharsetName {
public static void main(String[] args) throws Exception {
try {
Charset.forName(null);
} catch (Exception x) {
if (x instanceof IllegalArgumentException) {
System.err.println("Thrown as expected: " + x);
return;
}
throw new Exception("Incorrect exception: "
+ x.getClass().getName(),
x);
}
throw new Exception("No exception thrown");
}
}
此差异已折叠。
#!/bin/sh
#
# Copyright 2010 Sun Microsystems, Inc. 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.
#
# 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
# CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions.
#
# @test
# @bug 4772857
# @summary Unit test for Charset.defaultCharset
#
# @build Default
# @run shell default.sh
#
# Command-line usage: sh default.sh [/path/to/build]
if [ -z "$TESTJAVA" ]; then
if [ $# -lt 1 ]; then exit 1; fi
TESTJAVA=$1; shift
TESTSRC=`pwd`
TESTCLASSES=`pwd`
fi
s="`uname -s`"
if [ "$s" != Linux -a "$s" != SunOS ]; then
echo "$s: locale command not supported on this system, skipping..."
exit 0
fi
JAVA=$TESTJAVA/bin/java
tolower() {
echo "$1" | tr '[A-Z]' '[a-z]'
}
go() {
L="$1"
shift
if [ "x`locale -a | grep \^$L\$`" != "x$L" ]; then
echo "$L: Locale not supported, skipping..."
return
fi
ecs="$1"; shift
echo -n "$L: "
cs="`LC_ALL=$L $JAVA -cp $TESTCLASSES Default`"
if [ $? != 0 ]; then
exit 1
elif [ "`tolower $cs`" != "`tolower $ecs`" ]; then
echo "$cs, expected $ecs -- ERROR"
exit 1
else
echo "$cs, as expected"
fi
}
go en_US iso-8859-1
go ja_JP.utf8 utf-8
go tr_TR iso-8859-9
go C us-ascii
if [ "$s" = Linux ]; then
go ja_JP x-euc-jp-linux
go ja_JP.eucjp x-euc-jp-linux
go ja_JP.ujis x-euc-jp-linux
go ja_JP.utf8 utf-8
fi
# Solaris
if [ "$s" = SunOS ]; then
go ja x-eucjp-open
go ja_JP.eucJP x-eucjp-open
go ja_JP.PCK x-PCK
go ja_JP.UTF-8 utf-8
fi
/*
* Copyright 2010 Sun Microsystems, Inc. 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.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* @test
* @bug 4853350
* @summary Ensure that averages do not exceed maxima
*
* @build AverageMax
* @run main AverageMax
* @run main/othervm -Dsun.nio.cs.bugLevel=1.4 AverageMax
*/
import java.nio.*;
import java.nio.charset.*;
public class AverageMax {
static boolean compat;
static abstract class Test {
public abstract void go() throws Exception;
Test() throws Exception {
try {
go();
} catch (Exception x) {
if (compat) {
throw new Exception("Exception thrown", x);
}
if (x instanceof IllegalArgumentException) {
System.err.println("Thrown as expected: " + x);
return;
}
throw new Exception("Incorrect exception: "
+ x.getClass().getName(),
x);
}
if (!compat)
throw new Exception("No exception thrown");
}
}
public static void main(String[] args) throws Exception {
// If sun.nio.cs.bugLevel == 1.4 then we want the 1.4 behavior
String bl = System.getProperty("sun.nio.cs.bugLevel");
compat = (bl != null && bl.equals("1.4"));
final Charset ascii = Charset.forName("US-ASCII");
new Test() {
public void go() throws Exception {
new CharsetDecoder(ascii, 3.9f, 1.2f) {
protected CoderResult decodeLoop(ByteBuffer in,
CharBuffer out)
{
return null;
}
};
}};
new Test() {
public void go() throws Exception {
new CharsetEncoder(ascii, 3.9f, 1.2f) {
protected CoderResult encodeLoop(CharBuffer in,
ByteBuffer out)
{
return null;
}
};
}};
}
}
/*
* Copyright 2010 Sun Microsystems, Inc. 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.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* @test
* @bug 4400697
* @summary Ensure that CharsetDecoder.decode throws BUE on empty input
*/
import java.nio.*;
import java.nio.charset.*;
public class EmptyInput {
public static void main(String[] args) throws Exception {
ByteBuffer bb = ByteBuffer.allocate(10);
bb.flip();
CharsetDecoder cd = Charset.forName("US-ASCII").newDecoder();
try {
cd.decode(bb, CharBuffer.allocate(10), true).throwException();
} catch (BufferUnderflowException x) {
System.err.println("BufferUnderflowException thrown as expected");
return;
}
throw new Exception("BufferUnderflowException not thrown");
}
}
/*
* Copyright 2010 Sun Microsystems, Inc. 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.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* @test
* @bug 4821213
* @summary Unit test for CharsetEncoder.canEncode methods
*/
import java.io.*;
import java.nio.*;
import java.nio.charset.*;
public class CanEncode {
private static int errors = 0;
private static PrintStream out = System.err;
private static void wrong(CharsetEncoder ce, boolean can, String what) {
out.println(ce.charset().name()
+ ": Wrong answer for " + what
+ ": " + !can);
errors++;
}
private static void ck(CharsetEncoder ce, char c, boolean can)
throws Exception
{
if (ce.canEncode(c) != can)
wrong(ce, can,
("'" + c + "' (0x"
+ Integer.toHexString(c & 0xffff) + ")"));
}
private static void ck(CharsetEncoder ce, String s, boolean can)
throws Exception
{
if (ce.canEncode(CharBuffer.wrap(s.toCharArray())) != can)
wrong(ce, can, "array \"" + s + "\"");
if (ce.canEncode(CharBuffer.wrap(s)) != can)
wrong(ce, can, "buffer \"" + s + "\"");
}
private static void test(String csn) throws Exception {
Charset cs = Charset.forName(csn);
CharsetEncoder ce = cs.newEncoder();
if (cs.name().equals("US-ASCII")) {
ck(ce, 'x', true);
ck(ce, '\u00B6', false);
ck(ce, "x", true);
ck(ce, "\u00B6", false);
ck(ce, "xyzzy", true);
ck(ce, "xy\u00B6", false);
}
// Unpaired surrogates should never be encodable
ck(ce, '\ud800', false);
ck(ce, '\ud801', false);
ck(ce, '\udffe', false);
ck(ce, '\udfff', false);
ck(ce, "\ud800", false);
ck(ce, "\ud801", false);
ck(ce, "\udffe", false);
ck(ce, "\udfff", false);
}
public static void main(String[] args) throws Exception {
test("US-ASCII");
test("UTF-8");
}
}
/*
* Copyright 2010 Sun Microsystems, Inc. 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.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* @test
* @bug 6227608
* @summary Test proper handling of flush()
* @author Martin Buchholz
*/
import java.util.*;
import java.io.*;
import java.nio.*;
import java.nio.charset.*;
public class Flush {
private static byte[] contents(ByteBuffer bb) {
byte[] contents = new byte[bb.position()];
((ByteBuffer)(bb.duplicate().flip())).get(contents);
return contents;
}
private static ByteBuffer extend(ByteBuffer bb) {
ByteBuffer x = ByteBuffer.allocate(2*bb.capacity()+10);
bb.flip();
x.put(bb);
return x;
}
private static void realMain(String[] args) throws Throwable {
// A japanese character should decode as a 3-byte
// switch-to-japanese escape sequence, followed by a 2-byte
// encoding of the char itself, followed by a 3-byte return to
// ASCII escape sequence.
char[] jis0208 = {'\u3001'};
CharBuffer cb = CharBuffer.wrap(jis0208);
ByteBuffer bb = ByteBuffer.allocate(6);
CharsetEncoder enc = Charset.forName("ISO-2022-JP").newEncoder();
check(enc.encode(cb, bb, true).isUnderflow());
System.out.println(Arrays.toString(contents(bb)));
check(! cb.hasRemaining());
equal(contents(bb).length, 3 + 2);
equal(bb.get(0), (byte)0x1b);
//----------------------------------------------------------------
// We must be able to recover if flush() returns OVERFLOW
//----------------------------------------------------------------
check(enc.flush(bb).isOverflow());
check(enc.flush(bb).isOverflow());
equal(contents(bb).length, 3 + 2);
bb = extend(bb);
check(enc.flush(bb).isUnderflow());
equal(bb.get(3 + 2), (byte)0x1b);
System.out.println(Arrays.toString(contents(bb)));
equal(contents(bb).length, 3 + 2 + 3);
//----------------------------------------------------------------
// A final redundant flush() is a no-op
//----------------------------------------------------------------
check(enc.flush(bb).isUnderflow());
check(enc.flush(bb).isUnderflow());
equal(contents(bb).length, 3 + 2 + 3);
//----------------------------------------------------------------
// CharsetEncoder.encode(ByteBuffer) must call flush(ByteBuffer)
//----------------------------------------------------------------
bb = enc.encode(CharBuffer.wrap(jis0208));
byte[] expected = "\u001b$B!\"\u001b(B".getBytes("ASCII");
byte[] contents = new byte[bb.limit()]; bb.get(contents);
check(Arrays.equals(contents, expected));
}
//--------------------- Infrastructure ---------------------------
static volatile int passed = 0, failed = 0;
static void pass() { passed++; }
static void fail() { failed++; Thread.dumpStack(); }
static void fail(String msg) { System.out.println(msg); fail(); }
static void unexpected(Throwable t) { failed++; t.printStackTrace(); }
static void check(boolean cond) { if (cond) pass(); else fail(); }
static void equal(Object x, Object y) {
if (x == null ? y == null : x.equals(y)) pass();
else {System.out.println(x + " not equal to " + y); fail(); }}
public static void main(String[] args) throws Throwable {
try { realMain(args); } catch (Throwable t) { unexpected(t); }
System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
if (failed > 0) throw new Exception("Some tests failed");
}
}
此差异已折叠。
此差异已折叠。
/*
* Copyright 2010 Sun Microsystems, Inc. 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.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* @test
@bug 6227339
@summary Check if returned CoderResult.unmappableForLength has correct
length value.
*/
import java.nio.charset.*;
import java.nio.*;
public class TestUnmappableForLength {
public static void main(String[] argv) throws CharacterCodingException {
byte[] ba = {(byte)0xa2, (byte)0xff};
//EUC_TW has its own decodeArrayLoop()
testDecode("EUC_TW", ba, 2);
//EUC_CN uses DoubleByteDecoder's decodeArrayLoop()
testDecode("EUC_CN", ba, 2);
}
static void testDecode(String csName, byte[] ba, int expected)
throws CharacterCodingException
{
try {
CoderResult cr = Charset
.forName(csName)
.newDecoder()
.decode(ByteBuffer.wrap(ba), CharBuffer.allocate(4), true);
if (cr.isUnmappable() && cr.length() != expected) {
throw new CharacterCodingException();
}
} catch (IllegalArgumentException x){
x.printStackTrace();
}
}
}
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
//
grant {
permission java.lang.RuntimePermission "charsetProvider";
};
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册