Merge
This commit is contained in:
commit
bdf450a182
@ -57,7 +57,10 @@ public class JavaStatic {
|
|||||||
id = ((JavaObjectRef)value).getId();
|
id = ((JavaObjectRef)value).getId();
|
||||||
}
|
}
|
||||||
value = value.dereference(snapshot, field);
|
value = value.dereference(snapshot, field);
|
||||||
if (value.isHeapAllocated()) {
|
if (value.isHeapAllocated() &&
|
||||||
|
clazz.getLoader() == snapshot.getNullThing()) {
|
||||||
|
// static fields are only roots if they are in classes
|
||||||
|
// loaded by the root classloader.
|
||||||
JavaHeapObject ho = (JavaHeapObject) value;
|
JavaHeapObject ho = (JavaHeapObject) value;
|
||||||
String s = "Static reference from " + clazz.getName()
|
String s = "Static reference from " + clazz.getName()
|
||||||
+ "." + field.getName();
|
+ "." + field.getName();
|
||||||
|
@ -4,7 +4,10 @@ package com.sun.tracing;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.logging.Logger;
|
import java.security.AccessController;
|
||||||
|
import java.security.PrivilegedActionException;
|
||||||
|
import java.security.PrivilegedExceptionAction;
|
||||||
|
import sun.security.action.GetPropertyAction;
|
||||||
|
|
||||||
import sun.tracing.NullProviderFactory;
|
import sun.tracing.NullProviderFactory;
|
||||||
import sun.tracing.PrintStreamProviderFactory;
|
import sun.tracing.PrintStreamProviderFactory;
|
||||||
@ -52,23 +55,17 @@ public abstract class ProviderFactory {
|
|||||||
HashSet<ProviderFactory> factories = new HashSet<ProviderFactory>();
|
HashSet<ProviderFactory> factories = new HashSet<ProviderFactory>();
|
||||||
|
|
||||||
// Try to instantiate a DTraceProviderFactory
|
// Try to instantiate a DTraceProviderFactory
|
||||||
String prop = null;
|
String prop = AccessController.doPrivileged(
|
||||||
try { prop = System.getProperty("com.sun.tracing.dtrace"); }
|
new GetPropertyAction("com.sun.tracing.dtrace"));
|
||||||
catch (java.security.AccessControlException e) {
|
|
||||||
Logger.getAnonymousLogger().fine(
|
|
||||||
"Cannot access property com.sun.tracing.dtrace");
|
|
||||||
}
|
|
||||||
if ( (prop == null || !prop.equals("disable")) &&
|
if ( (prop == null || !prop.equals("disable")) &&
|
||||||
DTraceProviderFactory.isSupported() ) {
|
DTraceProviderFactory.isSupported() ) {
|
||||||
factories.add(new DTraceProviderFactory());
|
factories.add(new DTraceProviderFactory());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to instantiate an output stream factory
|
// Try to instantiate an output stream factory
|
||||||
try { prop = System.getProperty("sun.tracing.stream"); }
|
prop = AccessController.doPrivileged(
|
||||||
catch (java.security.AccessControlException e) {
|
new GetPropertyAction("sun.tracing.stream"));
|
||||||
Logger.getAnonymousLogger().fine(
|
|
||||||
"Cannot access property sun.tracing.stream");
|
|
||||||
}
|
|
||||||
if (prop != null) {
|
if (prop != null) {
|
||||||
for (String spec : prop.split(",")) {
|
for (String spec : prop.split(",")) {
|
||||||
PrintStream ps = getPrintStreamFromSpec(spec);
|
PrintStream ps = getPrintStreamFromSpec(spec);
|
||||||
@ -89,22 +86,29 @@ public abstract class ProviderFactory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static PrintStream getPrintStreamFromSpec(String spec) {
|
private static PrintStream getPrintStreamFromSpec(final String spec) {
|
||||||
try {
|
try {
|
||||||
// spec is in the form of <class>.<field>, where <class> is
|
// spec is in the form of <class>.<field>, where <class> is
|
||||||
// a fully specified class name, and <field> is a static member
|
// a fully specified class name, and <field> is a static member
|
||||||
// in that class. The <field> must be a 'PrintStream' or subtype
|
// in that class. The <field> must be a 'PrintStream' or subtype
|
||||||
// in order to be used.
|
// in order to be used.
|
||||||
int fieldpos = spec.lastIndexOf('.');
|
final int fieldpos = spec.lastIndexOf('.');
|
||||||
Class<?> cls = Class.forName(spec.substring(0, fieldpos));
|
final Class<?> cls = Class.forName(spec.substring(0, fieldpos));
|
||||||
Field f = cls.getField(spec.substring(fieldpos + 1));
|
|
||||||
Class<?> fieldType = f.getType();
|
Field f = AccessController.doPrivileged(new PrivilegedExceptionAction<Field>() {
|
||||||
|
public Field run() throws NoSuchFieldException {
|
||||||
|
return cls.getField(spec.substring(fieldpos + 1));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return (PrintStream)f.get(null);
|
return (PrintStream)f.get(null);
|
||||||
} catch (Exception e) {
|
} catch (ClassNotFoundException e) {
|
||||||
Logger.getAnonymousLogger().warning(
|
throw new AssertionError(e);
|
||||||
"Could not parse sun.tracing.stream property: " + e);
|
} catch (IllegalAccessException e) {
|
||||||
|
throw new AssertionError(e);
|
||||||
|
} catch (PrivilegedActionException e) {
|
||||||
|
throw new AssertionError(e);
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ import java.util.List;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import sun.util.logging.PlatformLogger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CookieManager provides a concrete implementation of {@link CookieHandler},
|
* CookieManager provides a concrete implementation of {@link CookieHandler},
|
||||||
@ -263,6 +264,7 @@ public class CookieManager extends CookieHandler
|
|||||||
if (cookieJar == null)
|
if (cookieJar == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
PlatformLogger logger = PlatformLogger.getLogger("java.net.CookieManager");
|
||||||
for (String headerKey : responseHeaders.keySet()) {
|
for (String headerKey : responseHeaders.keySet()) {
|
||||||
// RFC 2965 3.2.2, key must be 'Set-Cookie2'
|
// RFC 2965 3.2.2, key must be 'Set-Cookie2'
|
||||||
// we also accept 'Set-Cookie' here for backward compatibility
|
// we also accept 'Set-Cookie' here for backward compatibility
|
||||||
@ -277,7 +279,16 @@ public class CookieManager extends CookieHandler
|
|||||||
|
|
||||||
for (String headerValue : responseHeaders.get(headerKey)) {
|
for (String headerValue : responseHeaders.get(headerKey)) {
|
||||||
try {
|
try {
|
||||||
List<HttpCookie> cookies = HttpCookie.parse(headerValue);
|
List<HttpCookie> cookies;
|
||||||
|
try {
|
||||||
|
cookies = HttpCookie.parse(headerValue);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
// Bogus header, make an empty list and log the error
|
||||||
|
cookies = java.util.Collections.EMPTY_LIST;
|
||||||
|
if (logger.isLoggable(PlatformLogger.SEVERE)) {
|
||||||
|
logger.severe("Invalid cookie for " + uri + ": " + headerValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
for (HttpCookie cookie : cookies) {
|
for (HttpCookie cookie : cookies) {
|
||||||
if (cookie.getPath() == null) {
|
if (cookie.getPath() == null) {
|
||||||
// If no path is specified, then by default
|
// If no path is specified, then by default
|
||||||
|
@ -1036,7 +1036,7 @@ public final class HttpCookie implements Cloneable {
|
|||||||
int version = Integer.parseInt(attrValue);
|
int version = Integer.parseInt(attrValue);
|
||||||
cookie.setVersion(version);
|
cookie.setVersion(version);
|
||||||
} catch (NumberFormatException ignored) {
|
} catch (NumberFormatException ignored) {
|
||||||
throw new IllegalArgumentException("Illegal cookie version attribute");
|
// Just ignore bogus version, it will default to 0 or 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -1147,12 +1147,15 @@ public final class HttpCookie implements Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static String stripOffSurroundingQuote(String str) {
|
private static String stripOffSurroundingQuote(String str) {
|
||||||
if (str != null && str.length() > 0 &&
|
if (str != null && str.length() > 2 &&
|
||||||
str.charAt(0) == '"' && str.charAt(str.length() - 1) == '"') {
|
str.charAt(0) == '"' && str.charAt(str.length() - 1) == '"') {
|
||||||
return str.substring(1, str.length() - 1);
|
return str.substring(1, str.length() - 1);
|
||||||
} else {
|
|
||||||
return str;
|
|
||||||
}
|
}
|
||||||
|
if (str != null && str.length() > 2 &&
|
||||||
|
str.charAt(0) == '\'' && str.charAt(str.length() - 1) == '\'') {
|
||||||
|
return str.substring(1, str.length() - 1);
|
||||||
|
}
|
||||||
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean equalsIgnoreCase(String s, String t) {
|
private static boolean equalsIgnoreCase(String s, String t) {
|
||||||
|
@ -335,10 +335,13 @@ class OCSPChecker extends PKIXCertPathChecker {
|
|||||||
response = OCSP.check(Collections.singletonList(certId), uri,
|
response = OCSP.check(Collections.singletonList(certId), uri,
|
||||||
responderCert, pkixParams.getDate());
|
responderCert, pkixParams.getDate());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// Wrap all exceptions in CertPathValidatorException so that
|
if (e instanceof CertPathValidatorException) {
|
||||||
// we can fallback to CRLs, if enabled.
|
throw (CertPathValidatorException) e;
|
||||||
throw new CertPathValidatorException
|
} else {
|
||||||
("Unable to send OCSP request", e);
|
// Wrap exceptions in CertPathValidatorException so that
|
||||||
|
// we can fallback to CRLs, if enabled.
|
||||||
|
throw new CertPathValidatorException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RevocationStatus rs = (RevocationStatus) response.getSingleResponse(certId);
|
RevocationStatus rs = (RevocationStatus) response.getSingleResponse(certId);
|
||||||
|
@ -30,7 +30,6 @@ import java.lang.reflect.InvocationTargetException;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import com.sun.tracing.ProviderFactory;
|
import com.sun.tracing.ProviderFactory;
|
||||||
import com.sun.tracing.Provider;
|
import com.sun.tracing.Provider;
|
||||||
@ -65,13 +64,7 @@ public class MultiplexProviderFactory extends ProviderFactory {
|
|||||||
providers.add(factory.createProvider(cls));
|
providers.add(factory.createProvider(cls));
|
||||||
}
|
}
|
||||||
MultiplexProvider provider = new MultiplexProvider(cls, providers);
|
MultiplexProvider provider = new MultiplexProvider(cls, providers);
|
||||||
try {
|
provider.init();
|
||||||
provider.init();
|
|
||||||
} catch (Exception e) {
|
|
||||||
// Probably a permission problem (can't get declared members)
|
|
||||||
Logger.getAnonymousLogger().warning(
|
|
||||||
"Could not initialize tracing provider: " + e.getMessage());
|
|
||||||
}
|
|
||||||
return provider.newProxyInstance();
|
return provider.newProxyInstance();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
package sun.tracing;
|
package sun.tracing;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import com.sun.tracing.ProviderFactory;
|
import com.sun.tracing.ProviderFactory;
|
||||||
import com.sun.tracing.Provider;
|
import com.sun.tracing.Provider;
|
||||||
@ -53,13 +52,7 @@ public class NullProviderFactory extends ProviderFactory {
|
|||||||
*/
|
*/
|
||||||
public <T extends Provider> T createProvider(Class<T> cls) {
|
public <T extends Provider> T createProvider(Class<T> cls) {
|
||||||
NullProvider provider = new NullProvider(cls);
|
NullProvider provider = new NullProvider(cls);
|
||||||
try {
|
provider.init();
|
||||||
provider.init();
|
|
||||||
} catch (Exception e) {
|
|
||||||
// Probably a permission problem (can't get declared members)
|
|
||||||
Logger.getAnonymousLogger().warning(
|
|
||||||
"Could not initialize tracing provider: " + e.getMessage());
|
|
||||||
}
|
|
||||||
return provider.newProxyInstance();
|
return provider.newProxyInstance();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,6 @@ package sun.tracing;
|
|||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import com.sun.tracing.ProviderFactory;
|
import com.sun.tracing.ProviderFactory;
|
||||||
import com.sun.tracing.Provider;
|
import com.sun.tracing.Provider;
|
||||||
@ -54,13 +53,7 @@ public class PrintStreamProviderFactory extends ProviderFactory {
|
|||||||
|
|
||||||
public <T extends Provider> T createProvider(Class<T> cls) {
|
public <T extends Provider> T createProvider(Class<T> cls) {
|
||||||
PrintStreamProvider provider = new PrintStreamProvider(cls, stream);
|
PrintStreamProvider provider = new PrintStreamProvider(cls, stream);
|
||||||
try {
|
provider.init();
|
||||||
provider.init();
|
|
||||||
} catch (Exception e) {
|
|
||||||
// Probably a permission problem (can't get declared members)
|
|
||||||
Logger.getAnonymousLogger().warning(
|
|
||||||
"Could not initialize tracing provider: " + e.getMessage());
|
|
||||||
}
|
|
||||||
return provider.newProxyInstance();
|
return provider.newProxyInstance();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,8 @@ import java.lang.reflect.InvocationTargetException;
|
|||||||
import java.lang.reflect.AnnotatedElement;
|
import java.lang.reflect.AnnotatedElement;
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.security.AccessController;
|
||||||
|
import java.security.PrivilegedAction;
|
||||||
|
|
||||||
import com.sun.tracing.Provider;
|
import com.sun.tracing.Provider;
|
||||||
import com.sun.tracing.Probe;
|
import com.sun.tracing.Probe;
|
||||||
@ -99,7 +101,13 @@ public abstract class ProviderSkeleton implements InvocationHandler, Provider {
|
|||||||
* It is up to the factory implementations to call this after construction.
|
* It is up to the factory implementations to call this after construction.
|
||||||
*/
|
*/
|
||||||
public void init() {
|
public void init() {
|
||||||
for (Method m : providerType.getDeclaredMethods()) {
|
Method[] methods = AccessController.doPrivileged(new PrivilegedAction<Method[]>() {
|
||||||
|
public Method[] run() {
|
||||||
|
return providerType.getDeclaredMethods();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
for (Method m : methods) {
|
||||||
if ( m.getReturnType() != Void.TYPE ) {
|
if ( m.getReturnType() != Void.TYPE ) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"Return value of method is not void");
|
"Return value of method is not void");
|
||||||
|
@ -29,7 +29,6 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.logging.Logger;
|
|
||||||
import java.security.Permission;
|
import java.security.Permission;
|
||||||
|
|
||||||
import com.sun.tracing.ProviderFactory;
|
import com.sun.tracing.ProviderFactory;
|
||||||
@ -80,15 +79,8 @@ public final class DTraceProviderFactory extends ProviderFactory {
|
|||||||
DTraceProvider jsdt = new DTraceProvider(cls);
|
DTraceProvider jsdt = new DTraceProvider(cls);
|
||||||
T proxy = jsdt.newProxyInstance();
|
T proxy = jsdt.newProxyInstance();
|
||||||
jsdt.setProxy(proxy);
|
jsdt.setProxy(proxy);
|
||||||
try {
|
jsdt.init();
|
||||||
jsdt.init();
|
new Activation(jsdt.getModuleName(), new DTraceProvider[] { jsdt });
|
||||||
new Activation(jsdt.getModuleName(), new DTraceProvider[] { jsdt });
|
|
||||||
} catch (Exception e) {
|
|
||||||
// Probably a permission problem (can't get declared members)
|
|
||||||
Logger.getAnonymousLogger().warning(
|
|
||||||
"Could not initialize tracing provider: " + e.getMessage());
|
|
||||||
jsdt.dispose();
|
|
||||||
}
|
|
||||||
return proxy;
|
return proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1117,9 +1117,6 @@ sun/jvmstat/monitor/MonitoredVm/CR6672135.java generic-all
|
|||||||
# Unexpected Monitor Exception, solaris sparc -client
|
# Unexpected Monitor Exception, solaris sparc -client
|
||||||
sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.sh generic-all
|
sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.sh generic-all
|
||||||
|
|
||||||
# Probably should be samevm, but seem to cause errors even in othervm at times
|
|
||||||
sun/tools/jhat/HatHeapDump1Test.java generic-all
|
|
||||||
|
|
||||||
# Problems on windows, jmap.exe hangs? (these run jmap)
|
# Problems on windows, jmap.exe hangs? (these run jmap)
|
||||||
sun/tools/jmap/Basic.sh windows-all
|
sun/tools/jmap/Basic.sh windows-all
|
||||||
|
|
||||||
@ -1129,9 +1126,6 @@ sun/tools/jstatd/jstatdDefaults.sh solaris-all
|
|||||||
# Solaris sparcv9, jps output does not match, x64 different
|
# Solaris sparcv9, jps output does not match, x64 different
|
||||||
sun/tools/jstatd/jstatdExternalRegistry.sh solaris-all
|
sun/tools/jstatd/jstatdExternalRegistry.sh solaris-all
|
||||||
|
|
||||||
# Probably should be samevm, but seem to cause errors even in othervm at times
|
|
||||||
sun/tools/native2ascii/NativeErrors.java generic-all
|
|
||||||
|
|
||||||
# Solaris 10 sparc 32bit -client, java.lang.AssertionError: Some tests failed
|
# Solaris 10 sparc 32bit -client, java.lang.AssertionError: Some tests failed
|
||||||
tools/jar/JarEntryTime.java generic-all
|
tools/jar/JarEntryTime.java generic-all
|
||||||
|
|
||||||
|
149
jdk/test/com/sun/tracing/BasicWithSecurityMgr.java
Normal file
149
jdk/test/com/sun/tracing/BasicWithSecurityMgr.java
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2008 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 6899605
|
||||||
|
* @summary Basic unit test for tracing framework with security manager
|
||||||
|
* enabled
|
||||||
|
*/
|
||||||
|
|
||||||
|
import com.sun.tracing.*;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
|
@ProviderName("NamedProvider")
|
||||||
|
interface BasicProvider extends Provider {
|
||||||
|
void plainProbe();
|
||||||
|
void probeWithArgs(int a, float f, String s, Long l);
|
||||||
|
@ProbeName("namedProbe") void probeWithName();
|
||||||
|
void overloadedProbe();
|
||||||
|
void overloadedProbe(int i);
|
||||||
|
}
|
||||||
|
|
||||||
|
interface InvalidProvider extends Provider {
|
||||||
|
int nonVoidProbe();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BasicWithSecurityMgr {
|
||||||
|
|
||||||
|
public static ProviderFactory factory;
|
||||||
|
public static BasicProvider bp;
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
// enable security manager
|
||||||
|
System.setSecurityManager(new SecurityManager());
|
||||||
|
|
||||||
|
factory = ProviderFactory.getDefaultFactory();
|
||||||
|
if (factory != null) {
|
||||||
|
bp = factory.createProvider(BasicProvider.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
testProviderFactory();
|
||||||
|
testProbe();
|
||||||
|
testProvider();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void fail(String s) throws Exception {
|
||||||
|
throw new Exception(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void testProviderFactory() throws Exception {
|
||||||
|
if (factory == null) {
|
||||||
|
fail("ProviderFactory.getDefaultFactory: Did not create factory");
|
||||||
|
}
|
||||||
|
if (bp == null) {
|
||||||
|
fail("ProviderFactory.createProvider: Did not create provider");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
factory.createProvider(null);
|
||||||
|
fail("ProviderFactory.createProvider: Did not throw NPE for null");
|
||||||
|
} catch (NullPointerException e) {}
|
||||||
|
|
||||||
|
try {
|
||||||
|
factory.createProvider(InvalidProvider.class);
|
||||||
|
fail("Factory.createProvider: Should error with non-void probes");
|
||||||
|
} catch (IllegalArgumentException e) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void testProvider() throws Exception {
|
||||||
|
|
||||||
|
// These just shouldn't throw any exeptions:
|
||||||
|
bp.plainProbe();
|
||||||
|
bp.probeWithArgs(42, (float)3.14, "spam", new Long(2L));
|
||||||
|
bp.probeWithArgs(42, (float)3.14, null, null);
|
||||||
|
bp.probeWithName();
|
||||||
|
bp.overloadedProbe();
|
||||||
|
bp.overloadedProbe(42);
|
||||||
|
|
||||||
|
Method m = BasicProvider.class.getMethod("plainProbe");
|
||||||
|
Probe p = bp.getProbe(m);
|
||||||
|
if (p == null) {
|
||||||
|
fail("Provider.getProbe: Did not return probe");
|
||||||
|
}
|
||||||
|
|
||||||
|
Method m2 = BasicWithSecurityMgr.class.getMethod("testProvider");
|
||||||
|
p = bp.getProbe(m2);
|
||||||
|
if (p != null) {
|
||||||
|
fail("Provider.getProbe: Got probe with invalid spec");
|
||||||
|
}
|
||||||
|
|
||||||
|
bp.dispose();
|
||||||
|
// These just shouldn't throw any exeptions:
|
||||||
|
bp.plainProbe();
|
||||||
|
bp.probeWithArgs(42, (float)3.14, "spam", new Long(2L));
|
||||||
|
bp.probeWithArgs(42, (float)3.14, null, null);
|
||||||
|
bp.probeWithName();
|
||||||
|
bp.overloadedProbe();
|
||||||
|
bp.overloadedProbe(42);
|
||||||
|
|
||||||
|
if (bp.getProbe(m) != null) {
|
||||||
|
fail("Provider.getProbe: Should return null after dispose()");
|
||||||
|
}
|
||||||
|
|
||||||
|
bp.dispose(); // just to make sure nothing bad happens
|
||||||
|
}
|
||||||
|
|
||||||
|
static void testProbe() throws Exception {
|
||||||
|
Method m = BasicProvider.class.getMethod("plainProbe");
|
||||||
|
Probe p = bp.getProbe(m);
|
||||||
|
p.isEnabled(); // just make sure it doesn't do anything bad
|
||||||
|
p.trigger();
|
||||||
|
|
||||||
|
try {
|
||||||
|
p.trigger(0);
|
||||||
|
fail("Probe.trigger: too many arguments not caught");
|
||||||
|
} catch (IllegalArgumentException e) {}
|
||||||
|
|
||||||
|
p = bp.getProbe(BasicProvider.class.getMethod(
|
||||||
|
"probeWithArgs", int.class, float.class, String.class, Long.class));
|
||||||
|
try {
|
||||||
|
p.trigger();
|
||||||
|
fail("Probe.trigger: too few arguments not caught");
|
||||||
|
} catch (IllegalArgumentException e) {}
|
||||||
|
|
||||||
|
try {
|
||||||
|
p.trigger((float)3.14, (float)3.14, "", new Long(0L));
|
||||||
|
fail("Probe.trigger: wrong type primitive arguments not caught");
|
||||||
|
} catch (IllegalArgumentException e) {}
|
||||||
|
}
|
||||||
|
}
|
@ -24,7 +24,7 @@
|
|||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
* @summary Unit test for java.net.HttpCookie
|
* @summary Unit test for java.net.HttpCookie
|
||||||
* @bug 6244040 6277796 6277801 6277808 6294071 6692802 6790677
|
* @bug 6244040 6277796 6277801 6277808 6294071 6692802 6790677 6901170
|
||||||
* @author Edward Wang
|
* @author Edward Wang
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -335,6 +335,9 @@ public class TestHttpCookie {
|
|||||||
// bug 6277801
|
// bug 6277801
|
||||||
test("set-cookie: CUSTOMER=WILE_E_COYOTE; path=/; expires=Wednesday, 09-Nov-99 23:12:40 GMT; path=\"/acme\"")
|
test("set-cookie: CUSTOMER=WILE_E_COYOTE; path=/; expires=Wednesday, 09-Nov-99 23:12:40 GMT; path=\"/acme\"")
|
||||||
.n("CUSTOMER").v("WILE_E_COYOTE").p("/").ver(0);
|
.n("CUSTOMER").v("WILE_E_COYOTE").p("/").ver(0);
|
||||||
|
|
||||||
|
// bug 6901170
|
||||||
|
test("set-cookie: CUSTOMER=WILE_E_COYOTE; version='1'").ver(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void misc() {
|
static void misc() {
|
||||||
|
@ -186,11 +186,13 @@ public class HatRun {
|
|||||||
*/
|
*/
|
||||||
int nvm_options = 0;
|
int nvm_options = 0;
|
||||||
if ( vm_options != null ) nvm_options = vm_options.length;
|
if ( vm_options != null ) nvm_options = vm_options.length;
|
||||||
String cmd[] = new String[1 + (d64?1:0) + 5 + nvm_options];
|
String cmd[] = new String[1 + (d64?1:0) + 7 + nvm_options];
|
||||||
int i,j;
|
int i,j;
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
cmd[i++] = java;
|
cmd[i++] = java;
|
||||||
|
cmd[i++] = "-cp";
|
||||||
|
cmd[i++] = cdir;
|
||||||
cmd[i++] = "-Dtest.classes=" + cdir;
|
cmd[i++] = "-Dtest.classes=" + cdir;
|
||||||
if ( d64 ) {
|
if ( d64 ) {
|
||||||
cmd[i++] = "-d64";
|
cmd[i++] = "-d64";
|
||||||
|
@ -59,15 +59,28 @@ public class NativeErrors {
|
|||||||
in = new BufferedReader(new InputStreamReader(p.getInputStream()));
|
in = new BufferedReader(new InputStreamReader(p.getInputStream()));
|
||||||
checkResult(in, "err.bad.arg");
|
checkResult(in, "err.bad.arg");
|
||||||
|
|
||||||
command = getComString("test123");
|
File f0 = new File(System.getProperty("test.src", "."), "test123");
|
||||||
|
String path0 = f0.getPath();
|
||||||
|
if ( f0.exists() ) {
|
||||||
|
throw new Error("Input file should not exist: " + path0);
|
||||||
|
}
|
||||||
|
|
||||||
|
command = getComString(path0);
|
||||||
p = Runtime.getRuntime().exec(command);
|
p = Runtime.getRuntime().exec(command);
|
||||||
in = new BufferedReader(new InputStreamReader(p.getInputStream()));
|
in = new BufferedReader(new InputStreamReader(p.getInputStream()));
|
||||||
checkResult(in, "err.cannot.read");
|
checkResult(in, "err.cannot.read");
|
||||||
|
|
||||||
File f1 = new File(System.getProperty("test.src", "."), "test1");
|
File f1 = new File(System.getProperty("test.src", "."), "test1");
|
||||||
File f2 = new File(System.getProperty("test.src", "."), "test2");
|
File f2 = File.createTempFile("test2", ".tmp");
|
||||||
String path1 = f1.getPath();
|
String path1 = f1.getPath();
|
||||||
String path2 = f2.getPath();
|
String path2 = f2.getPath();
|
||||||
|
if ( !f1.exists() ) {
|
||||||
|
throw new Error("Missing input file: " + path1);
|
||||||
|
}
|
||||||
|
if ( !f2.setWritable(false) ) {
|
||||||
|
throw new Error("Output file cannot be made read only: " + path2);
|
||||||
|
}
|
||||||
|
f2.deleteOnExit();
|
||||||
|
|
||||||
command = getComString(path1, path2);
|
command = getComString(path1, path2);
|
||||||
p = Runtime.getRuntime().exec(command);
|
p = Runtime.getRuntime().exec(command);
|
||||||
@ -80,7 +93,9 @@ public class NativeErrors {
|
|||||||
throws Exception {
|
throws Exception {
|
||||||
String errorReceived;
|
String errorReceived;
|
||||||
errorReceived = in.readLine();
|
errorReceived = in.readLine();
|
||||||
|
assert errorReceived != null : "First readline cannot be null";
|
||||||
errorExpected = rsrc.getString(errorExpected);
|
errorExpected = rsrc.getString(errorExpected);
|
||||||
|
assert errorExpected != null : "Expected message cannot be null";
|
||||||
StringBuffer error = new StringBuffer(errorExpected);
|
StringBuffer error = new StringBuffer(errorExpected);
|
||||||
int start = errorExpected.indexOf("{0}");
|
int start = errorExpected.indexOf("{0}");
|
||||||
if (start >= 0) {
|
if (start >= 0) {
|
||||||
@ -128,6 +143,7 @@ public class NativeErrors {
|
|||||||
f = new File(path);
|
f = new File(path);
|
||||||
if (!f.exists())
|
if (!f.exists())
|
||||||
throw new RuntimeException("Cannot find native2ascii at "+path);
|
throw new RuntimeException("Cannot find native2ascii at "+path);
|
||||||
|
System.out.println("Using native2ascii at "+path);
|
||||||
}
|
}
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
@ -1 +0,0 @@
|
|||||||
This file exists as a non-writable placeholder for NativeErrors.java
|
|
Loading…
x
Reference in New Issue
Block a user