mirror of
https://github.com/openjdk/jdk.git
synced 2026-05-10 21:50:07 +00:00
Merge
This commit is contained in:
commit
9537405582
@ -270,7 +270,10 @@ SUNWprivate_1.1 {
|
||||
Java_sun_misc_Version_getJvmVersionInfo;
|
||||
Java_sun_misc_Version_getJvmSpecialVersion;
|
||||
Java_sun_misc_VM_latestUserDefinedLoader;
|
||||
Java_sun_misc_VM_isSetUID;
|
||||
Java_sun_misc_VM_getuid;
|
||||
Java_sun_misc_VM_geteuid;
|
||||
Java_sun_misc_VM_getgid;
|
||||
Java_sun_misc_VM_getegid;
|
||||
Java_sun_misc_VM_initialize;
|
||||
Java_sun_misc_VMSupport_initAgentProperties;
|
||||
Java_sun_misc_VMSupport_getVMTemporaryDirectory;
|
||||
|
||||
@ -739,6 +739,9 @@ SetClassPath(const char *s)
|
||||
if (s == NULL)
|
||||
return;
|
||||
s = JLI_WildcardExpandClasspath(s);
|
||||
if (sizeof(format) - 2 + JLI_StrLen(s) < JLI_StrLen(s))
|
||||
// s is became corrupted after expanding wildcards
|
||||
return;
|
||||
def = JLI_MemAlloc(sizeof(format)
|
||||
- 2 /* strlen("%s") */
|
||||
+ JLI_StrLen(s));
|
||||
@ -1358,9 +1361,11 @@ AddApplicationOptions(int cpathc, const char **cpathv)
|
||||
if (s) {
|
||||
s = (char *) JLI_WildcardExpandClasspath(s);
|
||||
/* 40 for -Denv.class.path= */
|
||||
envcp = (char *)JLI_MemAlloc(JLI_StrLen(s) + 40);
|
||||
sprintf(envcp, "-Denv.class.path=%s", s);
|
||||
AddOption(envcp, NULL);
|
||||
if (JLI_StrLen(s) + 40 > JLI_StrLen(s)) { // Safeguard from overflow
|
||||
envcp = (char *)JLI_MemAlloc(JLI_StrLen(s) + 40);
|
||||
sprintf(envcp, "-Denv.class.path=%s", s);
|
||||
AddOption(envcp, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -44,12 +44,7 @@ public class SocketAttachingConnector extends GenericAttachingConnector {
|
||||
public SocketAttachingConnector() {
|
||||
super(new SocketTransportService());
|
||||
|
||||
String defaultHostName;
|
||||
try {
|
||||
defaultHostName = InetAddress.getLocalHost().getHostName();
|
||||
} catch (UnknownHostException e) {
|
||||
defaultHostName = "";
|
||||
}
|
||||
String defaultHostName = "localhost";
|
||||
|
||||
addStringArgument(
|
||||
ARG_HOST,
|
||||
|
||||
@ -198,13 +198,17 @@ public class SocketTransportService extends TransportService {
|
||||
String host;
|
||||
String portStr;
|
||||
if (splitIndex < 0) {
|
||||
host = InetAddress.getLocalHost().getHostName();
|
||||
host = "localhost";
|
||||
portStr = address;
|
||||
} else {
|
||||
host = address.substring(0, splitIndex);
|
||||
portStr = address.substring(splitIndex+1);
|
||||
}
|
||||
|
||||
if (host.equals("*")) {
|
||||
host = InetAddress.getLocalHost().getHostName();
|
||||
}
|
||||
|
||||
int port;
|
||||
try {
|
||||
port = Integer.decode(portStr).intValue();
|
||||
@ -215,7 +219,6 @@ public class SocketTransportService extends TransportService {
|
||||
|
||||
|
||||
// open TCP connection to VM
|
||||
|
||||
InetSocketAddress sa = new InetSocketAddress(host, port);
|
||||
Socket s = new Socket();
|
||||
try {
|
||||
|
||||
@ -25,7 +25,6 @@
|
||||
|
||||
package java.lang;
|
||||
|
||||
import java.lang.ClassValue.ClassValueMap;
|
||||
import java.util.WeakHashMap;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
@ -375,10 +374,10 @@ public abstract class ClassValue<T> {
|
||||
synchronized (CRITICAL_SECTION) { // private object to avoid deadlocks
|
||||
// happens about once per type
|
||||
if ((map = type.classValueMap) == null)
|
||||
type.classValueMap = map = new ClassValueMap(type);
|
||||
}
|
||||
return map;
|
||||
type.classValueMap = map = new ClassValueMap();
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
static <T> Entry<T> makeEntry(Version<T> explicitVersion, T value) {
|
||||
// Note that explicitVersion might be different from this.version.
|
||||
@ -398,12 +397,11 @@ public abstract class ClassValue<T> {
|
||||
|
||||
// The following class could also be top level and non-public:
|
||||
|
||||
/** A backing map for all ClassValues, relative a single given type.
|
||||
/** A backing map for all ClassValues.
|
||||
* Gives a fully serialized "true state" for each pair (ClassValue cv, Class type).
|
||||
* Also manages an unserialized fast-path cache.
|
||||
*/
|
||||
static class ClassValueMap extends WeakHashMap<ClassValue.Identity, Entry<?>> {
|
||||
private final Class<?> type;
|
||||
private Entry<?>[] cacheArray;
|
||||
private int cacheLoad, cacheLoadLimit;
|
||||
|
||||
@ -413,11 +411,10 @@ public abstract class ClassValue<T> {
|
||||
*/
|
||||
private static final int INITIAL_ENTRIES = 32;
|
||||
|
||||
/** Build a backing map for ClassValues, relative the given type.
|
||||
/** Build a backing map for ClassValues.
|
||||
* Also, create an empty cache array and install it on the class.
|
||||
*/
|
||||
ClassValueMap(Class<?> type) {
|
||||
this.type = type;
|
||||
ClassValueMap() {
|
||||
sizeCache(INITIAL_ENTRIES);
|
||||
}
|
||||
|
||||
|
||||
@ -54,7 +54,7 @@ import java.util.stream.Collector;
|
||||
*
|
||||
* @implNote This implementation is not thread safe. However, it is safe to use
|
||||
* {@link java.util.stream.Collectors#summarizingDouble(java.util.function.ToDoubleFunction)
|
||||
* Collectors.toDoubleStatistics()} on a parallel stream, because the parallel
|
||||
* Collectors.summarizingDouble()} on a parallel stream, because the parallel
|
||||
* implementation of {@link java.util.stream.Stream#collect Stream.collect()}
|
||||
* provides the necessary partitioning, isolation, and merging of results for
|
||||
* safe and efficient parallel execution.
|
||||
|
||||
@ -54,7 +54,7 @@ import java.util.stream.Collector;
|
||||
*
|
||||
* @implNote This implementation is not thread safe. However, it is safe to use
|
||||
* {@link java.util.stream.Collectors#summarizingInt(java.util.function.ToIntFunction)
|
||||
* Collectors.toIntStatistics()} on a parallel stream, because the parallel
|
||||
* Collectors.summarizingInt()} on a parallel stream, because the parallel
|
||||
* implementation of {@link java.util.stream.Stream#collect Stream.collect()}
|
||||
* provides the necessary partitioning, isolation, and merging of results for
|
||||
* safe and efficient parallel execution.
|
||||
|
||||
@ -42,7 +42,7 @@ import java.util.stream.Collector;
|
||||
* }</pre>
|
||||
*
|
||||
* <p>{@code LongSummaryStatistics} can be used as a
|
||||
* {@linkplain java.util.stream.Stream#collect(Collector)} reduction}
|
||||
* {@linkplain java.util.stream.Stream#collect(Collector) reduction}
|
||||
* target for a {@linkplain java.util.stream.Stream stream}. For example:
|
||||
*
|
||||
* <pre> {@code
|
||||
@ -55,7 +55,7 @@ import java.util.stream.Collector;
|
||||
*
|
||||
* @implNote This implementation is not thread safe. However, it is safe to use
|
||||
* {@link java.util.stream.Collectors#summarizingLong(java.util.function.ToLongFunction)
|
||||
* Collectors.toLongStatistics()} on a parallel stream, because the parallel
|
||||
* Collectors.summarizingLong()} on a parallel stream, because the parallel
|
||||
* implementation of {@link java.util.stream.Stream#collect Stream.collect()}
|
||||
* provides the necessary partitioning, isolation, and merging of results for
|
||||
* safe and efficient parallel execution.
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -591,8 +591,7 @@ abstract public class TimeZone implements Serializable, Cloneable {
|
||||
/**
|
||||
* Gets the platform defined TimeZone ID.
|
||||
**/
|
||||
private static native String getSystemTimeZoneID(String javaHome,
|
||||
String country);
|
||||
private static native String getSystemTimeZoneID(String javaHome);
|
||||
|
||||
/**
|
||||
* Gets the custom time zone ID based on the GMT offset of the
|
||||
@ -650,12 +649,10 @@ abstract public class TimeZone implements Serializable, Cloneable {
|
||||
// if the time zone ID is not set (yet), perform the
|
||||
// platform to Java time zone ID mapping.
|
||||
if (zoneID == null || zoneID.isEmpty()) {
|
||||
String country = AccessController.doPrivileged(
|
||||
new GetPropertyAction("user.country"));
|
||||
String javaHome = AccessController.doPrivileged(
|
||||
new GetPropertyAction("java.home"));
|
||||
try {
|
||||
zoneID = getSystemTimeZoneID(javaHome, country);
|
||||
zoneID = getSystemTimeZoneID(javaHome);
|
||||
if (zoneID == null) {
|
||||
zoneID = GMT_ID;
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -216,26 +216,28 @@ final class JceSecurity {
|
||||
new WeakHashMap<>();
|
||||
|
||||
/*
|
||||
* Retuns the CodeBase for the given class.
|
||||
* Returns the CodeBase for the given class.
|
||||
*/
|
||||
static URL getCodeBase(final Class<?> clazz) {
|
||||
URL url = codeBaseCacheRef.get(clazz);
|
||||
if (url == null) {
|
||||
url = AccessController.doPrivileged(new PrivilegedAction<URL>() {
|
||||
public URL run() {
|
||||
ProtectionDomain pd = clazz.getProtectionDomain();
|
||||
if (pd != null) {
|
||||
CodeSource cs = pd.getCodeSource();
|
||||
if (cs != null) {
|
||||
return cs.getLocation();
|
||||
synchronized (codeBaseCacheRef) {
|
||||
URL url = codeBaseCacheRef.get(clazz);
|
||||
if (url == null) {
|
||||
url = AccessController.doPrivileged(new PrivilegedAction<URL>() {
|
||||
public URL run() {
|
||||
ProtectionDomain pd = clazz.getProtectionDomain();
|
||||
if (pd != null) {
|
||||
CodeSource cs = pd.getCodeSource();
|
||||
if (cs != null) {
|
||||
return cs.getLocation();
|
||||
}
|
||||
}
|
||||
return NULL_URL;
|
||||
}
|
||||
return NULL_URL;
|
||||
}
|
||||
});
|
||||
codeBaseCacheRef.put(clazz, url);
|
||||
});
|
||||
codeBaseCacheRef.put(clazz, url);
|
||||
}
|
||||
return (url == NULL_URL) ? null : url;
|
||||
}
|
||||
return (url == NULL_URL) ? null : url;
|
||||
}
|
||||
|
||||
private static void setupJurisdictionPolicies() throws Exception {
|
||||
|
||||
@ -134,7 +134,9 @@ public class BevelBorder extends AbstractBorder
|
||||
* when rendered on the specified component. If no highlight
|
||||
* color was specified at instantiation, the highlight color
|
||||
* is derived from the specified component's background color.
|
||||
*
|
||||
* @param c the component for which the highlight may be derived
|
||||
* @return the outer highlight {@code Color}
|
||||
* @since 1.3
|
||||
*/
|
||||
public Color getHighlightOuterColor(Component c) {
|
||||
@ -148,7 +150,9 @@ public class BevelBorder extends AbstractBorder
|
||||
* when rendered on the specified component. If no highlight
|
||||
* color was specified at instantiation, the highlight color
|
||||
* is derived from the specified component's background color.
|
||||
*
|
||||
* @param c the component for which the highlight may be derived
|
||||
* @return the inner highlight {@code Color}
|
||||
* @since 1.3
|
||||
*/
|
||||
public Color getHighlightInnerColor(Component c) {
|
||||
@ -162,7 +166,9 @@ public class BevelBorder extends AbstractBorder
|
||||
* when rendered on the specified component. If no shadow
|
||||
* color was specified at instantiation, the shadow color
|
||||
* is derived from the specified component's background color.
|
||||
*
|
||||
* @param c the component for which the shadow may be derived
|
||||
* @return the inner shadow {@code Color}
|
||||
* @since 1.3
|
||||
*/
|
||||
public Color getShadowInnerColor(Component c) {
|
||||
@ -176,7 +182,9 @@ public class BevelBorder extends AbstractBorder
|
||||
* when rendered on the specified component. If no shadow
|
||||
* color was specified at instantiation, the shadow color
|
||||
* is derived from the specified component's background color.
|
||||
*
|
||||
* @param c the component for which the shadow may be derived
|
||||
* @return the outer shadow {@code Color}
|
||||
* @since 1.3
|
||||
*/
|
||||
public Color getShadowOuterColor(Component c) {
|
||||
@ -189,6 +197,9 @@ public class BevelBorder extends AbstractBorder
|
||||
* Returns the outer highlight color of the bevel border.
|
||||
* Will return null if no highlight color was specified
|
||||
* at instantiation.
|
||||
*
|
||||
* @return the outer highlight {@code Color} or {@code null} if no highlight
|
||||
* color was specified
|
||||
* @since 1.3
|
||||
*/
|
||||
public Color getHighlightOuterColor() {
|
||||
@ -199,6 +210,9 @@ public class BevelBorder extends AbstractBorder
|
||||
* Returns the inner highlight color of the bevel border.
|
||||
* Will return null if no highlight color was specified
|
||||
* at instantiation.
|
||||
*
|
||||
* @return the inner highlight {@code Color} or {@code null} if no highlight
|
||||
* color was specified
|
||||
* @since 1.3
|
||||
*/
|
||||
public Color getHighlightInnerColor() {
|
||||
@ -209,6 +223,9 @@ public class BevelBorder extends AbstractBorder
|
||||
* Returns the inner shadow color of the bevel border.
|
||||
* Will return null if no shadow color was specified
|
||||
* at instantiation.
|
||||
*
|
||||
* @return the inner shadow {@code Color} or {@code null} if no shadow color
|
||||
* was specified
|
||||
* @since 1.3
|
||||
*/
|
||||
public Color getShadowInnerColor() {
|
||||
@ -219,6 +236,9 @@ public class BevelBorder extends AbstractBorder
|
||||
* Returns the outer shadow color of the bevel border.
|
||||
* Will return null if no shadow color was specified
|
||||
* at instantiation.
|
||||
*
|
||||
* @return the outer shadow {@code Color} or {@code null} if no shadow color
|
||||
* was specified
|
||||
* @since 1.3
|
||||
*/
|
||||
public Color getShadowOuterColor() {
|
||||
@ -227,13 +247,18 @@ public class BevelBorder extends AbstractBorder
|
||||
|
||||
/**
|
||||
* Returns the type of the bevel border.
|
||||
*
|
||||
* @return the bevel border type, either {@code RAISED} or {@code LOWERED}
|
||||
*/
|
||||
public int getBevelType() {
|
||||
return bevelType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not the border is opaque.
|
||||
* Returns whether or not the border is opaque. This implementation
|
||||
* returns {@code true}.
|
||||
*
|
||||
* @return true
|
||||
*/
|
||||
public boolean isBorderOpaque() { return true; }
|
||||
|
||||
|
||||
@ -66,6 +66,7 @@ public interface Border
|
||||
/**
|
||||
* Paints the border for the specified component with the specified
|
||||
* position and size.
|
||||
*
|
||||
* @param c the component for which this border is being painted
|
||||
* @param g the paint graphics
|
||||
* @param x the x position of the painted border
|
||||
@ -77,7 +78,10 @@ public interface Border
|
||||
|
||||
/**
|
||||
* Returns the insets of the border.
|
||||
*
|
||||
* @param c the component for which this border insets value applies
|
||||
* @return an {@code Insets} object containing the insets from top, left,
|
||||
* bottom and right of this {@code Border}
|
||||
*/
|
||||
Insets getBorderInsets(Component c);
|
||||
|
||||
@ -85,6 +89,8 @@ public interface Border
|
||||
* Returns whether or not the border is opaque. If the border
|
||||
* is opaque, it is responsible for filling in it's own
|
||||
* background when painting.
|
||||
*
|
||||
* @return true if this {@code Border} is opaque
|
||||
*/
|
||||
boolean isBorderOpaque();
|
||||
}
|
||||
|
||||
@ -155,6 +155,8 @@ public class CompoundBorder extends AbstractBorder {
|
||||
|
||||
/**
|
||||
* Returns the outside border object.
|
||||
*
|
||||
* @return the outside {@code Border} object
|
||||
*/
|
||||
public Border getOutsideBorder() {
|
||||
return outsideBorder;
|
||||
@ -162,6 +164,8 @@ public class CompoundBorder extends AbstractBorder {
|
||||
|
||||
/**
|
||||
* Returns the inside border object.
|
||||
*
|
||||
* @return the inside {@code Border} object
|
||||
*/
|
||||
public Border getInsideBorder() {
|
||||
return insideBorder;
|
||||
|
||||
@ -98,6 +98,9 @@ public class EmptyBorder extends AbstractBorder implements Serializable
|
||||
|
||||
/**
|
||||
* Returns the insets of the border.
|
||||
*
|
||||
* @return an {@code Insets} object containing the insets from top, left,
|
||||
* bottom and right
|
||||
* @since 1.3
|
||||
*/
|
||||
public Insets getBorderInsets() {
|
||||
|
||||
@ -77,6 +77,7 @@ public class EtchedBorder extends AbstractBorder
|
||||
* whose colors will be derived
|
||||
* from the background color of the component passed into
|
||||
* the paintBorder method.
|
||||
*
|
||||
* @param etchType the type of etch to be drawn by the border
|
||||
*/
|
||||
public EtchedBorder(int etchType) {
|
||||
@ -86,6 +87,7 @@ public class EtchedBorder extends AbstractBorder
|
||||
/**
|
||||
* Creates a lowered etched border with the specified highlight and
|
||||
* shadow colors.
|
||||
*
|
||||
* @param highlight the color to use for the etched highlight
|
||||
* @param shadow the color to use for the etched shadow
|
||||
*/
|
||||
@ -96,6 +98,7 @@ public class EtchedBorder extends AbstractBorder
|
||||
/**
|
||||
* Creates an etched border with the specified etch-type,
|
||||
* highlight and shadow colors.
|
||||
*
|
||||
* @param etchType the type of etch to be drawn by the border
|
||||
* @param highlight the color to use for the etched highlight
|
||||
* @param shadow the color to use for the etched shadow
|
||||
@ -110,6 +113,7 @@ public class EtchedBorder extends AbstractBorder
|
||||
/**
|
||||
* Paints the border for the specified component with the
|
||||
* specified position and size.
|
||||
*
|
||||
* @param c the component for which this border is being painted
|
||||
* @param g the paint graphics
|
||||
* @param x the x position of the painted border
|
||||
@ -138,6 +142,7 @@ public class EtchedBorder extends AbstractBorder
|
||||
|
||||
/**
|
||||
* Reinitialize the insets parameter with this Border's current Insets.
|
||||
*
|
||||
* @param c the component for which this border insets value applies
|
||||
* @param insets the object to be reinitialized
|
||||
*/
|
||||
@ -148,11 +153,16 @@ public class EtchedBorder extends AbstractBorder
|
||||
|
||||
/**
|
||||
* Returns whether or not the border is opaque.
|
||||
* This implementation returns true.
|
||||
*
|
||||
* @return true
|
||||
*/
|
||||
public boolean isBorderOpaque() { return true; }
|
||||
|
||||
/**
|
||||
* Returns which etch-type is set on the etched border.
|
||||
*
|
||||
* @return the etched border type, either {@code RAISED} or {@code LOWERED}
|
||||
*/
|
||||
public int getEtchType() {
|
||||
return etchType;
|
||||
@ -163,7 +173,9 @@ public class EtchedBorder extends AbstractBorder
|
||||
* when rendered on the specified component. If no highlight
|
||||
* color was specified at instantiation, the highlight color
|
||||
* is derived from the specified component's background color.
|
||||
*
|
||||
* @param c the component for which the highlight may be derived
|
||||
* @return the highlight {@code Color} of this {@code EtchedBorder}
|
||||
* @since 1.3
|
||||
*/
|
||||
public Color getHighlightColor(Component c) {
|
||||
@ -175,6 +187,9 @@ public class EtchedBorder extends AbstractBorder
|
||||
* Returns the highlight color of the etched border.
|
||||
* Will return null if no highlight color was specified
|
||||
* at instantiation.
|
||||
*
|
||||
* @return the highlight {@code Color} of this {@code EtchedBorder} or null
|
||||
* if none was specified
|
||||
* @since 1.3
|
||||
*/
|
||||
public Color getHighlightColor() {
|
||||
@ -186,7 +201,9 @@ public class EtchedBorder extends AbstractBorder
|
||||
* when rendered on the specified component. If no shadow
|
||||
* color was specified at instantiation, the shadow color
|
||||
* is derived from the specified component's background color.
|
||||
*
|
||||
* @param c the component for which the shadow may be derived
|
||||
* @return the shadow {@code Color} of this {@code EtchedBorder}
|
||||
* @since 1.3
|
||||
*/
|
||||
public Color getShadowColor(Component c) {
|
||||
@ -197,6 +214,9 @@ public class EtchedBorder extends AbstractBorder
|
||||
* Returns the shadow color of the etched border.
|
||||
* Will return null if no shadow color was specified
|
||||
* at instantiation.
|
||||
*
|
||||
* @return the shadow {@code Color} of this {@code EtchedBorder} or null
|
||||
* if none was specified
|
||||
* @since 1.3
|
||||
*/
|
||||
public Color getShadowColor() {
|
||||
|
||||
@ -60,8 +60,11 @@ public class LineBorder extends AbstractBorder
|
||||
protected Color lineColor;
|
||||
protected boolean roundedCorners;
|
||||
|
||||
/** Convenience method for getting the Color.black LineBorder of thickness 1.
|
||||
*/
|
||||
/**
|
||||
* Convenience method for getting the Color.black LineBorder of thickness 1.
|
||||
*
|
||||
* @return a {@code LineBorder} with {@code Color.black} and thickness of 1
|
||||
*/
|
||||
public static Border createBlackLineBorder() {
|
||||
if (blackLine == null) {
|
||||
blackLine = new LineBorder(Color.black, 1);
|
||||
@ -69,8 +72,11 @@ public class LineBorder extends AbstractBorder
|
||||
return blackLine;
|
||||
}
|
||||
|
||||
/** Convenience method for getting the Color.gray LineBorder of thickness 1.
|
||||
*/
|
||||
/**
|
||||
* Convenience method for getting the Color.gray LineBorder of thickness 1.
|
||||
*
|
||||
* @return a {@code LineBorder} with {@code Color.gray} and thickness of 1
|
||||
*/
|
||||
public static Border createGrayLineBorder() {
|
||||
if (grayLine == null) {
|
||||
grayLine = new LineBorder(Color.gray, 1);
|
||||
@ -81,6 +87,7 @@ public class LineBorder extends AbstractBorder
|
||||
/**
|
||||
* Creates a line border with the specified color and a
|
||||
* thickness = 1.
|
||||
*
|
||||
* @param color the color for the border
|
||||
*/
|
||||
public LineBorder(Color color) {
|
||||
@ -89,6 +96,7 @@ public class LineBorder extends AbstractBorder
|
||||
|
||||
/**
|
||||
* Creates a line border with the specified color and thickness.
|
||||
*
|
||||
* @param color the color of the border
|
||||
* @param thickness the thickness of the border
|
||||
*/
|
||||
@ -99,6 +107,7 @@ public class LineBorder extends AbstractBorder
|
||||
/**
|
||||
* Creates a line border with the specified color, thickness,
|
||||
* and corner shape.
|
||||
*
|
||||
* @param color the color of the border
|
||||
* @param thickness the thickness of the border
|
||||
* @param roundedCorners whether or not border corners should be round
|
||||
@ -114,6 +123,7 @@ public class LineBorder extends AbstractBorder
|
||||
/**
|
||||
* Paints the border for the specified component with the
|
||||
* specified position and size.
|
||||
*
|
||||
* @param c the component for which this border is being painted
|
||||
* @param g the paint graphics
|
||||
* @param x the x position of the painted border
|
||||
@ -152,6 +162,7 @@ public class LineBorder extends AbstractBorder
|
||||
|
||||
/**
|
||||
* Reinitialize the insets parameter with this Border's current Insets.
|
||||
*
|
||||
* @param c the component for which this border insets value applies
|
||||
* @param insets the object to be reinitialized
|
||||
*/
|
||||
@ -162,6 +173,8 @@ public class LineBorder extends AbstractBorder
|
||||
|
||||
/**
|
||||
* Returns the color of the border.
|
||||
*
|
||||
* @return a {@code Color} object representing the color of this object
|
||||
*/
|
||||
public Color getLineColor() {
|
||||
return lineColor;
|
||||
@ -169,6 +182,8 @@ public class LineBorder extends AbstractBorder
|
||||
|
||||
/**
|
||||
* Returns the thickness of the border.
|
||||
*
|
||||
* @return the thickness of this border
|
||||
*/
|
||||
public int getThickness() {
|
||||
return thickness;
|
||||
@ -176,6 +191,8 @@ public class LineBorder extends AbstractBorder
|
||||
|
||||
/**
|
||||
* Returns whether this border will be drawn with rounded corners.
|
||||
*
|
||||
* @return {@code true} if this border should have rounded corners
|
||||
* @since 1.3
|
||||
*/
|
||||
public boolean getRoundedCorners() {
|
||||
@ -184,6 +201,8 @@ public class LineBorder extends AbstractBorder
|
||||
|
||||
/**
|
||||
* Returns whether or not the border is opaque.
|
||||
*
|
||||
* @return {@code true} if the border is opaque, {@code false} otherwise
|
||||
*/
|
||||
public boolean isBorderOpaque() {
|
||||
return !roundedCorners;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -196,6 +196,9 @@ public class MatteBorder extends EmptyBorder
|
||||
/**
|
||||
* Returns the color used for tiling the border or null
|
||||
* if a tile icon is being used.
|
||||
*
|
||||
* @return the {@code Color} object used to render the border or {@code null}
|
||||
* if a tile icon is used
|
||||
* @since 1.3
|
||||
*/
|
||||
public Color getMatteColor() {
|
||||
@ -205,6 +208,9 @@ public class MatteBorder extends EmptyBorder
|
||||
/**
|
||||
* Returns the icon used for tiling the border or null
|
||||
* if a solid color is being used.
|
||||
*
|
||||
* @return the {@code Icon} used to tile the border or {@code null} if a
|
||||
* solid color is used to fill the border
|
||||
* @since 1.3
|
||||
*/
|
||||
public Icon getTileIcon() {
|
||||
@ -213,6 +219,8 @@ public class MatteBorder extends EmptyBorder
|
||||
|
||||
/**
|
||||
* Returns whether or not the border is opaque.
|
||||
*
|
||||
* @return {@code true} if the border is opaque, {@code false} otherwise
|
||||
*/
|
||||
public boolean isBorderOpaque() {
|
||||
// If a tileIcon is set, then it may contain transparent bits
|
||||
|
||||
@ -145,7 +145,8 @@ public abstract class AbstractColorChooserPanel extends JPanel {
|
||||
/**
|
||||
* Invoked when the panel is added to the chooser.
|
||||
* If you override this, be sure to call <code>super</code>.
|
||||
* @param enclosingChooser the panel to be added
|
||||
*
|
||||
* @param enclosingChooser the chooser to which the panel is to be added
|
||||
* @exception RuntimeException if the chooser panel has already been
|
||||
* installed
|
||||
*/
|
||||
@ -163,6 +164,8 @@ public abstract class AbstractColorChooserPanel extends JPanel {
|
||||
/**
|
||||
* Invoked when the panel is removed from the chooser.
|
||||
* If override this, be sure to call <code>super</code>.
|
||||
*
|
||||
* @param enclosingChooser the chooser from which the panel is to be removed
|
||||
*/
|
||||
public void uninstallChooserPanel(JColorChooser enclosingChooser) {
|
||||
chooser.removePropertyChangeListener("enabled", enabledListener);
|
||||
|
||||
@ -51,11 +51,16 @@ import java.io.File;
|
||||
public abstract class FileFilter {
|
||||
/**
|
||||
* Whether the given file is accepted by this filter.
|
||||
*
|
||||
* @param f the File to test
|
||||
* @return true if the file is to be accepted
|
||||
*/
|
||||
public abstract boolean accept(File f);
|
||||
|
||||
/**
|
||||
* The description of this filter. For example: "JPG and GIF Images"
|
||||
*
|
||||
* @return the description of this filter
|
||||
* @see FileView#getName
|
||||
*/
|
||||
public abstract String getDescription();
|
||||
|
||||
@ -324,11 +324,18 @@ public abstract class FileSystemView {
|
||||
|
||||
/**
|
||||
* Creates a new folder with a default folder name.
|
||||
*
|
||||
* @param containingDir a {@code File} object denoting directory to contain the new folder
|
||||
* @return a {@code File} object denoting the newly created folder
|
||||
* @throws IOException if new folder could not be created
|
||||
*/
|
||||
public abstract File createNewFolder(File containingDir) throws IOException;
|
||||
|
||||
/**
|
||||
* Returns whether a file is hidden or not.
|
||||
*
|
||||
* @param f a {@code File} object
|
||||
* @return true if the given {@code File} denotes a hidden file
|
||||
*/
|
||||
public boolean isHiddenFile(File f) {
|
||||
return f.isHidden();
|
||||
@ -395,6 +402,9 @@ public abstract class FileSystemView {
|
||||
* Returns all root partitions on this system. For example, on
|
||||
* Windows, this would be the "Desktop" folder, while on DOS this
|
||||
* would be the A: through Z: drives.
|
||||
*
|
||||
* @return an array of {@code File} objects representing all root partitions
|
||||
* on this system
|
||||
*/
|
||||
public File[] getRoots() {
|
||||
// Don't cache this array, because filesystem might change
|
||||
@ -435,6 +445,10 @@ public abstract class FileSystemView {
|
||||
|
||||
/**
|
||||
* Returns a File object constructed in dir from the given filename.
|
||||
*
|
||||
* @param dir an abstract pathname denoting a directory
|
||||
* @param filename a {@code String} representation of a pathname
|
||||
* @return a {@code File} object created from {@code dir} and {@code filename}
|
||||
*/
|
||||
public File createFileObject(File dir, String filename) {
|
||||
if(dir == null) {
|
||||
@ -446,6 +460,9 @@ public abstract class FileSystemView {
|
||||
|
||||
/**
|
||||
* Returns a File object constructed from the given path string.
|
||||
*
|
||||
* @param path {@code String} representation of path
|
||||
* @return a {@code File} object created from the given {@code path}
|
||||
*/
|
||||
public File createFileObject(String path) {
|
||||
File f = new File(path);
|
||||
@ -458,6 +475,12 @@ public abstract class FileSystemView {
|
||||
|
||||
/**
|
||||
* Gets the list of shown (i.e. not hidden) files.
|
||||
*
|
||||
* @param dir the root directory of files to be returned
|
||||
* @param useFileHiding determine if hidden files are returned
|
||||
* @return an array of {@code File} objects representing files and
|
||||
* directories in the given {@code dir}. It includes hidden
|
||||
* files if {@code useFileHiding} is false.
|
||||
*/
|
||||
public File[] getFiles(File dir, boolean useFileHiding) {
|
||||
List<File> files = new ArrayList<File>();
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -69,6 +69,9 @@ public abstract class FileView {
|
||||
/**
|
||||
* The name of the file. Normally this would be simply
|
||||
* <code>f.getName()</code>.
|
||||
*
|
||||
* @param f a {@code File} object
|
||||
* @return a {@code String} representing the name of the file
|
||||
*/
|
||||
public String getName(File f) {
|
||||
return null;
|
||||
@ -78,6 +81,11 @@ public abstract class FileView {
|
||||
* A human readable description of the file. For example,
|
||||
* a file named <i>jag.jpg</i> might have a description that read:
|
||||
* "A JPEG image file of James Gosling's face".
|
||||
*
|
||||
* @param f a {@code File} object
|
||||
* @return a {@code String} containing a description of the file or
|
||||
* {@code null} if it is not available.
|
||||
*
|
||||
*/
|
||||
public String getDescription(File f) {
|
||||
return null;
|
||||
@ -87,6 +95,10 @@ public abstract class FileView {
|
||||
* A human readable description of the type of the file. For
|
||||
* example, a <code>jpg</code> file might have a type description of:
|
||||
* "A JPEG Compressed Image File"
|
||||
*
|
||||
* @param f a {@code File} object
|
||||
* @return a {@code String} containing a description of the type of the file
|
||||
* or {@code null} if it is not available .
|
||||
*/
|
||||
public String getTypeDescription(File f) {
|
||||
return null;
|
||||
@ -94,6 +106,10 @@ public abstract class FileView {
|
||||
|
||||
/**
|
||||
* The icon that represents this file in the <code>JFileChooser</code>.
|
||||
*
|
||||
* @param f a {@code File} object
|
||||
* @return an {@code Icon} which represents the specified {@code File} or
|
||||
* {@code null} if it is not available.
|
||||
*/
|
||||
public Icon getIcon(File f) {
|
||||
return null;
|
||||
@ -103,6 +119,12 @@ public abstract class FileView {
|
||||
* Whether the directory is traversable or not. This might be
|
||||
* useful, for example, if you want a directory to represent
|
||||
* a compound document and don't want the user to descend into it.
|
||||
*
|
||||
* @param f a {@code File} object representing a directory
|
||||
* @return {@code true} if the directory is traversable,
|
||||
* {@code false} if it is not, and {@code null} if the
|
||||
* file system should be checked.
|
||||
* @see FileSystemView#isTraversable
|
||||
*/
|
||||
public Boolean isTraversable(File f) {
|
||||
return null;
|
||||
|
||||
@ -59,6 +59,8 @@ class AttributeList implements DTDConstants, Serializable {
|
||||
|
||||
/**
|
||||
* Create an attribute list element.
|
||||
*
|
||||
* @param name the attribute name
|
||||
*/
|
||||
public AttributeList(String name) {
|
||||
this.name = name;
|
||||
@ -66,6 +68,13 @@ class AttributeList implements DTDConstants, Serializable {
|
||||
|
||||
/**
|
||||
* Create an attribute list element.
|
||||
*
|
||||
* @param name the attribute name
|
||||
* @param type the attribute type
|
||||
* @param modifier the attribute modifier
|
||||
* @param value the default attribute value
|
||||
* @param values the possible attribute values
|
||||
* @param next the next attribute in the list
|
||||
*/
|
||||
public AttributeList(String name, int type, int modifier, String value, Vector<?> values, AttributeList next) {
|
||||
this.name = name;
|
||||
|
||||
@ -62,6 +62,8 @@ public final class ContentModel implements Serializable {
|
||||
|
||||
/**
|
||||
* Create a content model for an element.
|
||||
*
|
||||
* @param content the element
|
||||
*/
|
||||
public ContentModel(Element content) {
|
||||
this(0, content, null);
|
||||
@ -69,6 +71,9 @@ public final class ContentModel implements Serializable {
|
||||
|
||||
/**
|
||||
* Create a content model of a particular type.
|
||||
*
|
||||
* @param type the type
|
||||
* @param content the content
|
||||
*/
|
||||
public ContentModel(int type, ContentModel content) {
|
||||
this(type, content, null);
|
||||
@ -76,6 +81,10 @@ public final class ContentModel implements Serializable {
|
||||
|
||||
/**
|
||||
* Create a content model of a particular type.
|
||||
*
|
||||
* @param type the type
|
||||
* @param content the content
|
||||
* @param next the next content model
|
||||
*/
|
||||
public ContentModel(int type, Object content, ContentModel next) {
|
||||
this.type = type;
|
||||
@ -86,6 +95,9 @@ public final class ContentModel implements Serializable {
|
||||
/**
|
||||
* Return true if the content model could
|
||||
* match an empty input stream.
|
||||
*
|
||||
* @return {@code true} if the content model could
|
||||
* match an empty input stream
|
||||
*/
|
||||
public boolean empty() {
|
||||
switch (type) {
|
||||
@ -119,6 +131,8 @@ public final class ContentModel implements Serializable {
|
||||
/**
|
||||
* Update elemVec with the list of elements that are
|
||||
* part of the this contentModel.
|
||||
*
|
||||
* @param elemVec the list of elements
|
||||
*/
|
||||
public void getElements(Vector<Element> elemVec) {
|
||||
switch (type) {
|
||||
@ -148,6 +162,11 @@ public final class ContentModel implements Serializable {
|
||||
/**
|
||||
* Return true if the token could potentially be the
|
||||
* first token in the input stream.
|
||||
*
|
||||
* @param token the token
|
||||
*
|
||||
* @return {@code true} if the token could potentially be the first token
|
||||
* in the input stream
|
||||
*/
|
||||
public boolean first(Object token) {
|
||||
switch (type) {
|
||||
@ -206,6 +225,8 @@ public final class ContentModel implements Serializable {
|
||||
|
||||
/**
|
||||
* Return the element that must be next.
|
||||
*
|
||||
* @return the element that must be next
|
||||
*/
|
||||
public Element first() {
|
||||
switch (type) {
|
||||
@ -226,6 +247,8 @@ public final class ContentModel implements Serializable {
|
||||
|
||||
/**
|
||||
* Convert to a string.
|
||||
*
|
||||
* @return the string representation of this {@code ContentModel}
|
||||
*/
|
||||
public String toString() {
|
||||
switch (type) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -102,6 +102,7 @@ class DTD implements DTDConstants {
|
||||
|
||||
/**
|
||||
* Gets an entity by name.
|
||||
* @param name the entity name
|
||||
* @return the <code>Entity</code> corresponding to the
|
||||
* <code>name</code> <code>String</code>
|
||||
*/
|
||||
@ -111,6 +112,7 @@ class DTD implements DTDConstants {
|
||||
|
||||
/**
|
||||
* Gets a character entity.
|
||||
* @param ch the character
|
||||
* @return the <code>Entity</code> corresponding to the
|
||||
* <code>ch</code> character
|
||||
*/
|
||||
@ -193,13 +195,15 @@ class DTD implements DTDConstants {
|
||||
* specified parameters. If one doesn't exist, a new
|
||||
* one is created and returned.
|
||||
*
|
||||
* @param name the name of the <code>Element</code>
|
||||
* @param type the type of the <code>Element</code>
|
||||
* @param omitStart <code>true</code> if start should be omitted
|
||||
* @param omitEnd <code>true</code> if end should be omitted
|
||||
* @param content the <code>ContentModel</code>
|
||||
* @param atts the <code>AttributeList</code> specifying the
|
||||
* <code>Element</code>
|
||||
* @param name the name of the <code>Element</code>
|
||||
* @param type the type of the <code>Element</code>
|
||||
* @param omitStart <code>true</code> if start should be omitted
|
||||
* @param omitEnd <code>true</code> if end should be omitted
|
||||
* @param content the <code>ContentModel</code>
|
||||
* @param exclusions the set of elements that must not occur inside the element
|
||||
* @param inclusions the set of elements that can occur inside the element
|
||||
* @param atts the <code>AttributeList</code> specifying the
|
||||
* <code>Element</code>
|
||||
* @return the <code>Element</code> specified
|
||||
*/
|
||||
public Element defineElement(String name, int type,
|
||||
@ -231,6 +235,8 @@ class DTD implements DTDConstants {
|
||||
/**
|
||||
* Creates and returns a character <code>Entity</code>.
|
||||
* @param name the entity's name
|
||||
* @param type the entity's type
|
||||
* @param ch the entity's value (character)
|
||||
* @return the new character <code>Entity</code>
|
||||
*/
|
||||
public Entity defEntity(String name, int type, int ch) {
|
||||
@ -241,6 +247,8 @@ class DTD implements DTDConstants {
|
||||
/**
|
||||
* Creates and returns an <code>Entity</code>.
|
||||
* @param name the entity's name
|
||||
* @param type the entity's type
|
||||
* @param str the entity's data section
|
||||
* @return the new <code>Entity</code>
|
||||
*/
|
||||
protected Entity defEntity(String name, int type, String str) {
|
||||
@ -252,7 +260,14 @@ class DTD implements DTDConstants {
|
||||
|
||||
/**
|
||||
* Creates and returns an <code>Element</code>.
|
||||
* @param name the element's name
|
||||
* @param name the element's name
|
||||
* @param type the element's type
|
||||
* @param omitStart {@code true} if the element needs no starting tag
|
||||
* @param omitEnd {@code true} if the element needs no closing tag
|
||||
* @param content the element's content
|
||||
* @param exclusions the elements that must be excluded from the content of the element
|
||||
* @param inclusions the elements that can be included as the content of the element
|
||||
* @param atts the attributes of the element
|
||||
* @return the new <code>Element</code>
|
||||
*/
|
||||
protected Element defElement(String name, int type,
|
||||
@ -280,11 +295,18 @@ class DTD implements DTDConstants {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns an <code>AttributeList</code>.
|
||||
* @param name the attribute list's name
|
||||
* Creates and returns an <code>AttributeList</code> responding to a new attribute.
|
||||
* @param name the attribute's name
|
||||
* @param type the attribute's type
|
||||
* @param modifier the attribute's modifier
|
||||
* @param value the default value of the attribute
|
||||
* @param values the allowed values for the attribute (multiple values could be separated by '|')
|
||||
* @param atts the previous attribute of the element; to be placed to {@code AttributeList.next},
|
||||
* creating a linked list
|
||||
* @return the new <code>AttributeList</code>
|
||||
*/
|
||||
protected AttributeList defAttributeList(String name, int type, int modifier, String value, String values, AttributeList atts) {
|
||||
protected AttributeList defAttributeList(String name, int type, int modifier,
|
||||
String value, String values, AttributeList atts) {
|
||||
Vector<String> vals = null;
|
||||
if (values != null) {
|
||||
vals = new Vector<String>();
|
||||
@ -301,6 +323,8 @@ class DTD implements DTDConstants {
|
||||
/**
|
||||
* Creates and returns a new content model.
|
||||
* @param type the type of the new content model
|
||||
* @param obj the content of the content model
|
||||
* @param next pointer to the next content model
|
||||
* @return the new <code>ContentModel</code>
|
||||
*/
|
||||
protected ContentModel defContentModel(int type, Object obj, ContentModel next) {
|
||||
@ -332,6 +356,7 @@ class DTD implements DTDConstants {
|
||||
*
|
||||
* @param name the name of the DTD
|
||||
* @return the DTD which corresponds to <code>name</code>
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
public static DTD getDTD(String name) throws IOException {
|
||||
name = name.toLowerCase();
|
||||
@ -359,6 +384,7 @@ class DTD implements DTDConstants {
|
||||
/**
|
||||
* Recreates a DTD from an archived format.
|
||||
* @param in the <code>DataInputStream</code> to read from
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
public void read(DataInputStream in) throws IOException {
|
||||
if (in.readInt() != FILE_VERSION) {
|
||||
|
||||
@ -64,6 +64,9 @@ class Element implements DTDConstants, Serializable {
|
||||
|
||||
/**
|
||||
* Create a new element.
|
||||
*
|
||||
* @param name the name of the element
|
||||
* @param index the index
|
||||
*/
|
||||
Element(String name, int index) {
|
||||
this.name = name;
|
||||
@ -84,6 +87,8 @@ class Element implements DTDConstants, Serializable {
|
||||
|
||||
/**
|
||||
* Get the name of the element.
|
||||
*
|
||||
* @return the name of the element
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
@ -91,6 +96,8 @@ class Element implements DTDConstants, Serializable {
|
||||
|
||||
/**
|
||||
* Return true if the start tag can be omitted.
|
||||
*
|
||||
* @return {@code true} if the start tag can be omitted
|
||||
*/
|
||||
public boolean omitStart() {
|
||||
return oStart;
|
||||
@ -98,6 +105,8 @@ class Element implements DTDConstants, Serializable {
|
||||
|
||||
/**
|
||||
* Return true if the end tag can be omitted.
|
||||
*
|
||||
* @return {@code true} if the end tag can be omitted
|
||||
*/
|
||||
public boolean omitEnd() {
|
||||
return oEnd;
|
||||
@ -105,6 +114,8 @@ class Element implements DTDConstants, Serializable {
|
||||
|
||||
/**
|
||||
* Get type.
|
||||
*
|
||||
* @return the type of the element
|
||||
*/
|
||||
public int getType() {
|
||||
return type;
|
||||
@ -112,6 +123,8 @@ class Element implements DTDConstants, Serializable {
|
||||
|
||||
/**
|
||||
* Get content model
|
||||
*
|
||||
* @return the content model
|
||||
*/
|
||||
public ContentModel getContent() {
|
||||
return content;
|
||||
@ -119,6 +132,8 @@ class Element implements DTDConstants, Serializable {
|
||||
|
||||
/**
|
||||
* Get the attributes.
|
||||
*
|
||||
* @return the {@code AttributeList} specifying the element
|
||||
*/
|
||||
public AttributeList getAttributes() {
|
||||
return atts;
|
||||
@ -126,6 +141,8 @@ class Element implements DTDConstants, Serializable {
|
||||
|
||||
/**
|
||||
* Get index.
|
||||
*
|
||||
* @return the element index
|
||||
*/
|
||||
public int getIndex() {
|
||||
return index;
|
||||
@ -133,6 +150,8 @@ class Element implements DTDConstants, Serializable {
|
||||
|
||||
/**
|
||||
* Check if empty
|
||||
*
|
||||
* @return true if the current element is empty
|
||||
*/
|
||||
public boolean isEmpty() {
|
||||
return type == EMPTY;
|
||||
@ -140,6 +159,8 @@ class Element implements DTDConstants, Serializable {
|
||||
|
||||
/**
|
||||
* Convert to a string.
|
||||
*
|
||||
* @return a string representation for the given {@code Element} instance
|
||||
*/
|
||||
public String toString() {
|
||||
return name;
|
||||
@ -147,6 +168,10 @@ class Element implements DTDConstants, Serializable {
|
||||
|
||||
/**
|
||||
* Get an attribute by name.
|
||||
*
|
||||
* @param name the attribute name
|
||||
*
|
||||
* @return the {@code AttributeList} for the given {@code name}
|
||||
*/
|
||||
public AttributeList getAttribute(String name) {
|
||||
for (AttributeList a = atts ; a != null ; a = a.next) {
|
||||
@ -159,10 +184,14 @@ class Element implements DTDConstants, Serializable {
|
||||
|
||||
/**
|
||||
* Get an attribute by value.
|
||||
*
|
||||
* @param value the string representation of value
|
||||
*
|
||||
* @return the {@code AttributeList} for the given {@code value}
|
||||
*/
|
||||
public AttributeList getAttributeByValue(String name) {
|
||||
public AttributeList getAttributeByValue(String value) {
|
||||
for (AttributeList a = atts ; a != null ; a = a.next) {
|
||||
if ((a.values != null) && a.values.contains(name)) {
|
||||
if ((a.values != null) && a.values.contains(value)) {
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
@ -216,6 +216,8 @@ class Parser implements DTDConstants {
|
||||
* the current comment tag, text, block.... This is provided for
|
||||
* subclassers that wish to know the start of the current block when
|
||||
* called with one of the handleXXX methods.
|
||||
*
|
||||
* @return the start position of the current block
|
||||
*/
|
||||
int getBlockStartPosition() {
|
||||
return Math.max(0, lastBlockStartPos - 1);
|
||||
@ -223,31 +225,55 @@ class Parser implements DTDConstants {
|
||||
|
||||
/**
|
||||
* Makes a TagElement.
|
||||
*
|
||||
* @param elem the element storing the tag definition
|
||||
* @param fictional the value of the flag "{@code fictional}" to be set for the tag
|
||||
*
|
||||
* @return the created {@code TagElement}
|
||||
*/
|
||||
protected TagElement makeTag(Element elem, boolean fictional) {
|
||||
return new TagElement(elem, fictional);
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a TagElement.
|
||||
*
|
||||
* @param elem the element storing the tag definition
|
||||
*
|
||||
* @return the created {@code TagElement}
|
||||
*/
|
||||
protected TagElement makeTag(Element elem) {
|
||||
return makeTag(elem, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns attributes for the current tag.
|
||||
*
|
||||
* @return {@code SimpleAttributeSet} containing the attributes
|
||||
*/
|
||||
protected SimpleAttributeSet getAttributes() {
|
||||
return attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the current attributes.
|
||||
*/
|
||||
protected void flushAttributes() {
|
||||
attributes.removeAttributes(attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when PCDATA is encountered.
|
||||
*
|
||||
* @param text the section text
|
||||
*/
|
||||
protected void handleText(char text[]) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when an HTML title tag is encountered.
|
||||
*
|
||||
* @param text the title text
|
||||
*/
|
||||
protected void handleTitle(char text[]) {
|
||||
// default behavior is to call handleText. Subclasses
|
||||
@ -257,10 +283,15 @@ class Parser implements DTDConstants {
|
||||
|
||||
/**
|
||||
* Called when an HTML comment is encountered.
|
||||
*
|
||||
* @param text the comment being handled
|
||||
*/
|
||||
protected void handleComment(char text[]) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the content terminates without closing the HTML comment.
|
||||
*/
|
||||
protected void handleEOFInComment() {
|
||||
// We've reached EOF. Our recovery strategy is to
|
||||
// see if we have more than one line in the comment;
|
||||
@ -288,24 +319,34 @@ class Parser implements DTDConstants {
|
||||
|
||||
/**
|
||||
* Called when an empty tag is encountered.
|
||||
*
|
||||
* @param tag the tag being handled
|
||||
* @throws ChangedCharSetException if the document charset was changed
|
||||
*/
|
||||
protected void handleEmptyTag(TagElement tag) throws ChangedCharSetException {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a start tag is encountered.
|
||||
*
|
||||
* @param tag the tag being handled
|
||||
*/
|
||||
protected void handleStartTag(TagElement tag) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when an end tag is encountered.
|
||||
*
|
||||
* @param tag the tag being handled
|
||||
*/
|
||||
protected void handleEndTag(TagElement tag) {
|
||||
}
|
||||
|
||||
/**
|
||||
* An error has occurred.
|
||||
*
|
||||
* @param ln the number of line containing the error
|
||||
* @param msg the error message
|
||||
*/
|
||||
protected void handleError(int ln, String msg) {
|
||||
/*
|
||||
@ -368,7 +409,12 @@ class Parser implements DTDConstants {
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke the error handler.
|
||||
* Invokes the error handler.
|
||||
*
|
||||
* @param err the error type
|
||||
* @param arg1 the 1st error message argument
|
||||
* @param arg2 the 2nd error message argument
|
||||
* @param arg3 the 3rd error message argument
|
||||
*/
|
||||
protected void error(String err, String arg1, String arg2,
|
||||
String arg3) {
|
||||
@ -390,6 +436,9 @@ class Parser implements DTDConstants {
|
||||
* Handle a start tag. The new tag is pushed
|
||||
* onto the tag stack. The attribute list is
|
||||
* checked for required attributes.
|
||||
*
|
||||
* @param tag the tag
|
||||
* @throws ChangedCharSetException if the document charset was changed
|
||||
*/
|
||||
protected void startTag(TagElement tag) throws ChangedCharSetException {
|
||||
Element elem = tag.getElement();
|
||||
@ -441,6 +490,9 @@ class Parser implements DTDConstants {
|
||||
/**
|
||||
* Handle an end tag. The end tag is popped
|
||||
* from the tag stack.
|
||||
*
|
||||
* @param omitted {@code true} if the tag is no actually present in the
|
||||
* document, but is supposed by the parser
|
||||
*/
|
||||
protected void endTag(boolean omitted) {
|
||||
handleText(stack.tag);
|
||||
@ -498,6 +550,8 @@ class Parser implements DTDConstants {
|
||||
|
||||
/**
|
||||
* Marks the first time a tag has been seen in a document
|
||||
*
|
||||
* @param elem the element represented by the tag
|
||||
*/
|
||||
|
||||
protected void markFirstTime(Element elem) {
|
||||
@ -1478,8 +1532,11 @@ class Parser implements DTDConstants {
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses th Document Declaration Type markup declaration.
|
||||
* Parses the Document Type Declaration markup declaration.
|
||||
* Currently ignores it.
|
||||
*
|
||||
* @return the string representation of the markup declaration
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
public String parseDTDMarkup() throws IOException {
|
||||
|
||||
@ -1523,6 +1580,11 @@ class Parser implements DTDConstants {
|
||||
* Parse markup declarations.
|
||||
* Currently only handles the Document Type Declaration markup.
|
||||
* Returns true if it is a markup declaration false otherwise.
|
||||
*
|
||||
* @param strBuff the markup declaration
|
||||
* @return {@code true} if this is a valid markup declaration;
|
||||
* otherwise {@code false}
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
protected boolean parseMarkupDeclarations(StringBuffer strBuff) throws IOException {
|
||||
|
||||
@ -2236,6 +2298,9 @@ class Parser implements DTDConstants {
|
||||
|
||||
/**
|
||||
* Parse an HTML stream, given a DTD.
|
||||
*
|
||||
* @param in the reader to read the source from
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
public synchronized void parse(Reader in) throws IOException {
|
||||
this.in = in;
|
||||
|
||||
@ -149,6 +149,8 @@ public abstract class AbstractLayoutCache implements RowMapper {
|
||||
* Returns the height of each row. If the returned value is less than
|
||||
* or equal to 0 the height for each row is determined by the
|
||||
* renderer.
|
||||
*
|
||||
* @return the height of each row
|
||||
*/
|
||||
public int getRowHeight() {
|
||||
return rowHeight;
|
||||
@ -263,6 +265,9 @@ public abstract class AbstractLayoutCache implements RowMapper {
|
||||
|
||||
/**
|
||||
* Returns true if the value identified by row is currently expanded.
|
||||
*
|
||||
* @param path TreePath to check
|
||||
* @return whether TreePath is expanded
|
||||
*/
|
||||
public abstract boolean isExpanded(TreePath path);
|
||||
|
||||
@ -496,6 +501,8 @@ public abstract class AbstractLayoutCache implements RowMapper {
|
||||
|
||||
/**
|
||||
* Returns true if the height of each row is a fixed size.
|
||||
*
|
||||
* @return whether the height of each row is a fixed size
|
||||
*/
|
||||
protected boolean isFixedRowHeight() {
|
||||
return (rowHeight > 0);
|
||||
|
||||
@ -534,6 +534,7 @@ public class DefaultMutableTreeNode implements Cloneable,
|
||||
* Returns true if and only if <code>aNode</code> is in the same tree
|
||||
* as this node. Returns false if <code>aNode</code> is null.
|
||||
*
|
||||
* @param aNode node to find common ancestor with
|
||||
* @see #getSharedAncestor
|
||||
* @see #getRoot
|
||||
* @return true if <code>aNode</code> is in the same tree as this node;
|
||||
@ -638,6 +639,8 @@ public class DefaultMutableTreeNode implements Cloneable,
|
||||
* Returns the user object path, from the root, to get to this node.
|
||||
* If some of the TreeNodes in the path have null user objects, the
|
||||
* returned path will contain nulls.
|
||||
*
|
||||
* @return the user object path, from the root, to get to this node
|
||||
*/
|
||||
public Object[] getUserObjectPath() {
|
||||
TreeNode[] realPath = getPath();
|
||||
@ -828,6 +831,7 @@ public class DefaultMutableTreeNode implements Cloneable,
|
||||
* Modifying the tree by inserting, removing, or moving a node invalidates
|
||||
* any enumerations created before the modification.
|
||||
*
|
||||
* @param ancestor the node to start enumeration from
|
||||
* @see #isNodeAncestor
|
||||
* @see #isNodeDescendant
|
||||
* @exception IllegalArgumentException if <code>ancestor</code> is
|
||||
@ -848,6 +852,7 @@ public class DefaultMutableTreeNode implements Cloneable,
|
||||
* Returns true if <code>aNode</code> is a child of this node. If
|
||||
* <code>aNode</code> is null, this method returns false.
|
||||
*
|
||||
* @param aNode the node to determinate whether it is a child
|
||||
* @return true if <code>aNode</code> is a child of this node; false if
|
||||
* <code>aNode</code> is null
|
||||
*/
|
||||
@ -906,6 +911,7 @@ public class DefaultMutableTreeNode implements Cloneable,
|
||||
* <code>aChild</code> and is O(n) where n is the number of children; to
|
||||
* traverse the entire array of children, use an enumeration instead.
|
||||
*
|
||||
* @param aChild the child node to look for next child after it
|
||||
* @see #children
|
||||
* @exception IllegalArgumentException if <code>aChild</code> is
|
||||
* null or is not a child of this node
|
||||
@ -938,6 +944,7 @@ public class DefaultMutableTreeNode implements Cloneable,
|
||||
* performs a linear search of this node's children for <code>aChild</code>
|
||||
* and is O(n) where n is the number of children.
|
||||
*
|
||||
* @param aChild the child node to look for previous child before it
|
||||
* @exception IllegalArgumentException if <code>aChild</code> is null
|
||||
* or is not a child of this node
|
||||
* @return the child of this node that immediately precedes
|
||||
|
||||
@ -405,7 +405,9 @@ public class DefaultTreeCellEditor implements ActionListener, TreeCellEditor,
|
||||
/**
|
||||
* Returns true if <code>event</code> is a <code>MouseEvent</code>
|
||||
* and the click count is 1.
|
||||
* @param event the event being studied
|
||||
*
|
||||
* @param event the event being studied
|
||||
* @return whether {@code event} should starts the editing timer
|
||||
*/
|
||||
protected boolean shouldStartEditingTimer(EventObject event) {
|
||||
if((event instanceof MouseEvent) &&
|
||||
@ -433,7 +435,9 @@ public class DefaultTreeCellEditor implements ActionListener, TreeCellEditor,
|
||||
* Returns true if <code>event</code> is <code>null</code>,
|
||||
* or it is a <code>MouseEvent</code> with a click count > 2
|
||||
* and <code>inHitRegion</code> returns true.
|
||||
*
|
||||
* @param event the event being studied
|
||||
* @return whether editing can be started for the given {@code event}
|
||||
*/
|
||||
protected boolean canEditImmediately(EventObject event) {
|
||||
if((event instanceof MouseEvent) &&
|
||||
@ -513,6 +517,8 @@ public class DefaultTreeCellEditor implements ActionListener, TreeCellEditor,
|
||||
/**
|
||||
* Creates the container to manage placement of
|
||||
* <code>editingComponent</code>.
|
||||
*
|
||||
* @return new Container object
|
||||
*/
|
||||
protected Container createContainer() {
|
||||
return new EditorContainer();
|
||||
|
||||
@ -234,6 +234,9 @@ public class DefaultTreeCellRenderer extends JLabel implements TreeCellRenderer
|
||||
/**
|
||||
* Returns the default icon, for the current laf, that is used to
|
||||
* represent non-leaf nodes that are expanded.
|
||||
*
|
||||
* @return the default icon, for the current laf, that is used to
|
||||
* represent non-leaf nodes that are expanded.
|
||||
*/
|
||||
public Icon getDefaultOpenIcon() {
|
||||
return DefaultLookup.getIcon(this, ui, "Tree.openIcon");
|
||||
@ -242,6 +245,9 @@ public class DefaultTreeCellRenderer extends JLabel implements TreeCellRenderer
|
||||
/**
|
||||
* Returns the default icon, for the current laf, that is used to
|
||||
* represent non-leaf nodes that are not expanded.
|
||||
*
|
||||
* @return the default icon, for the current laf, that is used to
|
||||
* represent non-leaf nodes that are not expanded.
|
||||
*/
|
||||
public Icon getDefaultClosedIcon() {
|
||||
return DefaultLookup.getIcon(this, ui, "Tree.closedIcon");
|
||||
@ -250,6 +256,9 @@ public class DefaultTreeCellRenderer extends JLabel implements TreeCellRenderer
|
||||
/**
|
||||
* Returns the default icon, for the current laf, that is used to
|
||||
* represent leaf nodes.
|
||||
*
|
||||
* @return the default icon, for the current laf, that is used to
|
||||
* represent leaf nodes.
|
||||
*/
|
||||
public Icon getDefaultLeafIcon() {
|
||||
return DefaultLookup.getIcon(this, ui, "Tree.leafIcon");
|
||||
@ -257,6 +266,8 @@ public class DefaultTreeCellRenderer extends JLabel implements TreeCellRenderer
|
||||
|
||||
/**
|
||||
* Sets the icon used to represent non-leaf nodes that are expanded.
|
||||
*
|
||||
* @param newIcon the icon to be used for expanded non-leaf nodes
|
||||
*/
|
||||
public void setOpenIcon(Icon newIcon) {
|
||||
openIcon = newIcon;
|
||||
@ -264,6 +275,8 @@ public class DefaultTreeCellRenderer extends JLabel implements TreeCellRenderer
|
||||
|
||||
/**
|
||||
* Returns the icon used to represent non-leaf nodes that are expanded.
|
||||
*
|
||||
* @return the icon used to represent non-leaf nodes that are expanded
|
||||
*/
|
||||
public Icon getOpenIcon() {
|
||||
return openIcon;
|
||||
@ -271,6 +284,8 @@ public class DefaultTreeCellRenderer extends JLabel implements TreeCellRenderer
|
||||
|
||||
/**
|
||||
* Sets the icon used to represent non-leaf nodes that are not expanded.
|
||||
*
|
||||
* @param newIcon the icon to be used for not expanded non-leaf nodes
|
||||
*/
|
||||
public void setClosedIcon(Icon newIcon) {
|
||||
closedIcon = newIcon;
|
||||
@ -279,6 +294,9 @@ public class DefaultTreeCellRenderer extends JLabel implements TreeCellRenderer
|
||||
/**
|
||||
* Returns the icon used to represent non-leaf nodes that are not
|
||||
* expanded.
|
||||
*
|
||||
* @return the icon used to represent non-leaf nodes that are not
|
||||
* expanded
|
||||
*/
|
||||
public Icon getClosedIcon() {
|
||||
return closedIcon;
|
||||
@ -286,6 +304,8 @@ public class DefaultTreeCellRenderer extends JLabel implements TreeCellRenderer
|
||||
|
||||
/**
|
||||
* Sets the icon used to represent leaf nodes.
|
||||
*
|
||||
* @param newIcon icon to be used for leaf nodes
|
||||
*/
|
||||
public void setLeafIcon(Icon newIcon) {
|
||||
leafIcon = newIcon;
|
||||
@ -293,6 +313,8 @@ public class DefaultTreeCellRenderer extends JLabel implements TreeCellRenderer
|
||||
|
||||
/**
|
||||
* Returns the icon used to represent leaf nodes.
|
||||
*
|
||||
* @return the icon used to represent leaf nodes
|
||||
*/
|
||||
public Icon getLeafIcon() {
|
||||
return leafIcon;
|
||||
@ -300,6 +322,8 @@ public class DefaultTreeCellRenderer extends JLabel implements TreeCellRenderer
|
||||
|
||||
/**
|
||||
* Sets the color the text is drawn with when the node is selected.
|
||||
*
|
||||
* @param newColor color to be used for text when the node is selected
|
||||
*/
|
||||
public void setTextSelectionColor(Color newColor) {
|
||||
textSelectionColor = newColor;
|
||||
@ -307,6 +331,8 @@ public class DefaultTreeCellRenderer extends JLabel implements TreeCellRenderer
|
||||
|
||||
/**
|
||||
* Returns the color the text is drawn with when the node is selected.
|
||||
*
|
||||
* @return the color the text is drawn with when the node is selected
|
||||
*/
|
||||
public Color getTextSelectionColor() {
|
||||
return textSelectionColor;
|
||||
@ -314,6 +340,8 @@ public class DefaultTreeCellRenderer extends JLabel implements TreeCellRenderer
|
||||
|
||||
/**
|
||||
* Sets the color the text is drawn with when the node isn't selected.
|
||||
*
|
||||
* @param newColor color to be used for text when the node isn't selected
|
||||
*/
|
||||
public void setTextNonSelectionColor(Color newColor) {
|
||||
textNonSelectionColor = newColor;
|
||||
@ -321,6 +349,8 @@ public class DefaultTreeCellRenderer extends JLabel implements TreeCellRenderer
|
||||
|
||||
/**
|
||||
* Returns the color the text is drawn with when the node isn't selected.
|
||||
*
|
||||
* @return the color the text is drawn with when the node isn't selected.
|
||||
*/
|
||||
public Color getTextNonSelectionColor() {
|
||||
return textNonSelectionColor;
|
||||
@ -328,6 +358,8 @@ public class DefaultTreeCellRenderer extends JLabel implements TreeCellRenderer
|
||||
|
||||
/**
|
||||
* Sets the color to use for the background if node is selected.
|
||||
*
|
||||
* @param newColor to be used for the background if the node is selected
|
||||
*/
|
||||
public void setBackgroundSelectionColor(Color newColor) {
|
||||
backgroundSelectionColor = newColor;
|
||||
@ -336,6 +368,8 @@ public class DefaultTreeCellRenderer extends JLabel implements TreeCellRenderer
|
||||
|
||||
/**
|
||||
* Returns the color to use for the background if node is selected.
|
||||
*
|
||||
* @return the color to use for the background if node is selected
|
||||
*/
|
||||
public Color getBackgroundSelectionColor() {
|
||||
return backgroundSelectionColor;
|
||||
@ -343,6 +377,8 @@ public class DefaultTreeCellRenderer extends JLabel implements TreeCellRenderer
|
||||
|
||||
/**
|
||||
* Sets the background color to be used for non selected nodes.
|
||||
*
|
||||
* @param newColor color to be used for the background for non selected nodes
|
||||
*/
|
||||
public void setBackgroundNonSelectionColor(Color newColor) {
|
||||
backgroundNonSelectionColor = newColor;
|
||||
@ -350,6 +386,8 @@ public class DefaultTreeCellRenderer extends JLabel implements TreeCellRenderer
|
||||
|
||||
/**
|
||||
* Returns the background color to be used for non selected nodes.
|
||||
*
|
||||
* @return the background color to be used for non selected nodes.
|
||||
*/
|
||||
public Color getBackgroundNonSelectionColor() {
|
||||
return backgroundNonSelectionColor;
|
||||
@ -357,6 +395,8 @@ public class DefaultTreeCellRenderer extends JLabel implements TreeCellRenderer
|
||||
|
||||
/**
|
||||
* Sets the color to use for the border.
|
||||
*
|
||||
* @param newColor color to be used for the border
|
||||
*/
|
||||
public void setBorderSelectionColor(Color newColor) {
|
||||
borderSelectionColor = newColor;
|
||||
@ -364,6 +404,8 @@ public class DefaultTreeCellRenderer extends JLabel implements TreeCellRenderer
|
||||
|
||||
/**
|
||||
* Returns the color the border is drawn.
|
||||
*
|
||||
* @return the color the border is drawn
|
||||
*/
|
||||
public Color getBorderSelectionColor() {
|
||||
return borderSelectionColor;
|
||||
|
||||
@ -105,6 +105,9 @@ public class DefaultTreeModel implements Serializable, TreeModel {
|
||||
* Sets whether or not to test leafness by asking getAllowsChildren()
|
||||
* or isLeaf() to the TreeNodes. If newvalue is true, getAllowsChildren()
|
||||
* is messaged, otherwise isLeaf() is messaged.
|
||||
*
|
||||
* @param newValue if true, getAllowsChildren() is messaged, otherwise
|
||||
* isLeaf() is messaged
|
||||
*/
|
||||
public void setAsksAllowsChildren(boolean newValue) {
|
||||
asksAllowsChildren = newValue;
|
||||
@ -125,6 +128,8 @@ public class DefaultTreeModel implements Serializable, TreeModel {
|
||||
/**
|
||||
* Sets the root to <code>root</code>. A null <code>root</code> implies
|
||||
* the tree is to display nothing, and is legal.
|
||||
*
|
||||
* @param root new value of tree root
|
||||
*/
|
||||
public void setRoot(TreeNode root) {
|
||||
Object oldRoot = this.root;
|
||||
@ -231,6 +236,10 @@ public class DefaultTreeModel implements Serializable, TreeModel {
|
||||
* This will then message nodesWereInserted to create the appropriate
|
||||
* event. This is the preferred way to add children as it will create
|
||||
* the appropriate event.
|
||||
*
|
||||
* @param newChild child node to be inserted
|
||||
* @param parent node to which children new node will be added
|
||||
* @param index index of parent's children
|
||||
*/
|
||||
public void insertNodeInto(MutableTreeNode newChild,
|
||||
MutableTreeNode parent, int index){
|
||||
@ -247,6 +256,8 @@ public class DefaultTreeModel implements Serializable, TreeModel {
|
||||
* nodesWereRemoved to create the appropriate event. This is the
|
||||
* preferred way to remove a node as it handles the event creation
|
||||
* for you.
|
||||
*
|
||||
* @param node the node to be removed from it's parrent
|
||||
*/
|
||||
public void removeNodeFromParent(MutableTreeNode node) {
|
||||
MutableTreeNode parent = (MutableTreeNode)node.getParent();
|
||||
@ -266,6 +277,8 @@ public class DefaultTreeModel implements Serializable, TreeModel {
|
||||
/**
|
||||
* Invoke this method after you've changed how node is to be
|
||||
* represented in the tree.
|
||||
*
|
||||
* @param node the changed node
|
||||
*/
|
||||
public void nodeChanged(TreeNode node) {
|
||||
if(listenerList != null && node != null) {
|
||||
@ -303,6 +316,9 @@ public class DefaultTreeModel implements Serializable, TreeModel {
|
||||
* Invoke this method after you've inserted some TreeNodes into
|
||||
* node. childIndices should be the index of the new elements and
|
||||
* must be sorted in ascending order.
|
||||
*
|
||||
* @param node parent node which children count been incremented
|
||||
* @param childIndices indexes of inserted children
|
||||
*/
|
||||
public void nodesWereInserted(TreeNode node, int[] childIndices) {
|
||||
if(listenerList != null && node != null && childIndices != null
|
||||
@ -322,6 +338,10 @@ public class DefaultTreeModel implements Serializable, TreeModel {
|
||||
* node. childIndices should be the index of the removed elements and
|
||||
* must be sorted in ascending order. And removedChildren should be
|
||||
* the array of the children objects that were removed.
|
||||
*
|
||||
* @param node parent node which childred were removed
|
||||
* @param childIndices indexes of removed childs
|
||||
* @param removedChildren array of the children objects that were removed
|
||||
*/
|
||||
public void nodesWereRemoved(TreeNode node, int[] childIndices,
|
||||
Object[] removedChildren) {
|
||||
@ -334,6 +354,9 @@ public class DefaultTreeModel implements Serializable, TreeModel {
|
||||
/**
|
||||
* Invoke this method after you've changed how the children identified by
|
||||
* childIndicies are to be represented in the tree.
|
||||
*
|
||||
* @param node changed node
|
||||
* @param childIndices indexes of changed children
|
||||
*/
|
||||
public void nodesChanged(TreeNode node, int[] childIndices) {
|
||||
if(node != null) {
|
||||
@ -360,6 +383,8 @@ public class DefaultTreeModel implements Serializable, TreeModel {
|
||||
* Invoke this method if you've totally changed the children of
|
||||
* node and its children's children... This will post a
|
||||
* treeStructureChanged event.
|
||||
*
|
||||
* @param node changed node
|
||||
*/
|
||||
public void nodeStructureChanged(TreeNode node) {
|
||||
if(node != null) {
|
||||
@ -374,6 +399,7 @@ public class DefaultTreeModel implements Serializable, TreeModel {
|
||||
* tree.
|
||||
*
|
||||
* @param aNode the TreeNode to get the path for
|
||||
* @return an array of TreeNodes giving the path from the root
|
||||
*/
|
||||
public TreeNode[] getPathToRoot(TreeNode aNode) {
|
||||
return getPathToRoot(aNode, 0);
|
||||
|
||||
@ -618,6 +618,9 @@ public class DefaultTreeSelectionModel implements Cloneable, Serializable, TreeS
|
||||
/**
|
||||
* Notifies all listeners that are registered for
|
||||
* tree selection events on this object.
|
||||
*
|
||||
* @param e the event that characterizes the change
|
||||
*
|
||||
* @see #addTreeSelectionListener
|
||||
* @see EventListenerList
|
||||
*/
|
||||
@ -920,6 +923,9 @@ public class DefaultTreeSelectionModel implements Cloneable, Serializable, TreeS
|
||||
/**
|
||||
* Returns true if the paths are contiguous,
|
||||
* or this object has no RowMapper.
|
||||
*
|
||||
* @param paths array of paths to check
|
||||
* @return whether the paths are contiguous, or this object has no RowMapper
|
||||
*/
|
||||
protected boolean arePathsContiguous(TreePath[] paths) {
|
||||
if(rowMapper == null || paths.length < 2)
|
||||
@ -968,6 +974,9 @@ public class DefaultTreeSelectionModel implements Cloneable, Serializable, TreeS
|
||||
* or the selection mode is <code>DISCONTIGUOUS_TREE_SELECTION</code>, or
|
||||
* adding the paths to the current selection still results in a
|
||||
* contiguous set of <code>TreePath</code>s.
|
||||
*
|
||||
* @param paths array of {@code TreePaths} to check
|
||||
* @return whether the particular set of {@code TreePaths} can be added
|
||||
*/
|
||||
protected boolean canPathsBeAdded(TreePath[] paths) {
|
||||
if(paths == null || paths.length == 0 || rowMapper == null ||
|
||||
@ -1019,6 +1028,10 @@ public class DefaultTreeSelectionModel implements Cloneable, Serializable, TreeS
|
||||
* Returns true if the paths can be removed without breaking the
|
||||
* continuity of the model.
|
||||
* This is rather expensive.
|
||||
*
|
||||
* @param paths array of {@code TreePath} to check
|
||||
* @return whether the paths can be removed without breaking the
|
||||
* continuity of the model
|
||||
*/
|
||||
protected boolean canPathsBeRemoved(TreePath[] paths) {
|
||||
if(rowMapper == null || selection == null ||
|
||||
@ -1072,6 +1085,9 @@ public class DefaultTreeSelectionModel implements Cloneable, Serializable, TreeS
|
||||
* instances of PathPlaceHolder.
|
||||
*
|
||||
* @deprecated As of JDK version 1.7
|
||||
*
|
||||
* @param changedPaths the vector of the changed paths
|
||||
* @param oldLeadSelection the old selection path
|
||||
*/
|
||||
@Deprecated
|
||||
protected void notifyPathChange(Vector<?> changedPaths,
|
||||
|
||||
@ -42,22 +42,31 @@ public interface MutableTreeNode extends TreeNode
|
||||
/**
|
||||
* Adds <code>child</code> to the receiver at <code>index</code>.
|
||||
* <code>child</code> will be messaged with <code>setParent</code>.
|
||||
*
|
||||
* @param child node to be added
|
||||
* @param index index of the receiver
|
||||
*/
|
||||
void insert(MutableTreeNode child, int index);
|
||||
|
||||
/**
|
||||
* Removes the child at <code>index</code> from the receiver.
|
||||
*
|
||||
* @param index index of child to be removed
|
||||
*/
|
||||
void remove(int index);
|
||||
|
||||
/**
|
||||
* Removes <code>node</code> from the receiver. <code>setParent</code>
|
||||
* will be messaged on <code>node</code>.
|
||||
*
|
||||
* @param node node to be removed from the receiver
|
||||
*/
|
||||
void remove(MutableTreeNode node);
|
||||
|
||||
/**
|
||||
* Resets the user object of the receiver to <code>object</code>.
|
||||
*
|
||||
* @param object object to be set as a receiver
|
||||
*/
|
||||
void setUserObject(Object object);
|
||||
|
||||
@ -68,6 +77,8 @@ public interface MutableTreeNode extends TreeNode
|
||||
|
||||
/**
|
||||
* Sets the parent of the receiver to <code>newParent</code>.
|
||||
*
|
||||
* @param newParent node to be set as parent of the receiver
|
||||
*/
|
||||
void setParent(MutableTreeNode newParent);
|
||||
}
|
||||
|
||||
@ -41,6 +41,10 @@ public interface RowMapper
|
||||
* the same length as that passed in, and if one of the TreePaths
|
||||
* in <code>path</code> is not valid its entry in the array should
|
||||
* be set to -1.
|
||||
*
|
||||
* @param path array of TreePath to parse
|
||||
* @return the rows that the TreePath instances in {@code path} are
|
||||
* being displayed at
|
||||
*/
|
||||
int[] getRowsForPaths(TreePath[] path);
|
||||
}
|
||||
|
||||
@ -67,7 +67,14 @@ public interface TreeCellRenderer {
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* @return the <code>Component</code> that the renderer uses to draw the value
|
||||
* @param tree the receiver is being configured for
|
||||
* @param value the value to render
|
||||
* @param selected whether node is selected
|
||||
* @param expanded whether node is expanded
|
||||
* @param leaf whether node is a lead node
|
||||
* @param row row index
|
||||
* @param hasFocus whether node has focus
|
||||
* @return the {@code Component} that the renderer uses to draw the value
|
||||
*/
|
||||
Component getTreeCellRendererComponent(JTree tree, Object value,
|
||||
boolean selected, boolean expanded,
|
||||
|
||||
@ -79,8 +79,9 @@ public interface TreeModel
|
||||
* is a valid index for <code>parent</code> (that is <code>index >= 0 &&
|
||||
* index < getChildCount(parent</code>)).
|
||||
*
|
||||
* @param parent a node in the tree, obtained from this data source
|
||||
* @return the child of <code>parent</code> at index <code>index</code>
|
||||
* @param parent a node in the tree, obtained from this data source
|
||||
* @param index index of child to be returned
|
||||
* @return the child of {@code parent} at index {@code index}
|
||||
*/
|
||||
public Object getChild(Object parent, int index);
|
||||
|
||||
|
||||
@ -49,17 +49,24 @@ public interface TreeNode
|
||||
/**
|
||||
* Returns the child <code>TreeNode</code> at index
|
||||
* <code>childIndex</code>.
|
||||
*
|
||||
* @param childIndex index of child
|
||||
* @return the child node at given index
|
||||
*/
|
||||
TreeNode getChildAt(int childIndex);
|
||||
|
||||
/**
|
||||
* Returns the number of children <code>TreeNode</code>s the receiver
|
||||
* contains.
|
||||
*
|
||||
* @return the number of children the receiver contains
|
||||
*/
|
||||
int getChildCount();
|
||||
|
||||
/**
|
||||
* Returns the parent <code>TreeNode</code> of the receiver.
|
||||
*
|
||||
* @return the parent of the receiver
|
||||
*/
|
||||
TreeNode getParent();
|
||||
|
||||
@ -67,21 +74,30 @@ public interface TreeNode
|
||||
* Returns the index of <code>node</code> in the receivers children.
|
||||
* If the receiver does not contain <code>node</code>, -1 will be
|
||||
* returned.
|
||||
*
|
||||
* @param node node to be loked for
|
||||
* @return index of specified node
|
||||
*/
|
||||
int getIndex(TreeNode node);
|
||||
|
||||
/**
|
||||
* Returns true if the receiver allows children.
|
||||
*
|
||||
* @return whether the receiver allows children
|
||||
*/
|
||||
boolean getAllowsChildren();
|
||||
|
||||
/**
|
||||
* Returns true if the receiver is a leaf.
|
||||
*
|
||||
* @return whether the receiver is a leaf
|
||||
*/
|
||||
boolean isLeaf();
|
||||
|
||||
/**
|
||||
* Returns the children of the receiver as an <code>Enumeration</code>.
|
||||
*
|
||||
* @return the children of the receiver as an {@code Enumeration}
|
||||
*/
|
||||
Enumeration children();
|
||||
}
|
||||
|
||||
@ -320,8 +320,10 @@ public class TreePath extends Object implements Serializable {
|
||||
* plus <code>child</code>. <code>child</code> is the last element
|
||||
* of the newly created {@code TreePath}.
|
||||
*
|
||||
* @param child the path element to add
|
||||
* @throws NullPointerException if {@code child} is {@code null}
|
||||
* @param child the path element to add
|
||||
* @throws NullPointerException if {@code child} is {@code null}
|
||||
* @return a new path containing all the elements of this path
|
||||
* plus {@code child}
|
||||
*/
|
||||
public TreePath pathByAddingChild(Object child) {
|
||||
if(child == null)
|
||||
|
||||
@ -109,6 +109,8 @@ public interface TreeSelectionModel
|
||||
* selected when the mode is changed to <code>SINGLE_TREE_SELECTION</code>,
|
||||
* only one TreePath will remain selected. It is up to the particular
|
||||
* implementation to decide what TreePath remains selected.
|
||||
*
|
||||
* @param mode selection mode to be set
|
||||
*/
|
||||
void setSelectionMode(int mode);
|
||||
|
||||
@ -117,6 +119,8 @@ public interface TreeSelectionModel
|
||||
* <code>SINGLE_TREE_SELECTION</code>,
|
||||
* <code>CONTIGUOUS_TREE_SELECTION</code> or
|
||||
* <code>DISCONTIGUOUS_TREE_SELECTION</code>.
|
||||
*
|
||||
* @return the current selection mode
|
||||
*/
|
||||
int getSelectionMode();
|
||||
|
||||
@ -125,7 +129,7 @@ public interface TreeSelectionModel
|
||||
* the TreeSelectionListeners are notified. If <code>path</code> is
|
||||
* null, this has the same effect as invoking <code>clearSelection</code>.
|
||||
*
|
||||
* @param path new path to select
|
||||
* @param path new path to select
|
||||
*/
|
||||
void setSelectionPath(TreePath path);
|
||||
|
||||
@ -134,7 +138,7 @@ public interface TreeSelectionModel
|
||||
* the TreeSelectionListeners are notified. If <code>paths</code> is
|
||||
* null, this has the same effect as invoking <code>clearSelection</code>.
|
||||
*
|
||||
* @param paths new selection
|
||||
* @param paths new selection
|
||||
*/
|
||||
void setSelectionPaths(TreePath[] paths);
|
||||
|
||||
@ -143,7 +147,7 @@ public interface TreeSelectionModel
|
||||
* in the selection the TreeSelectionListeners are notified. This has
|
||||
* no effect if <code>path</code> is null.
|
||||
*
|
||||
* @param path the new path to add to the current selection
|
||||
* @param path the new path to add to the current selection
|
||||
*/
|
||||
void addSelectionPath(TreePath path);
|
||||
|
||||
@ -153,7 +157,7 @@ public interface TreeSelectionModel
|
||||
* are notified. This has
|
||||
* no effect if <code>paths</code> is null.
|
||||
*
|
||||
* @param paths the new paths to add to the current selection
|
||||
* @param paths the new paths to add to the current selection
|
||||
*/
|
||||
void addSelectionPaths(TreePath[] paths);
|
||||
|
||||
@ -162,7 +166,7 @@ public interface TreeSelectionModel
|
||||
* The TreeSelectionListeners are notified. This has no effect if
|
||||
* <code>path</code> is null.
|
||||
*
|
||||
* @param path the path to remove from the selection
|
||||
* @param path the path to remove from the selection
|
||||
*/
|
||||
void removeSelectionPath(TreePath path);
|
||||
|
||||
@ -172,7 +176,7 @@ public interface TreeSelectionModel
|
||||
* are in the selection, the TreeSelectionListeners are notified.
|
||||
* This method has no effect if <code>paths</code> is null.
|
||||
*
|
||||
* @param paths the path to remove from the selection
|
||||
* @param paths the path to remove from the selection
|
||||
*/
|
||||
void removeSelectionPaths(TreePath[] paths);
|
||||
|
||||
@ -181,28 +185,39 @@ public interface TreeSelectionModel
|
||||
* up to implementors, and may not necessarily be the TreePath with
|
||||
* the smallest integer value as determined from the
|
||||
* <code>RowMapper</code>.
|
||||
*
|
||||
* @return the first path in the selection
|
||||
*/
|
||||
TreePath getSelectionPath();
|
||||
|
||||
/**
|
||||
* Returns the paths in the selection. This will return null (or an
|
||||
* empty array) if nothing is currently selected.
|
||||
*
|
||||
* @return the paths in the selection
|
||||
*/
|
||||
TreePath[] getSelectionPaths();
|
||||
|
||||
/**
|
||||
* Returns the number of paths that are selected.
|
||||
*
|
||||
* @return the number of paths that are selected
|
||||
*/
|
||||
int getSelectionCount();
|
||||
|
||||
/**
|
||||
* Returns true if the path, <code>path</code>, is in the current
|
||||
* selection.
|
||||
*
|
||||
* @param path the path to be loked for
|
||||
* @return whether the {@code path} is in the current selection
|
||||
*/
|
||||
boolean isPathSelected(TreePath path);
|
||||
|
||||
/**
|
||||
* Returns true if the selection is currently empty.
|
||||
*
|
||||
* @return whether the selection is currently empty
|
||||
*/
|
||||
boolean isSelectionEmpty();
|
||||
|
||||
@ -215,12 +230,17 @@ public interface TreeSelectionModel
|
||||
/**
|
||||
* Sets the RowMapper instance. This instance is used to determine
|
||||
* the row for a particular TreePath.
|
||||
*
|
||||
* @param newMapper RowMapper to be set
|
||||
*/
|
||||
void setRowMapper(RowMapper newMapper);
|
||||
|
||||
/**
|
||||
* Returns the RowMapper instance that is able to map a TreePath to a
|
||||
* row.
|
||||
*
|
||||
* @return the RowMapper instance that is able to map a TreePath
|
||||
* to a row
|
||||
*/
|
||||
RowMapper getRowMapper();
|
||||
|
||||
@ -228,6 +248,8 @@ public interface TreeSelectionModel
|
||||
* Returns all of the currently selected rows. This will return
|
||||
* null (or an empty array) if there are no selected TreePaths or
|
||||
* a RowMapper has not been set.
|
||||
*
|
||||
* @return all of the currently selected rows
|
||||
*/
|
||||
int[] getSelectionRows();
|
||||
|
||||
@ -235,6 +257,9 @@ public interface TreeSelectionModel
|
||||
* Returns the smallest value obtained from the RowMapper for the
|
||||
* current set of selected TreePaths. If nothing is selected,
|
||||
* or there is no RowMapper, this will return -1.
|
||||
*
|
||||
* @return the smallest value obtained from the RowMapper
|
||||
* for the current set of selected TreePaths
|
||||
*/
|
||||
int getMinSelectionRow();
|
||||
|
||||
@ -242,11 +267,17 @@ public interface TreeSelectionModel
|
||||
* Returns the largest value obtained from the RowMapper for the
|
||||
* current set of selected TreePaths. If nothing is selected,
|
||||
* or there is no RowMapper, this will return -1.
|
||||
*
|
||||
* @return the largest value obtained from the RowMapper
|
||||
* for the current set of selected TreePaths
|
||||
*/
|
||||
int getMaxSelectionRow();
|
||||
|
||||
/**
|
||||
* Returns true if the row identified by <code>row</code> is selected.
|
||||
*
|
||||
* @param row row to check
|
||||
* @return whether the row is selected
|
||||
*/
|
||||
boolean isRowSelected(int row);
|
||||
|
||||
@ -264,12 +295,16 @@ public interface TreeSelectionModel
|
||||
/**
|
||||
* Returns the lead selection index. That is the last index that was
|
||||
* added.
|
||||
*
|
||||
* @return the lead selection index
|
||||
*/
|
||||
int getLeadSelectionRow();
|
||||
|
||||
/**
|
||||
* Returns the last path that was added. This may differ from the
|
||||
* leadSelectionPath property maintained by the JTree.
|
||||
*
|
||||
* @return the last path that was added
|
||||
*/
|
||||
TreePath getLeadSelectionPath();
|
||||
|
||||
@ -280,7 +315,7 @@ public interface TreeSelectionModel
|
||||
* A PropertyChangeEvent will get fired when the selection mode
|
||||
* changes.
|
||||
*
|
||||
* @param listener the PropertyChangeListener to be added
|
||||
* @param listener the PropertyChangeListener to be added
|
||||
*/
|
||||
void addPropertyChangeListener(PropertyChangeListener listener);
|
||||
|
||||
@ -289,7 +324,7 @@ public interface TreeSelectionModel
|
||||
* This removes a PropertyChangeListener that was registered
|
||||
* for all properties.
|
||||
*
|
||||
* @param listener the PropertyChangeListener to be removed
|
||||
* @param listener the PropertyChangeListener to be removed
|
||||
*/
|
||||
void removePropertyChangeListener(PropertyChangeListener listener);
|
||||
|
||||
@ -297,7 +332,7 @@ public interface TreeSelectionModel
|
||||
* Adds x to the list of listeners that are notified each time the
|
||||
* set of selected TreePaths changes.
|
||||
*
|
||||
* @param x the new listener to be added
|
||||
* @param x the new listener to be added
|
||||
*/
|
||||
void addTreeSelectionListener(TreeSelectionListener x);
|
||||
|
||||
@ -305,7 +340,7 @@ public interface TreeSelectionModel
|
||||
* Removes x from the list of listeners that are notified each time
|
||||
* the set of selected TreePaths changes.
|
||||
*
|
||||
* @param x the listener to remove
|
||||
* @param x the listener to remove
|
||||
*/
|
||||
void removeTreeSelectionListener(TreeSelectionListener x);
|
||||
}
|
||||
|
||||
@ -82,6 +82,9 @@ public class CompoundEdit extends AbstractUndoableEdit {
|
||||
* Returns the last <code>UndoableEdit</code> in
|
||||
* <code>edits</code>, or <code>null</code>
|
||||
* if <code>edits</code> is empty.
|
||||
*
|
||||
* @return the last {@code UndoableEdit} in {@code edits},
|
||||
* or {@code null} if {@code edits} is empty.
|
||||
*/
|
||||
protected UndoableEdit lastEdit() {
|
||||
int count = edits.size();
|
||||
@ -182,6 +185,7 @@ public class CompoundEdit extends AbstractUndoableEdit {
|
||||
* received end. This generally means that edits are still being
|
||||
* added to it.
|
||||
*
|
||||
* @return whether this edit is in progress
|
||||
* @see #end
|
||||
*/
|
||||
public boolean isInProgress() {
|
||||
|
||||
@ -43,12 +43,16 @@ public interface StateEditable {
|
||||
/**
|
||||
* Upon receiving this message the receiver should place any relevant
|
||||
* state into <EM>state</EM>.
|
||||
*
|
||||
* @param state Hashtable object to store the state
|
||||
*/
|
||||
public void storeState(Hashtable<Object,Object> state);
|
||||
|
||||
/**
|
||||
* Upon receiving this message the receiver should extract any relevant
|
||||
* state out of <EM>state</EM>.
|
||||
*
|
||||
* @param state Hashtable object to restore the state from it
|
||||
*/
|
||||
public void restoreState(Hashtable<?,?> state);
|
||||
} // End of interface StateEditable
|
||||
|
||||
@ -326,6 +326,7 @@ public class UndoManager extends CompoundEdit implements UndoableEditListener {
|
||||
* Undoes all changes from the index of the next edit to
|
||||
* <code>edit</code>, updating the index of the next edit appropriately.
|
||||
*
|
||||
* @param edit the edit to be undo to
|
||||
* @throws CannotUndoException if one of the edits throws
|
||||
* <code>CannotUndoException</code>
|
||||
*/
|
||||
@ -342,6 +343,7 @@ public class UndoManager extends CompoundEdit implements UndoableEditListener {
|
||||
* Redoes all changes from the index of the next edit to
|
||||
* <code>edit</code>, updating the index of the next edit appropriately.
|
||||
*
|
||||
* @param edit the edit to be redo to
|
||||
* @throws CannotRedoException if one of the edits throws
|
||||
* <code>CannotRedoException</code>
|
||||
*/
|
||||
|
||||
@ -96,6 +96,8 @@ public class UndoableEditSupport {
|
||||
* Called only from <code>postEdit</code> and <code>endUpdate</code>. Calls
|
||||
* <code>undoableEditHappened</code> in all listeners. No synchronization
|
||||
* is performed here, since the two calling methods are synchronized.
|
||||
*
|
||||
* @param e edit to be verified
|
||||
*/
|
||||
protected void _postEdit(UndoableEdit e) {
|
||||
UndoableEditEvent ev = new UndoableEditEvent(realSource, e);
|
||||
@ -110,6 +112,8 @@ public class UndoableEditSupport {
|
||||
* DEADLOCK WARNING: Calling this method may call
|
||||
* <code>undoableEditHappened</code> in all listeners.
|
||||
* It is unwise to call this method from one of its listeners.
|
||||
*
|
||||
* @param e edit to be posted
|
||||
*/
|
||||
public synchronized void postEdit(UndoableEdit e) {
|
||||
if (updateLevel == 0) {
|
||||
@ -142,6 +146,8 @@ public class UndoableEditSupport {
|
||||
/**
|
||||
* Called only from <code>beginUpdate</code>.
|
||||
* Exposed here for subclasses' use.
|
||||
*
|
||||
* @return new created {@code CompoundEdit} object
|
||||
*/
|
||||
protected CompoundEdit createCompoundEdit() {
|
||||
return new CompoundEdit();
|
||||
|
||||
@ -370,7 +370,37 @@ public class VM {
|
||||
/**
|
||||
* Returns {@code true} if we are in a set UID program.
|
||||
*/
|
||||
public static native boolean isSetUID();
|
||||
public static boolean isSetUID() {
|
||||
long uid = getuid();
|
||||
long euid = geteuid();
|
||||
long gid = getgid();
|
||||
long egid = getegid();
|
||||
return uid != euid || gid != egid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the real user ID of the calling process,
|
||||
* or -1 if the value is not available.
|
||||
*/
|
||||
public static native long getuid();
|
||||
|
||||
/**
|
||||
* Returns the effective user ID of the calling process,
|
||||
* or -1 if the value is not available.
|
||||
*/
|
||||
public static native long geteuid();
|
||||
|
||||
/**
|
||||
* Returns the real group ID of the calling process,
|
||||
* or -1 if the value is not available.
|
||||
*/
|
||||
public static native long getgid();
|
||||
|
||||
/**
|
||||
* Returns the effective group ID of the calling process,
|
||||
* or -1 if the value is not available.
|
||||
*/
|
||||
public static native long getegid();
|
||||
|
||||
static {
|
||||
initialize();
|
||||
|
||||
@ -75,7 +75,7 @@ public final class TypeAnnotationParser {
|
||||
if (ti.getTarget() == filter)
|
||||
l.add(t);
|
||||
}
|
||||
TypeAnnotation[] typeAnnotations = l.toArray(new TypeAnnotation[0]);
|
||||
TypeAnnotation[] typeAnnotations = l.toArray(EMPTY_TYPE_ANNOTATION_ARRAY);
|
||||
return AnnotatedTypeFactory.buildAnnotatedType(type,
|
||||
LocationInfo.BASE_LOCATION,
|
||||
typeAnnotations,
|
||||
@ -245,7 +245,6 @@ public final class TypeAnnotationParser {
|
||||
if (bounds != null) {
|
||||
int startIndex = 0;
|
||||
AnnotatedType[] res = new AnnotatedType[bounds.length];
|
||||
Arrays.fill(res, AnnotatedTypeFactory.EMPTY_ANNOTATED_TYPE);
|
||||
|
||||
// Adjust bounds index
|
||||
//
|
||||
@ -276,12 +275,12 @@ public final class TypeAnnotationParser {
|
||||
tInfo.getCount() == typeVarIndex) {
|
||||
l.add(t);
|
||||
}
|
||||
res[i] = AnnotatedTypeFactory.buildAnnotatedType(bounds[i],
|
||||
loc,
|
||||
l.toArray(new TypeAnnotation[0]),
|
||||
candidates.toArray(new TypeAnnotation[0]),
|
||||
(AnnotatedElement)decl);
|
||||
}
|
||||
res[i] = AnnotatedTypeFactory.buildAnnotatedType(bounds[i],
|
||||
loc,
|
||||
l.toArray(EMPTY_TYPE_ANNOTATION_ARRAY),
|
||||
candidates.toArray(EMPTY_TYPE_ANNOTATION_ARRAY),
|
||||
(AnnotatedElement)decl);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -39,7 +39,6 @@ import java.nio.file.attribute.PosixFilePermission;
|
||||
import java.security.AccessController;
|
||||
import java.util.*;
|
||||
|
||||
import com.sun.security.auth.module.UnixSystem;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
import sun.security.krb5.internal.KerberosTime;
|
||||
import sun.security.krb5.internal.Krb5;
|
||||
@ -61,8 +60,7 @@ import sun.security.krb5.internal.ReplayCache;
|
||||
*
|
||||
* service_euid
|
||||
*
|
||||
* Java does not have a method to get euid, so uid is used instead. This
|
||||
* should normally to be since a Java program is seldom used as a setuid app.
|
||||
* in which euid is available as sun.misc.VM.geteuid().
|
||||
*
|
||||
* The file has a header:
|
||||
*
|
||||
@ -108,14 +106,8 @@ public class DflCache extends ReplayCache {
|
||||
|
||||
private static long uid;
|
||||
static {
|
||||
try {
|
||||
// Available on Solaris, Linux and Mac. Otherwise, no _euid suffix
|
||||
UnixSystem us = new com.sun.security.auth.module.UnixSystem();
|
||||
uid = us.getUid();
|
||||
} catch (Throwable e) {
|
||||
// Cannot be only Exception, might be UnsatisfiedLinkError
|
||||
uid = -1;
|
||||
}
|
||||
// Available on Solaris, Linux and Mac. Otherwise, -1 and no _euid suffix
|
||||
uid = sun.misc.VM.geteuid();
|
||||
}
|
||||
|
||||
public DflCache (String source) {
|
||||
|
||||
@ -75,8 +75,8 @@ public class FormatData_es_DO extends ParallelListResourceBundle {
|
||||
new String[] {
|
||||
"EEEE d' de 'MMMM' de 'yyyy", // full date pattern
|
||||
"d' de 'MMMM' de 'yyyy", // long date pattern
|
||||
"MM/dd/yyyy", // medium date pattern
|
||||
"MM/dd/yy", // short date pattern
|
||||
"dd/MM/yyyy", // medium date pattern
|
||||
"dd/MM/yy", // short date pattern
|
||||
}
|
||||
},
|
||||
{ "DateTimePatterns",
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -26,8 +26,6 @@
|
||||
package sun.tools.serialver;
|
||||
|
||||
import java.io.*;
|
||||
import java.awt.*;
|
||||
import java.applet.*;
|
||||
import java.io.ObjectStreamClass;
|
||||
import java.util.Properties;
|
||||
import java.text.MessageFormat;
|
||||
@ -39,106 +37,7 @@ import java.net.MalformedURLException;
|
||||
import java.util.StringTokenizer;
|
||||
import sun.net.www.ParseUtil;
|
||||
|
||||
public class SerialVer extends Applet {
|
||||
GridBagLayout gb;
|
||||
TextField classname_t;
|
||||
Button show_b;
|
||||
TextField serialversion_t;
|
||||
Label footer_l;
|
||||
|
||||
private static final long serialVersionUID = 7666909783837760853L;
|
||||
|
||||
public synchronized void init() {
|
||||
gb = new GridBagLayout();
|
||||
setLayout(gb);
|
||||
|
||||
GridBagConstraints c = new GridBagConstraints();
|
||||
c.fill = GridBagConstraints.BOTH;
|
||||
|
||||
Label l1 = new Label(Res.getText("FullClassName"));
|
||||
l1.setAlignment(Label.RIGHT);
|
||||
gb.setConstraints(l1, c);
|
||||
add(l1);
|
||||
|
||||
classname_t = new TextField(20);
|
||||
c.gridwidth = GridBagConstraints.RELATIVE;
|
||||
c.weightx = 1.0;
|
||||
gb.setConstraints(classname_t, c);
|
||||
add(classname_t);
|
||||
|
||||
show_b = new Button(Res.getText("Show"));
|
||||
c.gridwidth = GridBagConstraints.REMAINDER;
|
||||
c.weightx = 0.0; /* Don't grow the button */
|
||||
gb.setConstraints(show_b, c);
|
||||
add(show_b);
|
||||
|
||||
Label l2 = new Label(Res.getText("SerialVersion"));
|
||||
l2.setAlignment(Label.RIGHT);
|
||||
c.gridwidth = 1;
|
||||
gb.setConstraints(l2, c);
|
||||
add(l2);
|
||||
|
||||
serialversion_t = new TextField(50);
|
||||
serialversion_t.setEditable(false);
|
||||
c.gridwidth = GridBagConstraints.REMAINDER;
|
||||
gb.setConstraints(serialversion_t, c);
|
||||
add(serialversion_t);
|
||||
|
||||
footer_l = new Label();
|
||||
c.gridwidth = GridBagConstraints.REMAINDER;
|
||||
gb.setConstraints(footer_l, c);
|
||||
add(footer_l);
|
||||
|
||||
/* Give the focus to the type-in area */
|
||||
classname_t.requestFocus();
|
||||
}
|
||||
|
||||
public void start() {
|
||||
/* Give the focus to the type-in area */
|
||||
classname_t.requestFocus();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean action(Event ev, Object obj) {
|
||||
if (ev.target == classname_t) {
|
||||
show((String)ev.arg);
|
||||
return true;
|
||||
} else if (ev.target == show_b) {
|
||||
show(classname_t.getText());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean handleEvent(Event ev) {
|
||||
boolean rc = super.handleEvent(ev);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lookup the specified classname and display it.
|
||||
*/
|
||||
void show(String classname) {
|
||||
try {
|
||||
footer_l.setText(""); // Clear the message
|
||||
serialversion_t.setText(""); // clear the last value
|
||||
|
||||
if (classname.equals("")) {
|
||||
return;
|
||||
}
|
||||
|
||||
String s = serialSyntax(classname);
|
||||
if (s != null) {
|
||||
serialversion_t.setText(s);
|
||||
} else {
|
||||
footer_l.setText(Res.getText("NotSerializable", classname));
|
||||
}
|
||||
} catch (ClassNotFoundException cnf) {
|
||||
footer_l.setText(Res.getText("ClassNotFound", classname));
|
||||
}
|
||||
}
|
||||
public class SerialVer {
|
||||
|
||||
/*
|
||||
* A class loader that will load from the CLASSPATH environment
|
||||
@ -218,13 +117,7 @@ public class SerialVer extends Applet {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private static void showWindow(Window w) {
|
||||
w.show();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
boolean show = false;
|
||||
String envcp = null;
|
||||
int i = 0;
|
||||
|
||||
@ -234,9 +127,7 @@ public class SerialVer extends Applet {
|
||||
}
|
||||
|
||||
for (i = 0; i < args.length; i++) {
|
||||
if (args[i].equals("-show")) {
|
||||
show = true;
|
||||
} else if (args[i].equals("-classpath")) {
|
||||
if (args[i].equals("-classpath")) {
|
||||
if ((i+1 == args.length) || args[i+1].startsWith("-")) {
|
||||
System.err.println(Res.getText("error.missing.classpath"));
|
||||
usage();
|
||||
@ -278,51 +169,35 @@ public class SerialVer extends Applet {
|
||||
System.exit(3);
|
||||
}
|
||||
|
||||
if (!show) {
|
||||
/*
|
||||
* Check if there are any class names specified, if it is not a
|
||||
* invocation with the -show option.
|
||||
*/
|
||||
if (i == args.length) {
|
||||
usage();
|
||||
System.exit(1);
|
||||
}
|
||||
/*
|
||||
* Check if there are any class names specified
|
||||
*/
|
||||
if (i == args.length) {
|
||||
usage();
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* The rest of the parameters are classnames.
|
||||
*/
|
||||
boolean exitFlag = false;
|
||||
for (i = i; i < args.length; i++ ) {
|
||||
try {
|
||||
String syntax = serialSyntax(args[i]);
|
||||
if (syntax != null)
|
||||
System.out.println(args[i] + ":" + syntax);
|
||||
else {
|
||||
System.err.println(Res.getText("NotSerializable",
|
||||
args[i]));
|
||||
exitFlag = true;
|
||||
}
|
||||
} catch (ClassNotFoundException cnf) {
|
||||
System.err.println(Res.getText("ClassNotFound", args[i]));
|
||||
/*
|
||||
* The rest of the parameters are classnames.
|
||||
*/
|
||||
boolean exitFlag = false;
|
||||
for (i = i; i < args.length; i++ ) {
|
||||
try {
|
||||
String syntax = serialSyntax(args[i]);
|
||||
if (syntax != null)
|
||||
System.out.println(args[i] + ":" + syntax);
|
||||
else {
|
||||
System.err.println(Res.getText("NotSerializable",
|
||||
args[i]));
|
||||
exitFlag = true;
|
||||
}
|
||||
} catch (ClassNotFoundException cnf) {
|
||||
System.err.println(Res.getText("ClassNotFound", args[i]));
|
||||
exitFlag = true;
|
||||
}
|
||||
if (exitFlag) {
|
||||
System.exit(1);
|
||||
}
|
||||
} else {
|
||||
if (i < args.length) {
|
||||
System.err.println(Res.getText("ignoring.classes"));
|
||||
System.exit(1);
|
||||
}
|
||||
Frame f = new SerialVerFrame();
|
||||
// f.setLayout(new FlowLayout());
|
||||
SerialVer sv = new SerialVer();
|
||||
sv.init();
|
||||
|
||||
f.add("Center", sv);
|
||||
f.pack();
|
||||
showWindow(f);
|
||||
}
|
||||
if (exitFlag) {
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -336,65 +211,6 @@ public class SerialVer extends Applet {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Top level frame so serialVer can be run as an main program
|
||||
* and have an exit menu item.
|
||||
*/
|
||||
class SerialVerFrame extends Frame {
|
||||
MenuBar menu_mb;
|
||||
Menu file_m;
|
||||
MenuItem exit_i;
|
||||
|
||||
private static final long serialVersionUID = -7248105987187532533L;
|
||||
|
||||
/*
|
||||
* Construct a new Frame with title and menu.
|
||||
*/
|
||||
SerialVerFrame() {
|
||||
super(Res.getText("SerialVersionInspector"));
|
||||
|
||||
/* Create the file menu */
|
||||
file_m = new Menu(Res.getText("File"));
|
||||
file_m.add(exit_i = new MenuItem(Res.getText("Exit")));
|
||||
|
||||
/* Now add the file menu to the menu bar */
|
||||
menu_mb = new MenuBar();
|
||||
menu_mb.add(file_m);
|
||||
|
||||
/* Add the menubar to the frame */
|
||||
// Bug in JDK1.1 setMenuBar(menu_mb);
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle a window destroy event by exiting.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean handleEvent(Event e) {
|
||||
if (e.id == Event.WINDOW_DESTROY) {
|
||||
exit(0);
|
||||
}
|
||||
return super.handleEvent(e);
|
||||
}
|
||||
/*
|
||||
* Handle an Exit event by exiting.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean action(Event ev, Object obj) {
|
||||
if (ev.target == exit_i) {
|
||||
exit(0);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Cleanup and exit.
|
||||
*/
|
||||
void exit(int ret) {
|
||||
System.exit(ret);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility for integrating with serialver and for localization.
|
||||
* Handle Resources. Access to error and warning counts.
|
||||
|
||||
@ -1,9 +1,3 @@
|
||||
SerialVersionInspector=Serial Version Inspector
|
||||
File=File
|
||||
Exit=Exit
|
||||
Show=Show
|
||||
FullClassName=Full Class Name:
|
||||
SerialVersion=Serial Version:
|
||||
NotSerializable=\
|
||||
Class {0} is not Serializable.
|
||||
ClassNotFound=\
|
||||
@ -14,7 +8,5 @@ error.missing.classpath=\
|
||||
Missing argument for -classpath option
|
||||
invalid.flag=\
|
||||
Invalid flag {0}.
|
||||
ignoring.classes=\
|
||||
Cannot specify class arguments with the -show option
|
||||
usage=\
|
||||
use: serialver [-classpath classpath] [-show] [classname...]
|
||||
use: serialver [-classpath classpath] [classname...]
|
||||
|
||||
@ -18,16 +18,6 @@ attributes = compatibility
|
||||
|
||||
disabledMechanisms = {
|
||||
CKM_DSA_KEY_PAIR_GEN
|
||||
# the following mechanisms are disabled due to CKR_SAVED_STATE_INVALID bug
|
||||
# (Solaris bug 7058108)
|
||||
CKM_MD2
|
||||
CKM_MD5
|
||||
CKM_SHA_1
|
||||
# the following mechanisms are disabled due to no cloning support
|
||||
# (Solaris bug 7050617)
|
||||
CKM_SHA256
|
||||
CKM_SHA384
|
||||
CKM_SHA512
|
||||
# the following mechanisms are disabled due to performance issues
|
||||
# (Solaris bug 6337157)
|
||||
CKM_DSA_SHA1
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -38,42 +38,28 @@
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_java_util_TimeZone_getSystemTimeZoneID(JNIEnv *env, jclass ign,
|
||||
jstring java_home, jstring country)
|
||||
jstring java_home)
|
||||
{
|
||||
const char *cname;
|
||||
const char *java_home_dir;
|
||||
char *javaTZ;
|
||||
jstring jstrJavaTZ = NULL;
|
||||
|
||||
if (java_home == NULL)
|
||||
return NULL;
|
||||
CHECK_NULL_RETURN(java_home, NULL);
|
||||
|
||||
java_home_dir = JNU_GetStringPlatformChars(env, java_home, 0);
|
||||
if (java_home_dir == NULL)
|
||||
return NULL;
|
||||
|
||||
if (country != NULL) {
|
||||
cname = JNU_GetStringPlatformChars(env, country, 0);
|
||||
/* ignore error cases for cname */
|
||||
} else {
|
||||
cname = NULL;
|
||||
}
|
||||
CHECK_NULL_RETURN(java_home_dir, NULL);
|
||||
|
||||
/*
|
||||
* Invoke platform dependent mapping function
|
||||
*/
|
||||
javaTZ = findJavaTZ_md(java_home_dir, cname);
|
||||
|
||||
free((void *)java_home_dir);
|
||||
if (cname != NULL) {
|
||||
free((void *)cname);
|
||||
}
|
||||
|
||||
javaTZ = findJavaTZ_md(java_home_dir);
|
||||
if (javaTZ != NULL) {
|
||||
jstring jstrJavaTZ = JNU_NewStringPlatform(env, javaTZ);
|
||||
jstrJavaTZ = JNU_NewStringPlatform(env, javaTZ);
|
||||
free((void *)javaTZ);
|
||||
return jstrJavaTZ;
|
||||
}
|
||||
return NULL;
|
||||
|
||||
JNU_ReleaseStringPlatformChars(env, java_home, java_home_dir);
|
||||
return jstrJavaTZ;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@ -31,6 +31,11 @@
|
||||
#include "jdwpTransport.h"
|
||||
#include "sysSocket.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The Socket Transport Library.
|
||||
*
|
||||
@ -189,23 +194,83 @@ handshake(int fd, jlong timeout) {
|
||||
return JDWPTRANSPORT_ERROR_NONE;
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
getLocalHostAddress() {
|
||||
// Simple routine to guess localhost address.
|
||||
// it looks up "localhost" and returns 127.0.0.1 if lookup
|
||||
// fails.
|
||||
struct addrinfo hints, *res = NULL;
|
||||
int err;
|
||||
|
||||
// Use portable way to initialize the structure
|
||||
memset((void *)&hints, 0, sizeof(hints));
|
||||
hints.ai_family = AF_INET;
|
||||
|
||||
err = getaddrinfo("localhost", NULL, &hints, &res);
|
||||
if (err < 0 || res == NULL) {
|
||||
return dbgsysHostToNetworkLong(INADDR_LOOPBACK);
|
||||
}
|
||||
|
||||
// getaddrinfo might return more than one address
|
||||
// but we are using first one only
|
||||
return ((struct sockaddr_in *)(res->ai_addr))->sin_addr.s_addr;
|
||||
}
|
||||
|
||||
static int
|
||||
getPortNumber(const char *s_port) {
|
||||
u_long n;
|
||||
char *eptr;
|
||||
|
||||
if (*s_port == 0) {
|
||||
// bad address - colon with no port number in parameters
|
||||
return -1;
|
||||
}
|
||||
|
||||
n = strtoul(s_port, &eptr, 10);
|
||||
if (eptr != s_port + strlen(s_port)) {
|
||||
// incomplete conversion - port number contains non-digit
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (n > (u_short) -1) {
|
||||
// check that value supplied by user is less than
|
||||
// maximum possible u_short value (65535) and
|
||||
// will not be truncated later.
|
||||
return -1;
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
static jdwpTransportError
|
||||
parseAddress(const char *address, struct sockaddr_in *sa, uint32_t defaultHost) {
|
||||
parseAddress(const char *address, struct sockaddr_in *sa) {
|
||||
char *colon;
|
||||
int port;
|
||||
|
||||
memset((void *)sa,0,sizeof(struct sockaddr_in));
|
||||
sa->sin_family = AF_INET;
|
||||
|
||||
/* check for host:port or port */
|
||||
colon = strchr(address, ':');
|
||||
port = getPortNumber((colon == NULL) ? address : colon +1);
|
||||
if (port < 0) {
|
||||
RETURN_ERROR(JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT, "invalid port number specified");
|
||||
}
|
||||
sa->sin_port = dbgsysHostToNetworkShort((u_short)port);
|
||||
|
||||
if (colon == NULL) {
|
||||
u_short port = (u_short)atoi(address);
|
||||
sa->sin_port = dbgsysHostToNetworkShort(port);
|
||||
sa->sin_addr.s_addr = dbgsysHostToNetworkLong(defaultHost);
|
||||
} else {
|
||||
// bind to localhost only if no address specified
|
||||
sa->sin_addr.s_addr = getLocalHostAddress();
|
||||
} else if (strncmp(address,"localhost:",10) == 0) {
|
||||
// optimize for common case
|
||||
sa->sin_addr.s_addr = getLocalHostAddress();
|
||||
} else if (*address == '*' && *(address+1) == ':') {
|
||||
// we are explicitly asked to bind server to all available IP addresses
|
||||
// has no meaning for client.
|
||||
sa->sin_addr.s_addr = dbgsysHostToNetworkLong(INADDR_ANY);
|
||||
} else {
|
||||
char *buf;
|
||||
char *hostname;
|
||||
u_short port;
|
||||
uint32_t addr;
|
||||
|
||||
buf = (*callback->alloc)((int)strlen(address)+1);
|
||||
@ -215,8 +280,6 @@ parseAddress(const char *address, struct sockaddr_in *sa, uint32_t defaultHost)
|
||||
strcpy(buf, address);
|
||||
buf[colon - address] = '\0';
|
||||
hostname = buf;
|
||||
port = atoi(colon + 1);
|
||||
sa->sin_port = dbgsysHostToNetworkShort(port);
|
||||
|
||||
/*
|
||||
* First see if the host is a literal IP address.
|
||||
@ -277,7 +340,7 @@ socketTransport_startListening(jdwpTransportEnv* env, const char* address,
|
||||
address = "0";
|
||||
}
|
||||
|
||||
err = parseAddress(address, &sa, INADDR_ANY);
|
||||
err = parseAddress(address, &sa);
|
||||
if (err != JDWPTRANSPORT_ERROR_NONE) {
|
||||
return err;
|
||||
}
|
||||
@ -437,7 +500,7 @@ socketTransport_attach(jdwpTransportEnv* env, const char* addressString, jlong a
|
||||
RETURN_ERROR(JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT, "address is missing");
|
||||
}
|
||||
|
||||
err = parseAddress(addressString, &sa, 0x7f000001);
|
||||
err = parseAddress(addressString, &sa);
|
||||
if (err != JDWPTRANSPORT_ERROR_NONE) {
|
||||
return err;
|
||||
}
|
||||
|
||||
@ -652,11 +652,11 @@ static char *mapPlatformToJavaTimezone(const char *java_home_dir, const char *tz
|
||||
* using <java_home>/lib/tzmappings. If the TZ value is not found, it
|
||||
* trys some libc implementation dependent mappings. If it still
|
||||
* can't map to a Java time zone ID, it falls back to the GMT+/-hh:mm
|
||||
* form. `country', which can be null, is not used for UNIX platforms.
|
||||
* form.
|
||||
*/
|
||||
/*ARGSUSED1*/
|
||||
char *
|
||||
findJavaTZ_md(const char *java_home_dir, const char *country)
|
||||
findJavaTZ_md(const char *java_home_dir)
|
||||
{
|
||||
char *tz;
|
||||
char *javatz = NULL;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2001, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -26,7 +26,7 @@
|
||||
#ifndef _TIMEZONE_MD_H
|
||||
#define _TIMEZONE_MD_H
|
||||
|
||||
char *findJavaTZ_md(const char *java_home_dir, const char *region);
|
||||
char *findJavaTZ_md(const char *java_home_dir);
|
||||
char *getGMTOffsetID();
|
||||
|
||||
#endif
|
||||
|
||||
@ -27,12 +27,26 @@
|
||||
#include "jni_util.h"
|
||||
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_sun_misc_VM_isSetUID(JNIEnv *env, jclass thisclass) {
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_sun_misc_VM_getuid(JNIEnv *env, jclass thisclass) {
|
||||
|
||||
/* Return true if we are in a set UID or set GID process. */
|
||||
if (getuid() != geteuid() || getgid() != getegid()) {
|
||||
return JNI_TRUE;
|
||||
}
|
||||
return JNI_FALSE;
|
||||
return getuid();
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_sun_misc_VM_geteuid(JNIEnv *env, jclass thisclass) {
|
||||
|
||||
return geteuid();
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_sun_misc_VM_getgid(JNIEnv *env, jclass thisclass) {
|
||||
|
||||
return getgid();
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_sun_misc_VM_getegid(JNIEnv *env, jclass thisclass) {
|
||||
|
||||
return getegid();
|
||||
}
|
||||
|
||||
@ -62,6 +62,8 @@ typedef SCARDHANDLE *LPSCARDHANDLE;
|
||||
|
||||
#define MAX_ATR_SIZE 33 /* Maximum ATR size */
|
||||
|
||||
#ifndef __APPLE__
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char *szReader;
|
||||
@ -73,6 +75,23 @@ typedef struct
|
||||
}
|
||||
SCARD_READERSTATE_A;
|
||||
|
||||
#else // __APPLE__
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct
|
||||
{
|
||||
const char *szReader;
|
||||
void *pvUserData;
|
||||
uint32_t dwCurrentState;
|
||||
uint32_t dwEventState;
|
||||
uint32_t cbAtr;
|
||||
unsigned char rgbAtr[MAX_ATR_SIZE];
|
||||
}
|
||||
SCARD_READERSTATE_A;
|
||||
#pragma pack()
|
||||
|
||||
#endif // __APPLE__
|
||||
|
||||
typedef SCARD_READERSTATE_A SCARD_READERSTATE, *PSCARD_READERSTATE_A,
|
||||
*LPSCARD_READERSTATE_A;
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -394,31 +394,34 @@ static int getWinTimeZone(char *winZoneName, char *winMapID)
|
||||
*
|
||||
* value_type is one of the following values:
|
||||
* VALUE_KEY for exact key matching
|
||||
* VALUE_MAPID for MapID and country-based mapping (this is
|
||||
* VALUE_MAPID for MapID (this is
|
||||
* required for the old Windows, such as NT 4.0 SP3).
|
||||
*/
|
||||
static char *matchJavaTZ(const char *java_home_dir, int value_type, char *tzName,
|
||||
char *mapID, const char *country)
|
||||
char *mapID)
|
||||
{
|
||||
int line;
|
||||
int IDmatched = 0;
|
||||
FILE *fp;
|
||||
char *javaTZName = NULL;
|
||||
char *items[TZ_NITEMS];
|
||||
char mapFileName[_MAX_PATH + 1];
|
||||
char *mapFileName;
|
||||
char lineBuffer[MAX_ZONE_CHAR * 4];
|
||||
char bestMatch[MAX_ZONE_CHAR];
|
||||
int noMapID = *mapID == '\0'; /* no mapID on Vista */
|
||||
|
||||
bestMatch[0] = '\0';
|
||||
int noMapID = *mapID == '\0'; /* no mapID on Vista and later */
|
||||
|
||||
mapFileName = malloc(strlen(java_home_dir) + strlen(MAPPINGS_FILE) + 1);
|
||||
if (mapFileName == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
strcpy(mapFileName, java_home_dir);
|
||||
strcat(mapFileName, MAPPINGS_FILE);
|
||||
|
||||
if ((fp = fopen(mapFileName, "r")) == NULL) {
|
||||
jio_fprintf(stderr, "can't open %s.\n", mapFileName);
|
||||
free((void *) mapFileName);
|
||||
return NULL;
|
||||
}
|
||||
free((void *) mapFileName);
|
||||
|
||||
line = 0;
|
||||
while (fgets(lineBuffer, sizeof(lineBuffer), fp) != NULL) {
|
||||
@ -469,18 +472,6 @@ static char *matchJavaTZ(const char *java_home_dir, int value_type, char *tzName
|
||||
javaTZName = _strdup(items[TZ_JAVA_NAME]);
|
||||
break;
|
||||
}
|
||||
/*
|
||||
* Try to find the most likely time zone.
|
||||
*/
|
||||
if (*items[TZ_REGION] == '\0') {
|
||||
strncpy(bestMatch, items[TZ_JAVA_NAME], MAX_ZONE_CHAR);
|
||||
} else if (country != NULL && strcmp(items[TZ_REGION], country) == 0) {
|
||||
if (value_type == VALUE_MAPID) {
|
||||
javaTZName = _strdup(items[TZ_JAVA_NAME]);
|
||||
break;
|
||||
}
|
||||
strncpy(bestMatch, items[TZ_JAVA_NAME], MAX_ZONE_CHAR);
|
||||
}
|
||||
} else {
|
||||
if (IDmatched == 1) {
|
||||
/*
|
||||
@ -492,9 +483,6 @@ static char *matchJavaTZ(const char *java_home_dir, int value_type, char *tzName
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
if (javaTZName == NULL && bestMatch[0] != '\0') {
|
||||
javaTZName = _strdup(bestMatch);
|
||||
}
|
||||
return javaTZName;
|
||||
|
||||
illegal_format:
|
||||
@ -506,7 +494,7 @@ static char *matchJavaTZ(const char *java_home_dir, int value_type, char *tzName
|
||||
/*
|
||||
* Detects the platform time zone which maps to a Java time zone ID.
|
||||
*/
|
||||
char *findJavaTZ_md(const char *java_home_dir, const char *country)
|
||||
char *findJavaTZ_md(const char *java_home_dir)
|
||||
{
|
||||
char winZoneName[MAX_ZONE_CHAR];
|
||||
char winMapID[MAX_MAPID_LENGTH];
|
||||
@ -521,7 +509,7 @@ char *findJavaTZ_md(const char *java_home_dir, const char *country)
|
||||
std_timezone = _strdup(winZoneName);
|
||||
} else {
|
||||
std_timezone = matchJavaTZ(java_home_dir, result,
|
||||
winZoneName, winMapID, country);
|
||||
winZoneName, winMapID);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2001, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -26,7 +26,7 @@
|
||||
#ifndef _TIMEZONE_MD_H
|
||||
#define _TIMEZONE_MD_H
|
||||
|
||||
char *findJavaTZ_md(const char *java_home_dir, const char *region);
|
||||
char *findJavaTZ_md(const char *java_home_dir);
|
||||
char *getGMTOffsetID();
|
||||
|
||||
#endif
|
||||
|
||||
@ -26,9 +26,30 @@
|
||||
#include "jni_util.h"
|
||||
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_sun_misc_VM_isSetUID(JNIEnv *env, jclass thisclass) {
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_sun_misc_VM_getuid(JNIEnv *env, jclass thisclass) {
|
||||
|
||||
/* There is no set UID on Windows. */
|
||||
return JNI_FALSE;
|
||||
/* -1 means function not available. */
|
||||
return -1;
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_sun_misc_VM_geteuid(JNIEnv *env, jclass thisclass) {
|
||||
|
||||
/* -1 means function not available. */
|
||||
return -1;
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_sun_misc_VM_getgid(JNIEnv *env, jclass thisclass) {
|
||||
|
||||
/* -1 means function not available. */
|
||||
return -1;
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_sun_misc_VM_getegid(JNIEnv *env, jclass thisclass) {
|
||||
|
||||
/* -1 means function not available. */
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
* @summary Check that a bad handshake doesn't cause a debuggee to abort
|
||||
* @library /lib/testlibrary
|
||||
*
|
||||
* @build VMConnection BadHandshakeTest Exit0
|
||||
* @build jdk.testlibrary.* VMConnection BadHandshakeTest Exit0
|
||||
* @run main BadHandshakeTest
|
||||
*
|
||||
*/
|
||||
@ -110,12 +110,12 @@ public class BadHandshakeTest {
|
||||
}
|
||||
|
||||
// Connect to the debuggee and handshake with garbage
|
||||
Socket s = new Socket(InetAddress.getLocalHost(), port);
|
||||
Socket s = new Socket("localhost", port);
|
||||
s.getOutputStream().write("Here's a poke in the eye".getBytes("UTF-8"));
|
||||
s.close();
|
||||
|
||||
// Re-connect and to a partial handshake - don't disconnect
|
||||
s = new Socket(InetAddress.getLocalHost(), port);
|
||||
s = new Socket("localhost", port);
|
||||
s.getOutputStream().write("JDWP-".getBytes("UTF-8"));
|
||||
|
||||
|
||||
|
||||
@ -27,8 +27,7 @@
|
||||
* at the same time.
|
||||
* @library /lib/testlibrary
|
||||
*
|
||||
* @build jdk.testlibrary.ProcessTools jdk.testlibrary.JDKToolLauncher jdk.testlibrary.Utils
|
||||
* @build VMConnection ExclusiveBind HelloWorld
|
||||
* @build jdk.testlibrary.* VMConnection ExclusiveBind HelloWorld
|
||||
* @run main ExclusiveBind
|
||||
*/
|
||||
import java.net.ServerSocket;
|
||||
|
||||
@ -157,6 +157,37 @@ public class OptionTest extends Object {
|
||||
throw new Exception("Test failed: jdwp doesn't like " + cmds[1]);
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("Testing invalid address string");
|
||||
|
||||
// Test invalid addresses
|
||||
String badAddresses[] = {
|
||||
":",
|
||||
"localhost:",
|
||||
"localhost:abc",
|
||||
"localhost:65536",
|
||||
"localhost:65F"
|
||||
};
|
||||
|
||||
for (String badAddress : badAddresses) {
|
||||
|
||||
String badOptions = "transport=dt_socket" +
|
||||
",address=" + badAddress +
|
||||
",server=y" +
|
||||
",suspend=n";
|
||||
String cmds[] = {javaExe, "-agentlib:jdwp=" + badOptions, targetClass};
|
||||
OptionTest myTest = new OptionTest();
|
||||
String results[] = myTest.run(VMConnection.insertDebuggeeVMOptions(cmds));
|
||||
|
||||
if (!results[RETSTAT].equals("0") && results[STDERR].startsWith("ERROR:")) {
|
||||
// We got expected error, test passed
|
||||
}
|
||||
else {
|
||||
throw new Exception("Test failed: jdwp accept invalid address '" + badAddress + "'");
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("Test passed: status = 0");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -161,6 +161,9 @@ public class RunToExit {
|
||||
Connector.IntegerArgument port_arg =
|
||||
(Connector.IntegerArgument)conn_args.get("port");
|
||||
port_arg.setValue(port);
|
||||
|
||||
System.out.println("Connection arguments: " + conn_args);
|
||||
|
||||
VirtualMachine vm = conn.attach(conn_args);
|
||||
|
||||
// The first event is always a VMStartEvent, and it is always in
|
||||
|
||||
@ -38,8 +38,8 @@ import jdk.testlibrary.ProcessThread;
|
||||
* @bug 8033104
|
||||
* @summary Test to make sure attach and jvmstat works correctly when java.io.tmpdir is set
|
||||
* @library /lib/testlibrary
|
||||
* @run build Application Shutdown RunnerUtil
|
||||
* @run main/timeout=10 TempDirTest
|
||||
* @run build jdk.testlibrary.* Application Shutdown RunnerUtil
|
||||
* @run main TempDirTest
|
||||
*/
|
||||
|
||||
public class TempDirTest {
|
||||
|
||||
129
jdk/test/java/lang/annotation/TypeVariableBounds.java
Normal file
129
jdk/test/java/lang/annotation/TypeVariableBounds.java
Normal file
@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8038994
|
||||
* @summary Test that getAnnotatedBounds().getType() match getBounds()
|
||||
* @run testng TypeVariableBounds
|
||||
*/
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.annotation.*;
|
||||
import java.lang.reflect.*;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.testng.Assert.*;
|
||||
|
||||
public class TypeVariableBounds {
|
||||
@Test(dataProvider = "classData")
|
||||
public void testClass(Class<?> c) throws Exception {
|
||||
assertNotEquals(c.getTypeParameters().length, 0);
|
||||
|
||||
TypeVariable[] tv = c.getTypeParameters();
|
||||
|
||||
for(TypeVariable t : tv)
|
||||
testTv(t);
|
||||
|
||||
}
|
||||
|
||||
@Test(dataProvider = "methodData")
|
||||
public void testMethod(Class<?>c) throws Exception {
|
||||
Method m = c.getMethod("aMethod");
|
||||
TypeVariable[] tv = m.getTypeParameters();
|
||||
|
||||
for(TypeVariable t : tv)
|
||||
testTv(t);
|
||||
|
||||
}
|
||||
|
||||
public void testTv(TypeVariable<?> tv) {
|
||||
Type[] t = tv.getBounds();
|
||||
AnnotatedType[] at = tv.getAnnotatedBounds();
|
||||
|
||||
assertEquals(t.length, at.length, Arrays.asList(t) + " and " + Arrays.asList(at) + " should be the same length");
|
||||
|
||||
for (int i = 0; i < t.length; i++)
|
||||
assertSame(at[i].getType(), t[i], "T: " + t[i] + ", AT: " + at[i] + ", AT.getType(): " + at[i].getType() + "\n");
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] classData() { return CLASS_TESTS; }
|
||||
|
||||
@DataProvider
|
||||
public Object[][] methodData() { return METHOD_TESTS; }
|
||||
|
||||
public static final Object[][] CLASS_TESTS = {
|
||||
{ Case1.class, },
|
||||
{ Case2.class, },
|
||||
{ Case5.class, },
|
||||
{ Case6.class, },
|
||||
};
|
||||
|
||||
public static final Object[][] METHOD_TESTS = {
|
||||
{ Case3.class, },
|
||||
{ Case4.class, },
|
||||
{ Case5.class, },
|
||||
{ Case6.class, },
|
||||
};
|
||||
|
||||
// Class type var
|
||||
public static class Case1<C1T1, C1T2 extends AnnotatedElement, C1T3 extends AnnotatedElement & Type & Serializable> {}
|
||||
public static class Case2<C2T0, @TA C2T1 extends Type, C2T2 extends @TB AnnotatedElement, C2T3 extends AnnotatedElement & @TB Type & Serializable> {}
|
||||
|
||||
// Method type var
|
||||
public static class Case3 { public <C3T1, C3T2 extends AnnotatedElement, C3T3 extends AnnotatedElement & Type & Serializable> void aMethod() {}}
|
||||
public static class Case4 { public <C4T0, @TA C4T1 extends List, C4T2 extends @TB Set, C4T3 extends Set & @TB Callable & Serializable> void aMethod() {}}
|
||||
|
||||
// Both
|
||||
public static class Case5 <C5CT1, C5CT2 extends Runnable> {
|
||||
public <C5MT1,
|
||||
C5MT2 extends AnnotatedElement,
|
||||
C5MT3 extends AnnotatedElement & Type & Serializable,
|
||||
C5MT4 extends C5CT2>
|
||||
void aMethod() {}}
|
||||
|
||||
public static class Case6 <@TA C6CT1, C6CT2 extends @TB Runnable> {
|
||||
public <@TA C6MT1,
|
||||
C6MT2 extends @TB AnnotatedElement,
|
||||
C6MT3 extends @TB AnnotatedElement & @TB2 Type & Serializable,
|
||||
C6MT4 extends @TB2 C6CT2>
|
||||
void aMethod() {}}
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE_PARAMETER)
|
||||
public @interface TA {}
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE_USE)
|
||||
public @interface TB {}
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE_USE)
|
||||
public @interface TB2 {}
|
||||
}
|
||||
@ -26,7 +26,7 @@
|
||||
* @summary Assert in java.lang.instrument agents during shutdown when classloading occurs after shutdown
|
||||
* @library /lib/testlibrary
|
||||
*
|
||||
* @build DummyAgent DummyClass TestDaemonThreadLauncher TestDaemonThread
|
||||
* @build jdk.testlibrary.* DummyAgent DummyClass TestDaemonThreadLauncher TestDaemonThread
|
||||
* @run shell ../MakeJAR3.sh DummyAgent
|
||||
* @run main TestDaemonThreadLauncher /timeout=240
|
||||
*
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
* @author Mandy Chung
|
||||
*
|
||||
* @library /lib/testlibrary/
|
||||
* @build ResetPeakMemoryUsage MemoryUtil RunUtil
|
||||
* @build jdk.testlibrary.* ResetPeakMemoryUsage MemoryUtil RunUtil
|
||||
* @run main ResetPeakMemoryUsage
|
||||
*/
|
||||
|
||||
|
||||
@ -61,29 +61,31 @@ public class BaseTest {
|
||||
public void tearDownMethod() throws Exception {
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* Take some form of SQLException, serialize and deserialize it
|
||||
*
|
||||
* @param <T> SQLException
|
||||
* @param ex SQLException
|
||||
* @return deserialized SQLException
|
||||
* @throws IOException
|
||||
* @throws ClassNotFoundException
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
protected <T extends SQLException> T
|
||||
createSerializedException(T ex)
|
||||
throws IOException, ClassNotFoundException {
|
||||
T ex1;
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
try (ObjectOutputStream oos = new ObjectOutputStream(baos) ) {
|
||||
oos.writeObject(ex);
|
||||
}
|
||||
try (ObjectInputStream ois =
|
||||
new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()))) {
|
||||
ex1 = (T) ois.readObject();
|
||||
}
|
||||
return ex1;
|
||||
return (T) serializeDeserializeObject(ex);
|
||||
}
|
||||
|
||||
/*
|
||||
* Utility method to serialize and deserialize an object
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
protected <T> T serializeDeserializeObject(T o)
|
||||
throws IOException, ClassNotFoundException {
|
||||
T o1;
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
try (ObjectOutputStream oos = new ObjectOutputStream(baos)) {
|
||||
oos.writeObject(o);
|
||||
}
|
||||
try (ObjectInputStream ois
|
||||
= new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()))) {
|
||||
o1 = (T) ois.readObject();
|
||||
}
|
||||
return o1;
|
||||
}
|
||||
}
|
||||
|
||||
2
jdk/test/javax/sql/testng/TEST.properties
Normal file
2
jdk/test/javax/sql/testng/TEST.properties
Normal file
@ -0,0 +1,2 @@
|
||||
# JDBC unit tests uses TestNG
|
||||
TestNG.dirs= .
|
||||
@ -0,0 +1,236 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package test.rowset.serial;
|
||||
|
||||
import java.sql.Array;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.sql.rowset.serial.SerialArray;
|
||||
import javax.sql.rowset.serial.SerialException;
|
||||
import static org.testng.Assert.*;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
import util.BaseTest;
|
||||
import util.StubArray;
|
||||
|
||||
public class SerialArrayTests extends BaseTest {
|
||||
|
||||
private Object[] coffees;
|
||||
private final String sqlType = "VARCHAR";
|
||||
private Array a;
|
||||
private Map<String, Class<?>> map;
|
||||
|
||||
@BeforeMethod
|
||||
public void setUpMethod() throws Exception {
|
||||
coffees = new Object[]{"Espresso", "Colombian", "French Roast",
|
||||
"Cappuccino"};
|
||||
a = new StubArray(sqlType, coffees);
|
||||
map = new HashMap<>();
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate a SerialArray can be created from an Array
|
||||
*/
|
||||
@Test
|
||||
public void test01() throws Exception {
|
||||
SerialArray sa = new SerialArray(a);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate a SQLException is thrown if the map is null
|
||||
*/
|
||||
@Test(expectedExceptions = SQLException.class)
|
||||
public void test02() throws Exception {
|
||||
SerialArray sa = new SerialArray(a, null);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate a SerialException is thrown when getResultSet() is called
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test03() throws Exception {
|
||||
SerialArray sa = new SerialArray(a);
|
||||
sa.getResultSet();
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate a SerialException is thrown when getResultSet() is called
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test04() throws Exception {
|
||||
SerialArray sa = new SerialArray(a);
|
||||
sa.getResultSet(null);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate a SerialException is thrown when getResultSet() is called
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test05() throws Exception {
|
||||
SerialArray sa = new SerialArray(a);
|
||||
sa.getResultSet(1, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate a SerialException is thrown when getResultSet() is called
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test06() throws Exception {
|
||||
SerialArray sa = new SerialArray(a);
|
||||
sa.getResultSet(1, 1, null);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate a SerialException is thrown when getArray() is invoked after
|
||||
* free() is called
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test07() throws Exception {
|
||||
SerialArray sa = new SerialArray(a);
|
||||
sa.free();
|
||||
sa.getArray();
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate a SerialException is thrown when getArray() is invoked after
|
||||
* free() is called
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test08() throws Exception {
|
||||
SerialArray sa = new SerialArray(a);
|
||||
sa.free();
|
||||
sa.getArray(map);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate a SerialException is thrown when getArray() is invoked after
|
||||
* free() is called
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test09() throws Exception {
|
||||
SerialArray sa = new SerialArray(a);
|
||||
sa.free();
|
||||
sa.getArray(1, 1, map);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate a SerialException is thrown when getArray() is invoked after
|
||||
* free() is called
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test10() throws Exception {
|
||||
SerialArray sa = new SerialArray(a);
|
||||
sa.free();
|
||||
sa.getArray(1, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate a SerialException is thrown when getBaseType() is invoked after
|
||||
* free() is called
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test11() throws Exception {
|
||||
SerialArray sa = new SerialArray(a);
|
||||
sa.free();
|
||||
sa.getBaseType();
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate a SerialException is thrown when getBaseTypeName() is invoked after
|
||||
* free() is called
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test12() throws Exception {
|
||||
SerialArray sa = new SerialArray(a);
|
||||
sa.free();
|
||||
sa.getBaseTypeName();
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate getArray() returns the same Object[] used to create the
|
||||
* SerialArray
|
||||
*/
|
||||
@Test
|
||||
public void test13() throws Exception {
|
||||
SerialArray sa = new SerialArray(a);
|
||||
Object[] o = (Object[]) sa.getArray();
|
||||
assertTrue(Arrays.equals(o, coffees));
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate getArray() returns the same Object[] used to create the
|
||||
* SerialArray
|
||||
*/
|
||||
@Test
|
||||
public void test14() throws Exception {
|
||||
SerialArray sa = new SerialArray(a);
|
||||
Object[] o = (Object[]) sa.getArray(map);
|
||||
assertTrue(Arrays.equals(o, coffees));
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate getArray() returns the same Object[] used to create the
|
||||
* SerialArray
|
||||
*/
|
||||
@Test
|
||||
public void test15() throws Exception {
|
||||
SerialArray sa = new SerialArray(a);
|
||||
Object[] o = (Object[]) sa.getArray(1, 2);
|
||||
assertTrue(Arrays.equals(o, Arrays.copyOfRange(coffees, 1, 3)));
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate getArray() returns the same Object[] used to create the
|
||||
* SerialArray
|
||||
*/
|
||||
@Test
|
||||
public void test16() throws Exception {
|
||||
SerialArray sa = new SerialArray(a);
|
||||
Object[] o = (Object[]) sa.getArray(1, 2, map);
|
||||
assertTrue(Arrays.equals(o, Arrays.copyOfRange(coffees, 1, 3)));
|
||||
}
|
||||
|
||||
/*
|
||||
* clone() a SerialArray and check that it is equal to the
|
||||
* object it was cloned from
|
||||
*/
|
||||
@Test
|
||||
public void test17() throws Exception {
|
||||
SerialArray sa = new SerialArray(a);
|
||||
SerialArray sa1 = (SerialArray) sa.clone();
|
||||
assertTrue(sa.equals(sa1));
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate that a SerialArray that is serialized & deserialized is equal to
|
||||
* itself
|
||||
*/
|
||||
@Test
|
||||
public void test18() throws Exception {
|
||||
SerialArray sa = new SerialArray(a);
|
||||
SerialArray sa1 = serializeDeserializeObject(sa);;
|
||||
assertTrue(sa.equals(sa1));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,399 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package test.rowset.serial;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Arrays;
|
||||
import javax.sql.rowset.serial.SerialBlob;
|
||||
import javax.sql.rowset.serial.SerialException;
|
||||
import static org.testng.Assert.*;
|
||||
import org.testng.annotations.Test;
|
||||
import util.BaseTest;
|
||||
import util.StubBlob;
|
||||
|
||||
public class SerialBlobTests extends BaseTest {
|
||||
|
||||
// byte[] used to populate SerialBlob
|
||||
private byte[] bytes = new byte[]{1, 2, 3, 4, 5};
|
||||
|
||||
/*
|
||||
* Validate calling free() does not throw an Exception
|
||||
*/
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
SerialBlob sb = new SerialBlob(new StubBlob());
|
||||
sb.free();
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate calling getBinaryStream() after calling free() throws an
|
||||
* SerialException
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test01() throws Exception {
|
||||
SerialBlob sb = new SerialBlob(new StubBlob());
|
||||
sb.free();
|
||||
sb.getBinaryStream();
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate calling getBinaryStream() after calling free() throws an
|
||||
* SerialException
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test02() throws Exception {
|
||||
SerialBlob sb = new SerialBlob(new StubBlob());
|
||||
sb.free();
|
||||
sb.getBinaryStream(1, 5);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate calling getBytes() after calling free() throws an
|
||||
* SerialException
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test03() throws Exception {
|
||||
SerialBlob sb = new SerialBlob(new StubBlob());
|
||||
sb.free();
|
||||
sb.getBytes(1, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate calling getLength() after calling free() throws an
|
||||
* SerialException
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test04() throws Exception {
|
||||
SerialBlob sb = new SerialBlob(new StubBlob());
|
||||
sb.free();
|
||||
sb.length();
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate calling position() after calling free() throws an
|
||||
* SerialException
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test05() throws Exception {
|
||||
SerialBlob sb = new SerialBlob(new StubBlob());
|
||||
sb.free();
|
||||
sb.position(new byte[5], 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate calling position() after calling free() throws an
|
||||
* SerialException
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test06() throws Exception {
|
||||
SerialBlob sb = new SerialBlob(new StubBlob());
|
||||
sb.free();
|
||||
sb.position(new StubBlob(), 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate calling free() after calling setBinaryStream() throws an
|
||||
* SerialException
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test07() throws Exception {
|
||||
SerialBlob sb = new SerialBlob(new StubBlob());
|
||||
sb.free();
|
||||
sb.setBinaryStream(5);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate calling free() after calling setBytes() throws an
|
||||
* SerialException
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test08() throws Exception {
|
||||
SerialBlob sb = new SerialBlob(new StubBlob());
|
||||
sb.free();
|
||||
sb.setBytes(1, new byte[5]);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate calling setBytes() after calling free() throws an
|
||||
* SerialException
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test09() throws Exception {
|
||||
SerialBlob sb = new SerialBlob(new StubBlob());
|
||||
sb.free();
|
||||
sb.setBytes(1, new byte[10], 0, 5);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate calling truncate() after calling free() throws an
|
||||
* SerialException
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test10() throws Exception {
|
||||
SerialBlob sb = new SerialBlob(new StubBlob());
|
||||
sb.free();
|
||||
sb.truncate(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate getBinaryStream returns the correct bytes
|
||||
*/
|
||||
@Test
|
||||
public void test11() throws Exception {
|
||||
byte[] expected = new byte[]{1, 2, 3};
|
||||
SerialBlob sb = new SerialBlob(bytes);
|
||||
InputStream is = sb.getBinaryStream(1, 3);
|
||||
for (byte b : expected) {
|
||||
byte val = (byte) is.read();
|
||||
assertTrue(b == val, val + " does not match " + b);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate a SerialException is thrown if pos < 0 for getBinaryStream
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test12() throws Exception {
|
||||
SerialBlob sb = new SerialBlob(bytes);
|
||||
InputStream is = sb.getBinaryStream(-1, 3);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate a SerialException is thrown if pos = 0 for getBinaryStream
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test13() throws Exception {
|
||||
SerialBlob sb = new SerialBlob(bytes);
|
||||
InputStream is = sb.getBinaryStream(0, 3);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate a SerialException is thrown if len > the length of the stream
|
||||
* for getBinaryStream
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test14() throws Exception {
|
||||
SerialBlob sb = new SerialBlob(bytes);
|
||||
InputStream is = sb.getBinaryStream(0, 3);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate a SerialException is thrown if length < 1
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test15() throws Exception {
|
||||
SerialBlob sb = new SerialBlob(bytes);
|
||||
InputStream is = sb.getBinaryStream(1, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate a SerialException is thrown if length > byte array length
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test16() throws Exception {
|
||||
SerialBlob sb = new SerialBlob(bytes);
|
||||
InputStream is = sb.getBinaryStream(1, 6);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate a SerialException is thrown if pos > byte array length
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test17() throws Exception {
|
||||
SerialBlob sb = new SerialBlob(bytes);
|
||||
InputStream is = sb.getBinaryStream(bytes.length + 2, 6);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate that a cloned SerializedBlob bytes match the original
|
||||
*/
|
||||
@Test
|
||||
public void test18() throws Exception {
|
||||
SerialBlob sb = new SerialBlob(bytes);
|
||||
SerialBlob sb2 = (SerialBlob) sb.clone();
|
||||
assertTrue(
|
||||
Arrays.equals(sb.getBytes(1, (int) sb.length()),
|
||||
sb2.getBytes(1, (int) sb2.length())),
|
||||
"arrays do not match ");
|
||||
}
|
||||
|
||||
/*
|
||||
* Test clone after free has been called that the clone is not accessible
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test19() throws Exception {
|
||||
SerialBlob sb = new SerialBlob(bytes);
|
||||
sb.free();
|
||||
SerialBlob sb2 = (SerialBlob) sb.clone();
|
||||
InputStream is = sb2.getBinaryStream(1, 3);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate that a SerialBlob that is serialized & deserialized is equal to
|
||||
* itself
|
||||
*/
|
||||
@Test
|
||||
public void test20() throws Exception {
|
||||
SerialBlob sb = new SerialBlob(bytes);
|
||||
SerialBlob sb2 = serializeDeserializeObject(sb);
|
||||
assertTrue(sb.equals(sb2), "SerialBlob not equal");
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate a SerialException is thrown if byte[] is used to
|
||||
* create the SeriablBlob and setBinaryStream is called
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test21() throws Exception {
|
||||
SerialBlob sb = new SerialBlob(bytes);
|
||||
sb.setBinaryStream(3);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate that setBytes will properly write a set of bytes to the
|
||||
* specified location in the SerialBlob and the correct count is returned
|
||||
* for bytes written
|
||||
*/
|
||||
@Test
|
||||
public void test22() throws Exception {
|
||||
byte[] diff = new byte[]{7, 8, 9};
|
||||
byte[] expected = new byte[]{1, 7, 8, 9, 5};
|
||||
SerialBlob sb = new SerialBlob(bytes);
|
||||
int written = sb.setBytes(2, diff);
|
||||
assertEquals(written, diff.length);
|
||||
assertTrue(
|
||||
Arrays.equals(sb.getBytes(1, (int) sb.length()),
|
||||
expected),
|
||||
"arrays do not match ");
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate that setBytes will properly write a set of bytes to the
|
||||
* specified location in the SerialBlob and the correct count is returned
|
||||
* for bytes written
|
||||
*/
|
||||
@Test
|
||||
public void test23() throws Exception {
|
||||
int bytesToWrite = 3;
|
||||
byte[] diff = new byte[]{7, 8, 9, 0};
|
||||
byte[] expected = new byte[]{1, 8, 9, 0, 5};
|
||||
SerialBlob sb = new SerialBlob(bytes);
|
||||
int written = sb.setBytes(2, diff, 1, bytesToWrite);
|
||||
assertEquals(written, bytesToWrite);
|
||||
assertTrue(
|
||||
Arrays.equals(sb.getBytes(1, (int) sb.length()),
|
||||
expected),
|
||||
"arrays do not match ");
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate that truncate reduces the length of the SerlizedBlob to the
|
||||
* specified value
|
||||
*/
|
||||
@Test
|
||||
public void test24() throws Exception {
|
||||
SerialBlob sb = new SerialBlob(bytes);
|
||||
sb.truncate(0);
|
||||
assertTrue(sb.length() == 0);
|
||||
sb = new SerialBlob(bytes);
|
||||
sb.truncate(3);
|
||||
assertTrue(sb.length() == 3);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate getBinaryStream returns the correct bytes
|
||||
*/
|
||||
@Test
|
||||
public void test25() throws Exception {
|
||||
byte[] expected = bytes;
|
||||
SerialBlob sb = new SerialBlob(bytes);
|
||||
InputStream is = sb.getBinaryStream();
|
||||
for (byte b : expected) {
|
||||
byte val = (byte) is.read();
|
||||
assertTrue(b == val, val + " does not match " + b);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate setBinaryStream returns an OutputStream when passed a Blob
|
||||
*/
|
||||
@Test
|
||||
public void test26() throws Exception {
|
||||
SerialBlob sb = new SerialBlob(new StubBlob());
|
||||
OutputStream os = sb.setBinaryStream(0);
|
||||
assertTrue(os != null);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate that position returns the correct starting location for a
|
||||
* pattern in the SerialBlob
|
||||
*/
|
||||
@Test
|
||||
public void test27() throws Exception {
|
||||
long expectedPos = 3; // starting offset is 1 vs 0
|
||||
byte[] pattern = new byte[]{3, 4};
|
||||
SerialBlob sb = new SerialBlob(bytes);
|
||||
long pos = sb.position(pattern, 1);
|
||||
assertEquals(pos, expectedPos);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate that position returns the correct starting location for a
|
||||
* pattern in the SerialBlob
|
||||
*/
|
||||
@Test
|
||||
public void test28() throws Exception {
|
||||
long expectedPos = 3; // starting offset is 1 vs 0
|
||||
byte[] pattern = new byte[]{3, 4, 5};
|
||||
SerialBlob sb = new SerialBlob(bytes);
|
||||
long pos = sb.position(pattern, 2);
|
||||
assertEquals(pos, expectedPos);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate that position returns the correct starting location for a
|
||||
* pattern in the SerialBlob
|
||||
*/
|
||||
@Test
|
||||
public void test29() throws Exception {
|
||||
long expectedPos = 2; // starting offset is 1 vs 0
|
||||
byte[] pattern = new byte[]{4, 6};
|
||||
SerialBlob sb = new SerialBlob(new StubBlob());
|
||||
long pos = sb.position(pattern, 1);
|
||||
assertEquals(pos, expectedPos);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate that position returns the correct starting location for a
|
||||
* pattern in the SerialBlob
|
||||
*/
|
||||
@Test
|
||||
public void test30() throws Exception {
|
||||
long expectedPos = 3; // starting offset is 1 vs 0
|
||||
byte[] pattern = new byte[]{6, 8};
|
||||
SerialBlob sb = new SerialBlob(new StubBlob());
|
||||
long pos = sb.position(pattern, 2);
|
||||
assertEquals(pos, expectedPos);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,499 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package test.rowset.serial;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import javax.sql.rowset.serial.SerialClob;
|
||||
import javax.sql.rowset.serial.SerialException;
|
||||
import static org.testng.Assert.*;
|
||||
import org.testng.annotations.Test;
|
||||
import util.BaseTest;
|
||||
import util.StubClob;
|
||||
|
||||
public class SerialClobTests extends BaseTest {
|
||||
|
||||
// char[] used to populate SerialClob
|
||||
private final char[] chars;
|
||||
|
||||
public SerialClobTests() {
|
||||
this.chars = new char[]{'h', 'e', 'l', 'l', 'o', ' ', 'w',
|
||||
'o', 'r', 'l', 'd'};
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate calling free() does not throw an Exception
|
||||
*/
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
SerialClob sc = new SerialClob(new StubClob());
|
||||
sc.free();
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate calling getCharacterStream() after calling free() throws an
|
||||
* SerialException
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test01() throws Exception {
|
||||
SerialClob sc = new SerialClob(new StubClob());
|
||||
sc.free();
|
||||
sc.getCharacterStream();
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate calling getCharacterStream() after calling free() throws an
|
||||
* SerialException
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test02() throws Exception {
|
||||
SerialClob sc = new SerialClob(chars);
|
||||
sc.free();
|
||||
sc.getCharacterStream();
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate calling getCharacterStream() after calling free() throws an
|
||||
* SerialException
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test03() throws Exception {
|
||||
SerialClob sc = new SerialClob(new StubClob());
|
||||
sc.free();
|
||||
sc.getCharacterStream(1, 5);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate calling getSubString() after calling free() throws an
|
||||
* SerialException
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test04() throws Exception {
|
||||
SerialClob sc = new SerialClob(new StubClob());
|
||||
sc.free();
|
||||
sc.getSubString(1, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate calling truncate() after calling free() throws an
|
||||
* SerialException
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test05() throws Exception {
|
||||
SerialClob sc = new SerialClob(new StubClob());
|
||||
sc.free();
|
||||
sc.truncate(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate calling getAsciiStream() after calling free() throws an
|
||||
* SerialException
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test06() throws Exception {
|
||||
SerialClob sc = new SerialClob(new StubClob());
|
||||
sc.free();
|
||||
sc.getAsciiStream();
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate calling length() after calling free() throws an SerialException
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test07() throws Exception {
|
||||
SerialClob sc = new SerialClob(new StubClob());
|
||||
sc.free();
|
||||
sc.length();
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate calling position() after calling free() throws an
|
||||
* SerialException
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test08() throws Exception {
|
||||
SerialClob sc = new SerialClob(new StubClob());
|
||||
sc.free();
|
||||
sc.position("hello", 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate calling position() after calling free() throws an
|
||||
* SerialException
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test09() throws Exception {
|
||||
SerialClob sc = new SerialClob(new StubClob());
|
||||
sc.free();
|
||||
sc.position(new StubClob(), 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate calling setAsciiStream() after calling free() throws an
|
||||
* SerialException
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test10() throws Exception {
|
||||
SerialClob sc = new SerialClob(new StubClob());
|
||||
sc.free();
|
||||
sc.setAsciiStream(5);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate calling setCharacterStream() after calling free() throws an
|
||||
* SerialException
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test11() throws Exception {
|
||||
SerialClob sc = new SerialClob(new StubClob());
|
||||
sc.free();
|
||||
sc.setCharacterStream(5);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate calling setString() after calling free() throws an
|
||||
* SerialException
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test12() throws Exception {
|
||||
SerialClob sc = new SerialClob(new StubClob());
|
||||
sc.free();
|
||||
sc.setString(1, "hello");
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate calling setString() after calling free() throws an
|
||||
* SerialException
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test13() throws Exception {
|
||||
SerialClob sc = new SerialClob(new StubClob());
|
||||
sc.free();
|
||||
sc.setString(1, "hello", 0, 5);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test that SerialException is thrown if pos < 0 on a call to
|
||||
* getCharacterStream
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test14() throws Exception {
|
||||
SerialClob sc = new SerialClob(chars);
|
||||
sc.getCharacterStream(-1, 5);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test that SerialException is thrown if pos = 0 on a call to
|
||||
* getCharacterStream
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test15() throws Exception {
|
||||
SerialClob sc = new SerialClob(chars);
|
||||
sc.getCharacterStream(0, 5);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test that SerialException is thrown if pos = 0 on a call to
|
||||
* getCharacterStream
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test16() throws Exception {
|
||||
SerialClob sc = new SerialClob(chars);
|
||||
sc.getCharacterStream(1, 100);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test that SerialException is thrown if length = 0 on a call to
|
||||
* getCharacterStream
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test17() throws Exception {
|
||||
SerialClob sc = new SerialClob(chars);
|
||||
sc.getCharacterStream(1, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test that SerialException is thrown if pos > length on a call to
|
||||
* getCharacterStream
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test18() throws Exception {
|
||||
SerialClob sc = new SerialClob(chars);
|
||||
sc.getCharacterStream(100, 5);
|
||||
}
|
||||
|
||||
/*
|
||||
* Clone a SerialClob and check that it is equal to itself
|
||||
*/
|
||||
@Test
|
||||
public void test19() throws Exception {
|
||||
SerialClob sc = new SerialClob(chars);
|
||||
SerialClob sc1 = (SerialClob) sc.clone();
|
||||
assertTrue(sc.equals(sc1), "SerialClobs not equal");
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate that a getAsciiStream() returns an InputStream when a Clob is
|
||||
* used to create the SerialClob
|
||||
*/
|
||||
@Test
|
||||
public void test20() throws Exception {
|
||||
SerialClob sc = new SerialClob(new StubClob());
|
||||
InputStream is = sc.getAsciiStream();
|
||||
assertTrue(is != null);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate that a getCharacterStream() returns an Reader when a Clob is
|
||||
* used to create the SerialClob
|
||||
*/
|
||||
@Test
|
||||
public void test21() throws Exception {
|
||||
SerialClob sc = new SerialClob(new StubClob());
|
||||
Reader is = sc.getCharacterStream();
|
||||
assertTrue(is != null);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate that a getCharacterStream() returns an Reader when a char[] is
|
||||
* used to create the SerialClob
|
||||
*/
|
||||
@Test
|
||||
public void test22() throws Exception {
|
||||
SerialClob sc = new SerialClob(chars);
|
||||
Reader is = sc.getCharacterStream();
|
||||
assertTrue(is != null);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate that a getSubString() returns the correct value when a char[] is
|
||||
* used to create the SerialClob
|
||||
*/
|
||||
@Test
|
||||
public void test23() throws Exception {
|
||||
SerialClob sc = new SerialClob(chars);
|
||||
String expected = "world";
|
||||
assertEquals(expected, sc.getSubString(7, 5));
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate that a getSubString() returns the correct value when a Clob is
|
||||
* used to create the SerialClob
|
||||
*/
|
||||
@Test
|
||||
public void test24() throws Exception {
|
||||
SerialClob sc = new SerialClob(new StubClob());
|
||||
String expected = "test string";
|
||||
assertEquals(expected, sc.getSubString(5, 11));
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate that position() returns the correct value when a Clob is used to
|
||||
* create the SerialClob
|
||||
*/
|
||||
@Test
|
||||
public void test25() throws Exception {
|
||||
long expectedPos = 5;
|
||||
SerialClob sc = new SerialClob(new StubClob());
|
||||
String expected = "test string";
|
||||
long pos = sc.position(expected, 1);
|
||||
assertEquals(expectedPos, pos);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate that position returned is -1 when an the search string is not
|
||||
* part of the SerialClob
|
||||
*/
|
||||
@Test
|
||||
public void test26() throws Exception {
|
||||
long expectedPos = -1;
|
||||
SerialClob sc = new SerialClob(chars);
|
||||
String expected = "test string";
|
||||
long pos = sc.position(expected, 1);
|
||||
assertEquals(expectedPos, pos);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate that position() returned is -1 when an the search string is not
|
||||
* part of the SerialClob
|
||||
*/
|
||||
@Test
|
||||
public void test27() throws Exception {
|
||||
long expectedPos = -1;
|
||||
SerialClob sc = new SerialClob(new StubClob());
|
||||
String expected = "I am Batman";
|
||||
long pos = sc.position(expected, 2);
|
||||
assertEquals(expectedPos, pos);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate that position() returns the correct value when a char[] is used
|
||||
* to create the SerialClob
|
||||
*/
|
||||
@Test
|
||||
public void test28() throws Exception {
|
||||
long expectedPos = 2;
|
||||
SerialClob sc = new SerialClob(chars);
|
||||
String expected = "ello";
|
||||
long pos = sc.position(expected, 1);
|
||||
assertEquals(expectedPos, pos);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate that position() returns the correct value when a SerialClob is
|
||||
* used for the search argument
|
||||
*/
|
||||
@Test
|
||||
public void test29() throws Exception {
|
||||
long expectedPos = 21;
|
||||
String expected = "Batman";
|
||||
String buf = "I am Joker, not the Batman, hahaha";
|
||||
SerialClob sc = new SerialClob(expected.toCharArray());
|
||||
SerialClob sc1 = new SerialClob(buf.toCharArray());
|
||||
long pos = sc1.position(sc, 1);
|
||||
assertEquals(expectedPos, pos);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate that position() returns the correct value when a SerialClob is
|
||||
* used for the search argument
|
||||
*/
|
||||
@Test
|
||||
public void test30() throws Exception {
|
||||
long expectedPos = 17;
|
||||
String expected = "012";
|
||||
SerialClob sc = new SerialClob(expected.toCharArray());
|
||||
SerialClob sc1 = new SerialClob(new StubClob());
|
||||
long pos = sc1.position(sc, 1);
|
||||
assertEquals(expectedPos, pos);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check that setString() updates the appropriate characters in the
|
||||
* SerialClob
|
||||
*/
|
||||
@Test
|
||||
public void test31() throws Exception {
|
||||
String val = "Hello, I am Bruce Wayne";
|
||||
String val1 = "the Batman!";
|
||||
String expected = "Hello, I am the Batman!";
|
||||
SerialClob sc = new SerialClob(val.toCharArray());
|
||||
int written = sc.setString(13, val1);
|
||||
assertEquals(val1.length(), written);
|
||||
assertTrue(expected.equals(sc.getSubString(1, (int) sc.length())));
|
||||
}
|
||||
|
||||
/*
|
||||
* Check that setString() updates the appropriate characters in the
|
||||
* SerialClob
|
||||
*/
|
||||
@Test(enabled = false)
|
||||
public void test32() throws Exception {
|
||||
int expectedWritten = 9;
|
||||
String val = "Hi, I am Catwoman!!!!!!";
|
||||
String val1 = "Hahaha the Joker, who are you?!";
|
||||
String expected = "Hi, I am the Joker!";
|
||||
SerialClob sc = new SerialClob(val.toCharArray());
|
||||
int written = sc.setString(10, val1, 8, expectedWritten+1);
|
||||
assertEquals(written, expectedWritten);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Check that setCharacterStream() returns a non-null Writer for an
|
||||
* SerialClob created from a Clob
|
||||
*/
|
||||
@Test
|
||||
public void test33() throws Exception {
|
||||
SerialClob sc = new SerialClob(new StubClob());
|
||||
Writer w = sc.setCharacterStream(1);
|
||||
assertTrue(w != null);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check that setAsciiStream() returns a non-null OutputStream for an SerialClob
|
||||
* created from a Clob
|
||||
*/
|
||||
@Test
|
||||
public void test34() throws Exception {
|
||||
SerialClob sc = new SerialClob(new StubClob());
|
||||
OutputStream os = sc.setAsciiStream(1);
|
||||
assertTrue(os != null);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check that truncate() truncates the length of the SerialClob to the
|
||||
* specified size
|
||||
*/
|
||||
@Test
|
||||
public void test35() throws Exception {
|
||||
SerialClob sc = new SerialClob(new StubClob());
|
||||
sc.truncate(0);
|
||||
assertTrue(sc.length() == 0);
|
||||
sc = new SerialClob(chars);
|
||||
sc.truncate(5);
|
||||
assertTrue(sc.length() == 5);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check that getCharacterStream() returns a Reader and that the char[] that
|
||||
* was specified to create the SerialClob can be returned via the Reader
|
||||
*/
|
||||
@Test
|
||||
public void test36() throws Exception {
|
||||
SerialClob sc = new SerialClob(chars);
|
||||
Reader r = sc.getCharacterStream();
|
||||
for (char c : chars) {
|
||||
char val = (char) r.read();
|
||||
assertTrue(c == val, val + " does not match " + c);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Check that getCharacterStream() returns a Reader and that the char[] that
|
||||
* was specified to create the SerialClob can be returned via the Reader
|
||||
*/
|
||||
@Test(enabled = false)
|
||||
public void test37() throws Exception {
|
||||
SerialClob sc = new SerialClob(chars);
|
||||
String expected = "ello w";
|
||||
Reader r = sc.getCharacterStream(2, 6);
|
||||
for (char c : expected.toCharArray()) {
|
||||
char val = (char) r.read();
|
||||
assertTrue(c == val, val + " does not match " + c);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate that a SerialClob that is serialized & deserialized is equal to
|
||||
* itself
|
||||
*/
|
||||
@Test
|
||||
public void test38() throws Exception {
|
||||
SerialClob sc = new SerialClob(chars);
|
||||
SerialClob sc2 = serializeDeserializeObject(sc);
|
||||
assertTrue(sc.equals(sc2), "SerialClobs not equal");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package test.rowset.serial;
|
||||
|
||||
import java.net.URL;
|
||||
import javax.sql.rowset.serial.SerialDatalink;
|
||||
import javax.sql.rowset.serial.SerialException;
|
||||
import static org.testng.Assert.*;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
import util.BaseTest;
|
||||
|
||||
public class SerialDataLinkTests extends BaseTest {
|
||||
|
||||
private URL u;
|
||||
private URL u1;
|
||||
private SerialDatalink dl;
|
||||
|
||||
@BeforeMethod
|
||||
public void setUpMethod() throws Exception {
|
||||
u = new URL("http://www.oracle.com/");
|
||||
u1 = new URL("http://www.usatoday.com/");
|
||||
dl = new SerialDatalink(u);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate that a SerialException is thrown if the URL is null
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class)
|
||||
public void test() throws Exception {
|
||||
SerialDatalink dl1 = new SerialDatalink(null);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate that getDatalink() returns the same URL used to create the
|
||||
* SerialDatalink object
|
||||
*/
|
||||
@Test
|
||||
public void test01() throws Exception {
|
||||
URL u2 = dl.getDatalink();
|
||||
assertTrue(u2.equals(u));
|
||||
assertTrue(u2.sameFile(u));
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate that URL returned from getDatalink() differs from a URL that was
|
||||
* not used to create the SerialDatalink
|
||||
*/
|
||||
@Test
|
||||
public void test02() throws Exception {
|
||||
URL u2 = dl.getDatalink();
|
||||
assertFalse(u2.equals(u1));
|
||||
assertFalse(u2.sameFile(u1));
|
||||
}
|
||||
|
||||
/*
|
||||
* Create a clone of a SerialDatalink and validate that it is equal to the
|
||||
* SerialDatalink it was cloned from
|
||||
*/
|
||||
@Test
|
||||
public void test03() throws Exception {
|
||||
SerialDatalink dl2 = (SerialDatalink) dl.clone();
|
||||
assertTrue(dl.equals(dl2));
|
||||
SerialDatalink dl3 = new SerialDatalink(u1);
|
||||
assertFalse(dl2.equals(dl3));
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate that a SerialDatalink that is serialized & deserialized is
|
||||
* equal to itself
|
||||
*/
|
||||
@Test
|
||||
public void test04() throws Exception {
|
||||
SerialDatalink dl2 = serializeDeserializeObject(dl);
|
||||
SerialDatalink dl3 = new SerialDatalink(u);
|
||||
assertTrue(dl.equals(dl2));
|
||||
assertTrue(dl3.equals(dl2));
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that a SerialDatalink that is serialized & deserialized is not equal
|
||||
* to to a SerialDatalink created using a different URL
|
||||
*/
|
||||
@Test
|
||||
public void test05() throws Exception {
|
||||
SerialDatalink dl2 = serializeDeserializeObject(dl);
|
||||
SerialDatalink d3 = new SerialDatalink(u1);
|
||||
assertFalse(d3.equals(dl2));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package test.rowset.serial;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import javax.sql.rowset.serial.SerialException;
|
||||
import static org.testng.Assert.*;
|
||||
import org.testng.annotations.Test;
|
||||
import util.BaseTest;
|
||||
|
||||
public class SerialExceptionTests extends BaseTest {
|
||||
|
||||
/*
|
||||
* Create SerialException with no-arg constructor
|
||||
*/
|
||||
@Test
|
||||
public void test01() {
|
||||
SerialException ex = new SerialException();
|
||||
assertTrue(ex.getMessage() == null
|
||||
&& ex.getSQLState() == null
|
||||
&& ex.getCause() == null
|
||||
&& ex.getErrorCode() == 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Create SerialException with message
|
||||
*/
|
||||
@Test
|
||||
public void test02() {
|
||||
SerialException ex = new SerialException(reason);
|
||||
assertTrue(ex.getMessage().equals(reason)
|
||||
&& ex.getSQLState() == null
|
||||
&& ex.getCause() == null
|
||||
&& ex.getErrorCode() == 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate that the ordering of the returned Exceptions is correct using
|
||||
* for-each loop
|
||||
*/
|
||||
@Test
|
||||
public void test03() {
|
||||
SerialException ex = new SerialException("Exception 1");
|
||||
ex.initCause(t1);
|
||||
SerialException ex1 = new SerialException("Exception 2");
|
||||
SerialException ex2 = new SerialException("Exception 3");
|
||||
ex2.initCause(t2);
|
||||
ex.setNextException(ex1);
|
||||
ex.setNextException(ex2);
|
||||
int num = 0;
|
||||
for (Throwable e : ex) {
|
||||
assertTrue(msgs[num++].equals(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate that the ordering of the returned Exceptions is correct using
|
||||
* traditional while loop
|
||||
*/
|
||||
@Test
|
||||
public void test04() {
|
||||
SQLException ex = new SerialException("Exception 1");
|
||||
ex.initCause(t1);
|
||||
SerialException ex1 = new SerialException("Exception 2");
|
||||
SerialException ex2 = new SerialException("Exception 3");
|
||||
ex2.initCause(t2);
|
||||
ex.setNextException(ex1);
|
||||
ex.setNextException(ex2);
|
||||
int num = 0;
|
||||
while (ex != null) {
|
||||
assertTrue(msgs[num++].equals(ex.getMessage()));
|
||||
Throwable c = ex.getCause();
|
||||
while (c != null) {
|
||||
assertTrue(msgs[num++].equals(c.getMessage()));
|
||||
c = c.getCause();
|
||||
}
|
||||
ex = ex.getNextException();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Serialize a SerialException and make sure you can read it back properly
|
||||
*/
|
||||
@Test
|
||||
public void test05() throws Exception {
|
||||
SerialException e = new SerialException(reason);
|
||||
SerialException ex1 = createSerializedException(e);
|
||||
assertTrue(ex1.getMessage().equals(reason)
|
||||
&& ex1.getSQLState() == null
|
||||
&& ex1.getCause() == null
|
||||
&& ex1.getErrorCode() == 0);;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package test.rowset.serial;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Arrays;
|
||||
import javax.sql.rowset.RowSetMetaDataImpl;
|
||||
import javax.sql.rowset.serial.SerialException;
|
||||
import javax.sql.rowset.serial.SerialJavaObject;
|
||||
import static org.testng.Assert.*;
|
||||
import org.testng.annotations.Test;
|
||||
import util.BaseTest;
|
||||
|
||||
public class SerialJavaObjectTests extends BaseTest {
|
||||
|
||||
/*
|
||||
* Validate that an NPE is thrown when null is specified to create
|
||||
* the SerialJavaObject
|
||||
*/
|
||||
@Test(expectedExceptions = NullPointerException.class)
|
||||
public void test() throws Exception {
|
||||
SerialJavaObject sjo = new SerialJavaObject(null);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate that an SerialExcepion is thrown when the object specified
|
||||
* contains public static fields
|
||||
*/
|
||||
@Test(expectedExceptions = SerialException.class, enabled = false)
|
||||
public void test01() throws Exception {
|
||||
SerialJavaObject sjo = new SerialJavaObject(new RowSetMetaDataImpl());
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate that an getFields()s returns the same Field[] for the object
|
||||
* used to create the SerialJavaObject
|
||||
*/
|
||||
@Test
|
||||
public void test02() throws Exception {
|
||||
SerialException e = new SerialException();
|
||||
SerialJavaObject sjo = new SerialJavaObject(e);
|
||||
Field[] f = e.getClass().getFields();
|
||||
assertTrue(Arrays.equals(f, sjo.getFields()));
|
||||
assertFalse(Arrays.equals("hello".getClass().getFields(),
|
||||
sjo.getFields()));
|
||||
}
|
||||
|
||||
/*
|
||||
* clone() a SerialJavaObject and check that it is equal to the
|
||||
* object it was cloned from
|
||||
*/
|
||||
@Test
|
||||
public void test03() throws Exception {
|
||||
SerialJavaObject sjo = new SerialJavaObject("Hello");
|
||||
SerialJavaObject sjo2 = (SerialJavaObject) sjo.clone();
|
||||
assertTrue(sjo.equals(sjo2));
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that a SerialJavaObject that is serialized & deserialized is
|
||||
* equal to itself
|
||||
*/
|
||||
@Test
|
||||
public void test04() throws Exception {
|
||||
SerialJavaObject sjo = new SerialJavaObject("Hello");
|
||||
SerialJavaObject sjo2 = serializeDeserializeObject(sjo);
|
||||
assertTrue(sjo.equals(sjo2));
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate that a getObject() returns an object used to create the
|
||||
* SerialJavaObject
|
||||
*/
|
||||
@Test
|
||||
public void test05() throws Exception {
|
||||
String s = "Hello world";
|
||||
SerialJavaObject sjo = new SerialJavaObject(s);
|
||||
assertTrue(s.equals(sjo.getObject()));
|
||||
}
|
||||
}
|
||||
131
jdk/test/javax/sql/testng/test/rowset/serial/SerialRefTests.java
Normal file
131
jdk/test/javax/sql/testng/test/rowset/serial/SerialRefTests.java
Normal file
@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package test.rowset.serial;
|
||||
|
||||
import java.sql.Ref;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.sql.rowset.serial.SerialRef;
|
||||
import static org.testng.Assert.*;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
import util.BaseTest;
|
||||
import util.StubRef;
|
||||
import util.SuperHero;
|
||||
|
||||
public class SerialRefTests extends BaseTest {
|
||||
|
||||
private static Map<String, Class<?>> map = new HashMap<>();
|
||||
private Ref ref;
|
||||
private final String sqlType = "SUPERHERO";
|
||||
private SuperHero hero;
|
||||
|
||||
@BeforeMethod
|
||||
public void setUpMethod() throws Exception {
|
||||
map.put(sqlType, Class.forName("util.SuperHero"));
|
||||
hero = new SuperHero(sqlType, "Bruce", "Wayne", 1939, "Batman");
|
||||
ref = new StubRef(sqlType, hero);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate that a SQLException() is thrown if the Ref is null
|
||||
*/
|
||||
@Test(expectedExceptions = SQLException.class)
|
||||
public void test01() throws Exception {
|
||||
SerialRef sr = new SerialRef(null);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate that a SQLException() is thrown if the typeName is null in the
|
||||
* Ref used to create the SerialRef
|
||||
*/
|
||||
@Test(expectedExceptions = SQLException.class)
|
||||
public void test02() throws Exception {
|
||||
SerialRef sr = new SerialRef(new StubRef(null, hero));
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate that getBaseTypeName() returns the same SQLType specified
|
||||
* to create the Ref
|
||||
*/
|
||||
@Test
|
||||
public void test03() throws Exception {
|
||||
SerialRef sr = new SerialRef(ref);
|
||||
assertEquals(sr.getBaseTypeName(), sqlType);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate that getObject() returns the same object used to create the Ref
|
||||
*/
|
||||
@Test
|
||||
public void test04() throws Exception {
|
||||
SerialRef sr = new SerialRef(ref);
|
||||
assertTrue(hero.equals(sr.getObject()));
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate that getObject() returns the same object used to create the Ref
|
||||
*/
|
||||
@Test(enabled = false)
|
||||
public void test05() throws Exception {
|
||||
SerialRef sr = new SerialRef(ref);
|
||||
assertTrue(hero.equals(sr.getObject(map)));
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate that setObject() can be used to change the value of the object
|
||||
* pointed to by the SerialRef
|
||||
*/
|
||||
@Test
|
||||
public void test06() throws Exception {
|
||||
SerialRef sr = new SerialRef(ref);
|
||||
assertTrue(hero.equals(sr.getObject()));
|
||||
SuperHero h = new SuperHero(sqlType, "Dick", "Grayson", 1940, "Robin");
|
||||
sr.setObject(h);
|
||||
assertFalse(hero.equals(sr.getObject()));
|
||||
}
|
||||
|
||||
/*
|
||||
* clone() a SerialRef and check that it is equal to the
|
||||
* object it was cloned from
|
||||
*/
|
||||
@Test
|
||||
public void test09() throws Exception {
|
||||
SerialRef sr = new SerialRef(ref);
|
||||
SerialRef sr1 = (SerialRef) sr.clone();
|
||||
assertTrue(sr.equals(sr1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that a SerialRef that is serialized & deserialized is equal to
|
||||
* itself for the Object & baseTypeName
|
||||
*/
|
||||
@Test
|
||||
public void test10() throws Exception {
|
||||
SerialRef sr = new SerialRef(ref);
|
||||
SerialRef sr1 = serializeDeserializeObject(sr);
|
||||
assertTrue(sr1.getObject().equals(sr.getObject())
|
||||
&& sr1.getBaseTypeName().equals(sr.getBaseTypeName()));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,140 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package test.rowset.serial;
|
||||
|
||||
import java.sql.Struct;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.sql.rowset.serial.SerialStruct;
|
||||
import static org.testng.Assert.*;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
import util.BaseTest;
|
||||
import util.StubStruct;
|
||||
import util.SuperHero;
|
||||
|
||||
public class SerialStructTests extends BaseTest {
|
||||
|
||||
private static Map<String, Class<?>> map = new HashMap<>();
|
||||
private Object[] attributes;
|
||||
private Struct struct;
|
||||
private final String sqlType = "SUPERHERO";
|
||||
private SuperHero hero;
|
||||
|
||||
@BeforeMethod
|
||||
public void setUpMethod() throws Exception {
|
||||
attributes = new Object[]{"Bruce", "Wayne", 1939,
|
||||
"Batman"};
|
||||
map.put(sqlType, Class.forName("util.SuperHero"));
|
||||
struct = new StubStruct(sqlType, attributes);
|
||||
hero = new SuperHero(sqlType, "Bruce", "Wayne", 1939, "Batman");
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate that getSQLTypeName() returns the same SQLType specified by
|
||||
* the Struct used to create the object
|
||||
*/
|
||||
@Test
|
||||
public void test01() throws Exception {
|
||||
SerialStruct ss = new SerialStruct(struct, map);
|
||||
assertEquals(ss.getSQLTypeName(), sqlType);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate that getSQLTypeName() returns the same SQLType specified by
|
||||
* the Struct used to create the object
|
||||
*/
|
||||
@Test
|
||||
public void test02() throws Exception {
|
||||
SerialStruct ss = new SerialStruct(hero, map);
|
||||
assertEquals(ss.getSQLTypeName(), sqlType);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate that getAttributes() returns the same attributes specified by
|
||||
* the Struct used to create the object
|
||||
*/
|
||||
@Test
|
||||
public void test03() throws Exception {
|
||||
SerialStruct ss = new SerialStruct(struct, map);
|
||||
assertTrue(Arrays.equals(attributes,
|
||||
ss.getAttributes()));
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate that getAttributes() returns the same attributes specified by
|
||||
* the Struct used to create the object
|
||||
*/
|
||||
@Test
|
||||
public void test04() throws Exception {
|
||||
SerialStruct ss = new SerialStruct(hero, map);
|
||||
assertTrue(Arrays.equals(attributes,
|
||||
ss.getAttributes()));
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate that getAttributes() returns the
|
||||
same attributes specified by
|
||||
* the Struct used to create the object
|
||||
*/
|
||||
@Test
|
||||
public void test05() throws Exception {
|
||||
SerialStruct ss = new SerialStruct(struct, map);
|
||||
assertTrue(Arrays.equals(attributes,
|
||||
ss.getAttributes(map)));
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate that getAttributes() returns the same attributes specified by
|
||||
* the Struct used to create the object
|
||||
*/
|
||||
@Test
|
||||
public void test06() throws Exception {
|
||||
SerialStruct ss = new SerialStruct(hero, map);
|
||||
assertTrue(Arrays.equals(attributes,
|
||||
ss.getAttributes(map)));
|
||||
}
|
||||
|
||||
/*
|
||||
* clone() a SerialStruct and check that it is equal to the
|
||||
* object it was cloned from
|
||||
*/
|
||||
@Test
|
||||
public void test07() throws Exception {
|
||||
SerialStruct ss = new SerialStruct(struct, map);
|
||||
SerialStruct ss1 = (SerialStruct) ss.clone();
|
||||
assertTrue(ss.equals(ss1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that a SerialStruct that is serialized & deserialized is equal
|
||||
* to itself
|
||||
*/
|
||||
@Test
|
||||
public void test08() throws Exception {
|
||||
SerialStruct ss = new SerialStruct(struct, map);
|
||||
SerialStruct ss1 = serializeDeserializeObject(ss);;
|
||||
assertTrue(ss.equals(ss1));
|
||||
}
|
||||
}
|
||||
91
jdk/test/javax/sql/testng/util/BaseTest.java
Normal file
91
jdk/test/javax/sql/testng/util/BaseTest.java
Normal file
@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package util;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.sql.SQLException;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.AfterMethod;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
|
||||
public class BaseTest {
|
||||
|
||||
protected final String reason = "reason";
|
||||
protected final String state = "SQLState";
|
||||
protected final String cause = "java.lang.Throwable: cause";
|
||||
protected final Throwable t = new Throwable("cause");
|
||||
protected final Throwable t1 = new Throwable("cause 1");
|
||||
protected final Throwable t2 = new Throwable("cause 2");
|
||||
protected final int errorCode = 21;
|
||||
protected final String[] msgs = {"Exception 1", "cause 1", "Exception 2",
|
||||
"Exception 3", "cause 2"};
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpClass() throws Exception {
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownClass() throws Exception {
|
||||
}
|
||||
|
||||
@BeforeMethod
|
||||
public void setUpMethod() throws Exception {
|
||||
}
|
||||
|
||||
@AfterMethod
|
||||
public void tearDownMethod() throws Exception {
|
||||
}
|
||||
|
||||
/*
|
||||
* Take some form of SQLException, serialize and deserialize it
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
protected <T extends SQLException> T
|
||||
createSerializedException(T ex)
|
||||
throws IOException, ClassNotFoundException {
|
||||
return (T) serializeDeserializeObject(ex);
|
||||
}
|
||||
|
||||
/*
|
||||
* Utility method to serialize and deserialize an object
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
protected <T> T serializeDeserializeObject(T o)
|
||||
throws IOException, ClassNotFoundException {
|
||||
T o1;
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
try (ObjectOutputStream oos = new ObjectOutputStream(baos)) {
|
||||
oos.writeObject(o);
|
||||
}
|
||||
try (ObjectInputStream ois
|
||||
= new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()))) {
|
||||
o1 = (T) ois.readObject();
|
||||
}
|
||||
return o1;
|
||||
}
|
||||
}
|
||||
99
jdk/test/javax/sql/testng/util/StubArray.java
Normal file
99
jdk/test/javax/sql/testng/util/StubArray.java
Normal file
@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package util;
|
||||
|
||||
import java.sql.Array;
|
||||
import java.sql.JDBCType;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
public class StubArray implements Array {
|
||||
|
||||
private String typeName;
|
||||
Object[] elements;
|
||||
|
||||
public StubArray(String name, Object[] values) {
|
||||
typeName = name;
|
||||
elements = Arrays.copyOf(values, values.length);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBaseTypeName() throws SQLException {
|
||||
return typeName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBaseType() throws SQLException {
|
||||
return JDBCType.valueOf(typeName).getVendorTypeNumber();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getArray() throws SQLException {
|
||||
return Arrays.copyOf(elements, elements.length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getArray(Map<String, Class<?>> map) throws SQLException {
|
||||
return getArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getArray(long index, int count) throws SQLException {
|
||||
return getArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getArray(long index, int count, Map<String, Class<?>> map) throws SQLException {
|
||||
return getArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultSet getResultSet() throws SQLException {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultSet getResultSet(Map<String, Class<?>> map) throws SQLException {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultSet getResultSet(long index, int count) throws SQLException {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultSet getResultSet(long index, int count, Map<String, Class<?>> map) throws SQLException {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void free() throws SQLException {
|
||||
elements = null;
|
||||
typeName = null;
|
||||
}
|
||||
|
||||
}
|
||||
100
jdk/test/javax/sql/testng/util/StubBlob.java
Normal file
100
jdk/test/javax/sql/testng/util/StubBlob.java
Normal file
@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package util;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.sql.Blob;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Arrays;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class StubBlob implements Blob {
|
||||
|
||||
private byte[] bytes;
|
||||
|
||||
public StubBlob() {
|
||||
bytes = new byte[]{2, 4, 6, 8};
|
||||
}
|
||||
|
||||
public long length() throws SQLException {
|
||||
return bytes.length;
|
||||
}
|
||||
|
||||
public byte[] getBytes(long pos, int length)
|
||||
throws SQLException {
|
||||
return Arrays.copyOfRange(bytes, (int) pos - 1, length);
|
||||
}
|
||||
|
||||
public InputStream getBinaryStream()
|
||||
throws SQLException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public long position(byte[] pattern, long start)
|
||||
throws SQLException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long position(Blob pattern, long start)
|
||||
throws SQLException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int setBytes(long pos, byte[] bytes)
|
||||
throws SQLException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int setBytes(long pos, byte[] bytes, int offset, int len)
|
||||
throws SQLException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public OutputStream setBinaryStream(long pos)
|
||||
throws SQLException {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
ObjectOutputStream oos = null;
|
||||
try {
|
||||
oos = new ObjectOutputStream(baos);
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(StubBlob.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
return oos;
|
||||
}
|
||||
|
||||
public void truncate(long len)
|
||||
throws SQLException {
|
||||
}
|
||||
|
||||
public void free() throws SQLException {
|
||||
}
|
||||
|
||||
public InputStream getBinaryStream(long pos, long length) throws SQLException {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
113
jdk/test/javax/sql/testng/util/StubClob.java
Normal file
113
jdk/test/javax/sql/testng/util/StubClob.java
Normal file
@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package util;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.sql.Clob;
|
||||
import java.sql.SQLException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class StubClob implements Clob {
|
||||
|
||||
public String buf = "The test string 0123456789";
|
||||
|
||||
@Override
|
||||
public String getSubString(long pos, int length) throws SQLException {
|
||||
return buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long length() throws SQLException {
|
||||
return buf.length();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Reader getCharacterStream() throws SQLException {
|
||||
return new StringReader(buf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getAsciiStream() throws SQLException {
|
||||
return new java.io.StringBufferInputStream(buf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int setString(long pos, String str) throws SQLException {
|
||||
return str.length();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int setString(long pos, String str, int offset, int len) throws SQLException {
|
||||
return len;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long position(String searchstr, long start) throws SQLException {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public long position(Clob searchstr, long start) throws SQLException {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public OutputStream setAsciiStream(long pos) throws SQLException {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
ObjectOutputStream oos = null;
|
||||
try {
|
||||
oos = new ObjectOutputStream(baos);
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(StubBlob.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
return oos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Writer setCharacterStream(long pos) throws SQLException {
|
||||
return new StringWriter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void truncate(long len) throws SQLException {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void free() throws SQLException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Reader getCharacterStream(long pos, long length) throws SQLException {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
}
|
||||
60
jdk/test/javax/sql/testng/util/StubRef.java
Normal file
60
jdk/test/javax/sql/testng/util/StubRef.java
Normal file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package util;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.Ref;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map;
|
||||
|
||||
public class StubRef implements Ref, Serializable {
|
||||
|
||||
private final String baseTypeName;
|
||||
private Object obj;
|
||||
|
||||
public StubRef(String type, Object o) {
|
||||
baseTypeName = type;
|
||||
obj = o;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBaseTypeName() throws SQLException {
|
||||
return baseTypeName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getObject(Map<String, Class<?>> map) throws SQLException {
|
||||
return obj;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getObject() throws SQLException {
|
||||
return getObject(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setObject(Object value) throws SQLException {
|
||||
obj = value;
|
||||
}
|
||||
|
||||
}
|
||||
55
jdk/test/javax/sql/testng/util/StubStruct.java
Normal file
55
jdk/test/javax/sql/testng/util/StubStruct.java
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package util;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Struct;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
public class StubStruct implements Struct {
|
||||
|
||||
private final String type;
|
||||
private final Object[] attribs;
|
||||
|
||||
public StubStruct(String type, Object[] o) {
|
||||
this.type = type;
|
||||
this.attribs = Arrays.copyOf(o, o.length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLTypeName() throws SQLException {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getAttributes() throws SQLException {
|
||||
return attribs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getAttributes(Map<String, Class<?>> map) throws SQLException {
|
||||
return attribs;
|
||||
}
|
||||
|
||||
}
|
||||
106
jdk/test/javax/sql/testng/util/SuperHero.java
Normal file
106
jdk/test/javax/sql/testng/util/SuperHero.java
Normal file
@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package util;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.SQLData;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.SQLInput;
|
||||
import java.sql.SQLOutput;
|
||||
|
||||
public class SuperHero implements SQLData, Serializable {
|
||||
|
||||
private String first;
|
||||
private String last;
|
||||
private final String type;
|
||||
private Integer firstYear;
|
||||
private String secretIdentity;
|
||||
|
||||
public SuperHero(String sqlType, String fname, String lname, Integer year,
|
||||
String identity) {
|
||||
first = fname;
|
||||
last = lname;
|
||||
type = sqlType;
|
||||
firstYear = year;
|
||||
secretIdentity = identity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLTypeName() throws SQLException {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSQL(SQLInput stream, String typeName) throws SQLException {
|
||||
first = stream.readString();
|
||||
last = stream.readString();
|
||||
firstYear = stream.readInt();
|
||||
secretIdentity = stream.readString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSQL(SQLOutput stream) throws SQLException {
|
||||
stream.writeString(first);
|
||||
stream.writeString(last);
|
||||
stream.writeInt(firstYear);
|
||||
stream.writeString(secretIdentity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[ name =" + first + " " + last + " "
|
||||
+ firstYear + " " + secretIdentity + " ]";
|
||||
}
|
||||
|
||||
public void setIdentity(String identity) {
|
||||
secretIdentity = identity;
|
||||
}
|
||||
|
||||
public String getIdentity() {
|
||||
return secretIdentity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj instanceof SuperHero) {
|
||||
SuperHero ss = (SuperHero) obj;
|
||||
return first.equals(ss.first) && last.equals(ss.last)
|
||||
&& firstYear.equals(ss.firstYear)
|
||||
&& type.equals(ss.type)
|
||||
&& secretIdentity.equals(ss.secretIdentity);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return ((31 + first.hashCode()) * 31) * 31
|
||||
+ ((31 + last.hashCode()) * 31) * 31
|
||||
+ ((31 + firstYear.hashCode()) * 31) * 31
|
||||
+ ((31 + type.hashCode()) * 31) * 31
|
||||
+ secretIdentity.hashCode();
|
||||
}
|
||||
}
|
||||
@ -28,7 +28,7 @@
|
||||
* @test JdpDefaultsTest
|
||||
* @summary Assert that we can read JDP packets from a multicast socket connection, on default IP and port.
|
||||
* @library /lib/testlibrary
|
||||
* @build ClientConnection JdpTestUtil JdpTestCase JdpOnTestCase DynamicLauncher
|
||||
* @build jdk.testlibrary.* ClientConnection JdpTestUtil JdpTestCase JdpOnTestCase DynamicLauncher
|
||||
* @run main JdpDefaultsTest
|
||||
*/
|
||||
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
* @test JdpOffTest.java
|
||||
* @summary Assert that no JDP packets are sent to the default address and port.
|
||||
* @library /lib/testlibrary
|
||||
* @build ClientConnection JdpTestUtil JdpTestCase JdpOffTestCase DynamicLauncher
|
||||
* @build jdk.testlibrary.* ClientConnection JdpTestUtil JdpTestCase JdpOffTestCase DynamicLauncher
|
||||
* @run main JdpOffTest
|
||||
*/
|
||||
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
* @test JdpSpecificAddressTest
|
||||
* @summary Assert that we can read JDP packets from a multicast socket connection, on specific IP and port.
|
||||
* @library /lib/testlibrary
|
||||
* @build ClientConnection JdpTestUtil JdpTestCase JdpOnTestCase DynamicLauncher
|
||||
* @build jdk.testlibrary.* ClientConnection JdpTestUtil JdpTestCase JdpOnTestCase DynamicLauncher
|
||||
* @run main JdpSpecificAddressTest
|
||||
*/
|
||||
|
||||
|
||||
@ -42,9 +42,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
* without connection or username/password details.
|
||||
* TestManager will attempt a connection to the address obtained from
|
||||
* both agent properties and jvmstat buffer.
|
||||
* @build jdk.testlibrary.ProcessTools
|
||||
* @build jdk.testlibrary.Utils
|
||||
* @build TestManager TestApplication
|
||||
* @build jdk.testlibrary.* TestManager TestApplication
|
||||
* @run main/othervm/timeout=300 -XX:+UsePerfData LocalManagementTest
|
||||
*/
|
||||
|
||||
|
||||
@ -28,11 +28,7 @@ import java.io.IOException;
|
||||
* @library /lib/testlibrary
|
||||
* @bug 6557093
|
||||
* @summary Check SSL config file permission for out-of-the-box management
|
||||
* @build jdk.testlibrary.Utils
|
||||
* @build jdk.testlibrary.ProcessTools
|
||||
* @build jdk.testlibrary.OutputAnalyzer
|
||||
* @build AbstractFilePermissionTest
|
||||
* @build Dummy
|
||||
* @build jdk.testlibrary.* AbstractFilePermissionTest Dummy
|
||||
* @run main/timeout=300 PasswordFilePermissionTest
|
||||
*
|
||||
* @author Taras Ledkov
|
||||
|
||||
@ -27,11 +27,7 @@
|
||||
# @summary Test RMI Bootstrap
|
||||
#
|
||||
# @library /lib/testlibrary
|
||||
# @library /lib/testlibrary
|
||||
# @build jdk.testlibrary.Utils
|
||||
# @build TestLogger
|
||||
# @build Utils
|
||||
# @build RmiBootstrapTest
|
||||
# @build jdk.testlibrary.* TestLogger Utils RmiBootstrapTest
|
||||
# @run shell/timeout=300 RmiBootstrapTest.sh
|
||||
|
||||
# Define the Java class test name
|
||||
|
||||
@ -42,10 +42,7 @@ import java.util.regex.Pattern;
|
||||
* @library /lib/testlibrary
|
||||
* @bug 6228231
|
||||
* @summary Test that RMI registry uses SSL.
|
||||
* @build jdk.testlibrary.Utils
|
||||
* @build jdk.testlibrary.ProcessTools
|
||||
* @build jdk.testlibrary.OutputAnalyzer
|
||||
* @build RmiRegistrySslTestApp
|
||||
* @build jdk.testlibrary.* RmiRegistrySslTestApp
|
||||
* @run main/timeout=300 RmiRegistrySslTest
|
||||
* @author Luis-Miguel Alventosa, Taras Ledkov
|
||||
*/
|
||||
|
||||
@ -27,10 +27,7 @@
|
||||
# @summary Test RMI Bootstrap with SSL
|
||||
#
|
||||
# @library /lib/testlibrary
|
||||
# @build jdk.testlibrary.Utils
|
||||
# @build TestLogger
|
||||
# @build Utils
|
||||
# @build RmiBootstrapTest
|
||||
# @build jdk.testlibrary.* TestLogger Utils RmiBootstrapTest
|
||||
# @run shell/timeout=300 RmiSslBootstrapTest.sh
|
||||
|
||||
# Define the Java class test name
|
||||
|
||||
@ -27,12 +27,7 @@ import java.io.IOException;
|
||||
* @test
|
||||
* @library /lib/testlibrary
|
||||
* @bug 6557093
|
||||
* @bug 6557093
|
||||
* @build jdk.testlibrary.Utils
|
||||
* @build jdk.testlibrary.ProcessTools
|
||||
* @build jdk.testlibrary.OutputAnalyzer
|
||||
* @build Dummy
|
||||
* @build AbstractFilePermissionTest
|
||||
* @build jdk.testlibrary.* Dummy AbstractFilePermissionTest
|
||||
* @summary Check SSL config file permission for out-of-the-box management
|
||||
* @run main/timeout=300 SSLConfigFilePermissionTest
|
||||
*
|
||||
|
||||
@ -54,10 +54,7 @@ import jdk.testlibrary.JDKToolLauncher;
|
||||
* @test
|
||||
* @bug 7110104
|
||||
* @library /lib/testlibrary
|
||||
* @build jdk.testlibrary.ProcessTools
|
||||
* @build jdk.testlibrary.JDKToolLauncher
|
||||
* @build jdk.testlibrary.Utils
|
||||
* @build JMXStartStopTest JMXStartStopDoSomething
|
||||
* @build jdk.testlibrary.* JMXStartStopTest JMXStartStopDoSomething
|
||||
* @run main/othervm JMXStartStopTest
|
||||
* @summary Makes sure that enabling/disabling the management agent through
|
||||
* JCMD achieves the desired results
|
||||
|
||||
@ -40,7 +40,6 @@ import java.nio.file.StandardOpenOption;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.*;
|
||||
|
||||
import com.sun.security.auth.module.UnixSystem;
|
||||
import sun.security.jgss.GSSUtil;
|
||||
import sun.security.krb5.internal.APReq;
|
||||
import sun.security.krb5.internal.rcache.AuthTime;
|
||||
@ -79,13 +78,7 @@ public class ReplayCacheTestProc {
|
||||
mode = -1;
|
||||
}
|
||||
|
||||
try {
|
||||
UnixSystem us = new com.sun.security.auth.module.UnixSystem();
|
||||
uid = us.getUid();
|
||||
} catch (Throwable e) {
|
||||
// Cannot be only Exception, might be UnsatisfiedLinkError
|
||||
uid = -1;
|
||||
}
|
||||
uid = sun.misc.VM.geteuid();
|
||||
|
||||
KDC kdc = KDC.create(OneKDC.REALM, HOST, 0, true);
|
||||
for (int i=0; i<nu; i++) {
|
||||
|
||||
71
jdk/test/sun/text/resources/Format/Bug8037343.java
Normal file
71
jdk/test/sun/text/resources/Format/Bug8037343.java
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8037343
|
||||
* @summary updating dateformat for es_DO
|
||||
*/
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Locale;
|
||||
|
||||
public class Bug8037343
|
||||
{
|
||||
|
||||
public static void main(String[] arg)
|
||||
{
|
||||
final Locale esDO = new Locale("es", "DO");
|
||||
final String expectedShort = "31/03/12";
|
||||
final String expectedMedium = "31/03/2012";
|
||||
|
||||
int errors = 0;
|
||||
DateFormat format;
|
||||
String result;
|
||||
|
||||
Calendar cal = Calendar.getInstance(esDO);
|
||||
cal.set(Calendar.DAY_OF_MONTH, 31);
|
||||
cal.set(Calendar.MONTH, Calendar.MARCH);
|
||||
cal.set(Calendar.YEAR, 2012);
|
||||
|
||||
format = DateFormat.getDateInstance(DateFormat.SHORT, esDO);
|
||||
result = format.format(cal.getTime());
|
||||
if (!expectedShort.equals(result)) {
|
||||
System.out.println(String.format("Short Date format for es_DO is not as expected. Expected: [%s] Actual: [%s]", expectedShort, result));
|
||||
errors++;
|
||||
}
|
||||
|
||||
format = DateFormat.getDateInstance(DateFormat.MEDIUM, esDO);
|
||||
result = format.format(cal.getTime());
|
||||
if (!expectedMedium.equals(result)) {
|
||||
System.out.println(String.format("Medium Date format for es_DO is not as expected. Expected: [%s] Actual: [%s]", expectedMedium, result));
|
||||
errors++;
|
||||
}
|
||||
|
||||
if (errors > 0) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -483,8 +483,8 @@ FormatData/es_DO/TimePatterns/2=hh:mm:ss a
|
||||
FormatData/es_DO/TimePatterns/3=hh:mm a
|
||||
FormatData/es_DO/DatePatterns/0=EEEE d' de 'MMMM' de 'yyyy
|
||||
FormatData/es_DO/DatePatterns/1=d' de 'MMMM' de 'yyyy
|
||||
FormatData/es_DO/DatePatterns/2=MM/dd/yyyy
|
||||
FormatData/es_DO/DatePatterns/3=MM/dd/yy
|
||||
# FormatData/es_DO/DatePatterns/2=MM/dd/yyyy # Changed: see bug 8037343
|
||||
# FormatData/es_DO/DatePatterns/3=MM/dd/yy # Changed: see bug 8037343
|
||||
FormatData/es_DO/DateTimePatterns/0={1} {0}
|
||||
FormatData/es_DO/NumberElements/0=.
|
||||
FormatData/es_DO/NumberElements/1=,
|
||||
@ -7692,3 +7692,7 @@ FormatData/es_EC/TimePatterns/0=HH:mm:ss zzzz
|
||||
FormatData/es_EC/TimePatterns/1=H:mm:ss z
|
||||
FormatData/es_EC/TimePatterns/2=H:mm:ss
|
||||
FormatData/es_EC/TimePatterns/3=H:mm
|
||||
|
||||
# bug 8037343
|
||||
FormatData/es_DO/DatePatterns/2=dd/MM/yyyy
|
||||
FormatData/es_DO/DatePatterns/3=dd/MM/yy
|
||||
|
||||
@ -36,6 +36,7 @@
|
||||
* 6919624 6998391 7019267 7020960 7025837 7020583 7036905 7066203 7101495
|
||||
* 7003124 7085757 7028073 7171028 7189611 8000983 7195759 8004489 8006509
|
||||
* 7114053 7074882 7040556 8013836 8021121 6192407 6931564 8027695 8017142
|
||||
* 8037343
|
||||
* @summary Verify locale data
|
||||
*
|
||||
*/
|
||||
|
||||
@ -41,7 +41,7 @@ import jdk.testlibrary.Utils;
|
||||
* @bug 7104647 7154822
|
||||
* @library /lib/testlibrary
|
||||
* @build jdk.testlibrary.*
|
||||
* @run main TestJcmdSanity
|
||||
* @run main/othervm -XX:+UsePerfData TestJcmdSanity
|
||||
*/
|
||||
public class TestJcmdSanity {
|
||||
|
||||
|
||||
@ -28,8 +28,7 @@
|
||||
* @summary Test checks case when target application finishes execution and jstat didn't complete work.
|
||||
jstat is started with interval = 100 (jstat -compiler 100) and monitored application finishes
|
||||
after 500ms. This shouldn't cause crash or hang in target application or in jstat.
|
||||
* @build jdk.testlibrary.ProcessTools jdk.testlibrary.JDKToolLauncher
|
||||
* @build JStatInterval
|
||||
* @build jdk.testlibrary.* JStatInterval
|
||||
* @run main JStatInterval
|
||||
*/
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user