--- a/jdk/.hgtags Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/.hgtags Tue May 03 22:14:39 2011 -0700
@@ -114,3 +114,4 @@
29296ea6529a418037ccce95903249665ef31c11 jdk7-b137
60d3d55dcc9c31a30ced9caa6ef5c0dcd7db031d jdk7-b138
d80954a89b49fda47c0c5cace65a17f5a758b8bd jdk7-b139
+9315c733fb17ddfb9fb44be7e0ffea37bf3c727d jdk7-b140
--- a/jdk/src/share/classes/java/awt/Component.java Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/src/share/classes/java/awt/Component.java Tue May 03 22:14:39 2011 -0700
@@ -2945,6 +2945,46 @@
}
/**
+ * Revalidates the component hierarchy up to the nearest validate root.
+ * <p>
+ * This method first invalidates the component hierarchy starting from this
+ * component up to the nearest validate root. Afterwards, the component
+ * hierarchy is validated starting from the nearest validate root.
+ * <p>
+ * This is a convenience method supposed to help application developers
+ * avoid looking for validate roots manually. Basically, it's equivalent to
+ * first calling the {@link #invalidate()} method on this component, and
+ * then calling the {@link #validate()} method on the nearest validate
+ * root.
+ *
+ * @see Container#isValidateRoot
+ * @since 1.7
+ */
+ public void revalidate() {
+ synchronized (getTreeLock()) {
+ invalidate();
+
+ Container root = getContainer();
+ if (root == null) {
+ // There's no parents. Just validate itself.
+ validate();
+ } else {
+ while (!root.isValidateRoot()) {
+ if (root.getContainer() == null) {
+ // If there's no validate roots, we'll validate the
+ // topmost container
+ break;
+ }
+
+ root = root.getContainer();
+ }
+
+ root.validate();
+ }
+ }
+ }
+
+ /**
* Creates a graphics context for this component. This method will
* return <code>null</code> if this component is currently not
* displayable.
--- a/jdk/src/share/classes/java/awt/GraphicsDevice.java Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/src/share/classes/java/awt/GraphicsDevice.java Tue May 03 22:14:39 2011 -0700
@@ -257,6 +257,11 @@
* 1.0f, and the background color alpha is set to 255 (completely opaque).
* These values are not restored when returning to windowed mode.
* <p>
+ * It is unspecified and platform-dependent how decorated windows operate
+ * in full-screen mode. For this reason, it is recommended to turn off
+ * the decorations in a {@code Frame} or {@code Dialog} object by using the
+ * {@code setUndecorated} method.
+ * <p>
* When returning to windowed mode from an exclusive full-screen window,
* any display changes made by calling {@code setDisplayMode} are
* automatically restored to their original state.
@@ -272,6 +277,8 @@
* @see #setDisplayMode
* @see Component#enableInputMethods
* @see Component#setVisible
+ * @see Frame#setUndecorated
+ * @see Dialog#setUndecorated
*
* @since 1.4
*/
--- a/jdk/src/share/classes/java/awt/RadialGradientPaint.java Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/src/share/classes/java/awt/RadialGradientPaint.java Tue May 03 22:14:39 2011 -0700
@@ -49,9 +49,11 @@
* from the focus point to the circumference will thus span all the gradient
* colors.
* <p>
- * Specifying a focus point outside of the circle's radius will result in the
- * focus being set to the intersection point of the focus-center line and the
- * perimeter of the circle.
+ * Specifying a focus point outside of the radius of the circle will cause
+ * the rings of the gradient pattern to be centered on the point just inside
+ * the edge of the circle in the direction of the focus point.
+ * The rendering will internally use this modified location as if it were
+ * the specified focus point.
* <p>
* The user must provide an array of floats specifying how to distribute the
* colors along the gradient. These values should range from 0.0 to 1.0 and
@@ -621,6 +623,11 @@
/**
* Returns a copy of the focus point of the radial gradient.
+ * Note that if the focus point specified when the radial gradient
+ * was constructed lies outside of the radius of the circle, this
+ * method will still return the original focus point even though
+ * the rendering may center the rings of color on a different
+ * point that lies inside the radius.
*
* @return a {@code Point2D} object that is a copy of the focus point
*/
--- a/jdk/src/share/classes/java/awt/Toolkit.java Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/src/share/classes/java/awt/Toolkit.java Tue May 03 22:14:39 2011 -0700
@@ -1870,11 +1870,15 @@
/**
* Adds the specified property change listener for the named desktop
- * property.
- * If pcl is null, no exception is thrown and no action is performed.
+ * property. When a {@link PropertyChangeListenerProxy} object is added,
+ * its property name is ignored, and the wrapped listener is added.
+ * If {@code name} is {@code null} or {@code pcl} is {@code null},
+ * no exception is thrown and no action is performed.
*
* @param name The name of the property to listen for
* @param pcl The property change listener
+ * @see PropertyChangeSupport#addPropertyChangeListener(String,
+ PropertyChangeListener)
* @since 1.2
*/
public void addPropertyChangeListener(String name, PropertyChangeListener pcl) {
@@ -1883,11 +1887,16 @@
/**
* Removes the specified property change listener for the named
- * desktop property.
- * If pcl is null, no exception is thrown and no action is performed.
+ * desktop property. When a {@link PropertyChangeListenerProxy} object
+ * is removed, its property name is ignored, and
+ * the wrapped listener is removed.
+ * If {@code name} is {@code null} or {@code pcl} is {@code null},
+ * no exception is thrown and no action is performed.
*
* @param name The name of the property to remove
* @param pcl The property change listener
+ * @see PropertyChangeSupport#removePropertyChangeListener(String,
+ PropertyChangeListener)
* @since 1.2
*/
public void removePropertyChangeListener(String name, PropertyChangeListener pcl) {
@@ -1896,12 +1905,15 @@
/**
* Returns an array of all the property change listeners
- * registered on this toolkit.
+ * registered on this toolkit. The returned array
+ * contains {@code PropertyChangeListenerProxy} objects
+ * that associate listeners with the names of desktop properties.
*
- * @return all of this toolkit's <code>PropertyChangeListener</code>s
- * or an empty array if no property change
- * listeners are currently registered
+ * @return all of this toolkit's {@ code PropertyChangeListener}
+ * objects wrapped in {@code PropertyChangeListenerProxy} objects
+ * or an empty array if no listeners are added
*
+ * @see PropertyChangeSupport#getPropertyChangeListeners()
* @since 1.4
*/
public PropertyChangeListener[] getPropertyChangeListeners() {
@@ -1909,13 +1921,15 @@
}
/**
- * Returns an array of all the <code>PropertyChangeListener</code>s
- * associated with the named property.
+ * Returns an array of all property change listeners
+ * associated with the specified name of a desktop property.
*
* @param propertyName the named property
- * @return all of the <code>PropertyChangeListener</code>s associated with
- * the named property or an empty array if no such listeners have
- * been added
+ * @return all of the {@code PropertyChangeListener} objects
+ * associated with the specified name of a desktop property
+ * or an empty array if no such listeners are added
+ *
+ * @see PropertyChangeSupport#getPropertyChangeListeners(String)
* @since 1.4
*/
public PropertyChangeListener[] getPropertyChangeListeners(String propertyName) {
--- a/jdk/src/share/classes/java/awt/geom/Arc2D.java Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/src/share/classes/java/awt/geom/Arc2D.java Tue May 03 22:14:39 2011 -0700
@@ -681,7 +681,7 @@
* @see java.awt.geom.Arc2D.Float
* @see java.awt.geom.Arc2D.Double
*/
- Arc2D() {
+ protected Arc2D() {
this(OPEN);
}
--- a/jdk/src/share/classes/java/awt/geom/Path2D.java Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/src/share/classes/java/awt/geom/Path2D.java Tue May 03 22:14:39 2011 -0700
@@ -732,7 +732,7 @@
*
* @since 1.6
*/
- public PathIterator getPathIterator(AffineTransform at) {
+ public final PathIterator getPathIterator(AffineTransform at) {
if (at == null) {
return new CopyIterator(this);
} else {
@@ -1461,7 +1461,7 @@
* of this {@code Shape}'s outline
* @since 1.6
*/
- public PathIterator getPathIterator(AffineTransform at) {
+ public final PathIterator getPathIterator(AffineTransform at) {
if (at == null) {
return new CopyIterator(this);
} else {
@@ -2342,8 +2342,8 @@
*
* @since 1.6
*/
- public PathIterator getPathIterator(AffineTransform at,
- double flatness)
+ public final PathIterator getPathIterator(AffineTransform at,
+ double flatness)
{
return new FlatteningPathIterator(getPathIterator(at), flatness);
}
--- a/jdk/src/share/classes/java/util/jar/JarFile.java Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/src/share/classes/java/util/jar/JarFile.java Tue May 03 22:14:39 2011 -0700
@@ -37,7 +37,6 @@
import sun.security.action.GetPropertyAction;
import sun.security.util.ManifestEntryVerifier;
import sun.misc.SharedSecrets;
-import sun.security.util.SignatureFileVerifier;
/**
* The <code>JarFile</code> class is used to read the contents of a jar file
@@ -179,7 +178,7 @@
byte[] b = getBytes(manEntry);
man = new Manifest(new ByteArrayInputStream(b));
if (!jvInitialized) {
- jv = new JarVerifier(b, man);
+ jv = new JarVerifier(b);
}
} else {
man = new Manifest(super.getInputStream(manEntry));
@@ -298,7 +297,10 @@
if (names != null) {
for (int i = 0; i < names.length; i++) {
String name = names[i].toUpperCase(Locale.ENGLISH);
- if (SignatureFileVerifier.isBlockOrSF(name)) {
+ if (name.endsWith(".DSA") ||
+ name.endsWith(".RSA") ||
+ name.endsWith(".EC") ||
+ name.endsWith(".SF")) {
// Assume since we found a signature-related file
// that the jar is signed and that we therefore
// need a JarVerifier and Manifest
@@ -327,17 +329,17 @@
if (names != null) {
for (int i = 0; i < names.length; i++) {
JarEntry e = getJarEntry(names[i]);
- if (!e.isDirectory() &&
- SignatureFileVerifier.isBlock(names[i])) {
+ if (!e.isDirectory()) {
if (mev == null) {
mev = new ManifestEntryVerifier
(getManifestFromReference());
}
- String key = names[i].substring(
- 0, names[i].lastIndexOf("."));
- jv.verifyBlock(names[i],
- getBytes(e),
- super.getInputStream(getJarEntry(key + ".SF")));
+ byte[] b = getBytes(e);
+ if (b != null && b.length > 0) {
+ jv.beginEntry(e, mev);
+ jv.update(b.length, b, 0, b.length, mev);
+ jv.update(-1, null, 0, 0, mev);
+ }
}
}
}
--- a/jdk/src/share/classes/java/util/jar/JarInputStream.java Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/src/share/classes/java/util/jar/JarInputStream.java Tue May 03 22:14:39 2011 -0700
@@ -95,7 +95,7 @@
man.read(new ByteArrayInputStream(bytes));
closeEntry();
if (doVerify) {
- jv = new JarVerifier(bytes, man);
+ jv = new JarVerifier(bytes);
mev = new ManifestEntryVerifier(man);
}
return (JarEntry)super.getNextEntry();
--- a/jdk/src/share/classes/java/util/jar/JarVerifier.java Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/src/share/classes/java/util/jar/JarVerifier.java Tue May 03 22:14:39 2011 -0700
@@ -48,18 +48,35 @@
/* a table mapping names to code signers, for jar entries that have
had their actual hashes verified */
- private Map verifiedSigners;
+ private Hashtable verifiedSigners;
/* a table mapping names to code signers, for jar entries that have
passed the .SF/.DSA/.EC -> MANIFEST check */
- private Map sigFileSigners;
+ private Hashtable sigFileSigners;
+
+ /* a hash table to hold .SF bytes */
+ private Hashtable sigFileData;
+
+ /** "queue" of pending PKCS7 blocks that we couldn't parse
+ * until we parsed the .SF file */
+ private ArrayList pendingBlocks;
/* cache of CodeSigner objects */
private ArrayList signerCache;
+ /* Are we parsing a block? */
+ private boolean parsingBlockOrSF = false;
+
+ /* Are we done parsing META-INF entries? */
+ private boolean parsingMeta = true;
+
/* Are there are files to verify? */
private boolean anyToVerify = true;
+ /* The output stream to use when keeping track of files we are interested
+ in */
+ private ByteArrayOutputStream baos;
+
/** The ManifestDigester object */
private volatile ManifestDigester manDig;
@@ -75,20 +92,20 @@
/** collect -DIGEST-MANIFEST values for blacklist */
private List manifestDigests;
- /** The manifest object */
- Manifest man = null;
-
- public JarVerifier(byte rawBytes[], Manifest man) {
- this.man = man;
+ public JarVerifier(byte rawBytes[]) {
manifestRawBytes = rawBytes;
- sigFileSigners = new HashMap();
- verifiedSigners = new HashMap();
+ sigFileSigners = new Hashtable();
+ verifiedSigners = new Hashtable();
+ sigFileData = new Hashtable(11);
+ pendingBlocks = new ArrayList();
+ baos = new ByteArrayOutputStream();
manifestDigests = new ArrayList();
}
/**
- * This method scans to see which entry we're parsing and keeps
- * various state information depending on the file being parsed.
+ * This method scans to see which entry we're parsing and
+ * keeps various state information depending on what type of
+ * file is being parsed.
*/
public void beginEntry(JarEntry je, ManifestEntryVerifier mev)
throws IOException
@@ -112,6 +129,30 @@
* b. digest mismatch between the actual jar entry and the manifest
*/
+ if (parsingMeta) {
+ String uname = name.toUpperCase(Locale.ENGLISH);
+ if ((uname.startsWith("META-INF/") ||
+ uname.startsWith("/META-INF/"))) {
+
+ if (je.isDirectory()) {
+ mev.setEntry(null, je);
+ return;
+ }
+
+ if (SignatureFileVerifier.isBlockOrSF(uname)) {
+ /* We parse only DSA, RSA or EC PKCS7 blocks. */
+ parsingBlockOrSF = true;
+ baos.reset();
+ mev.setEntry(null, je);
+ }
+ return;
+ }
+ }
+
+ if (parsingMeta) {
+ doneWithMeta();
+ }
+
if (je.isDirectory()) {
mev.setEntry(null, je);
return;
@@ -147,7 +188,11 @@
throws IOException
{
if (b != -1) {
- mev.update((byte)b);
+ if (parsingBlockOrSF) {
+ baos.write(b);
+ } else {
+ mev.update((byte)b);
+ }
} else {
processEntry(mev);
}
@@ -162,7 +207,11 @@
throws IOException
{
if (n != -1) {
- mev.update(b, off, n);
+ if (parsingBlockOrSF) {
+ baos.write(b, off, n);
+ } else {
+ mev.update(b, off, n);
+ }
} else {
processEntry(mev);
}
@@ -174,10 +223,101 @@
private void processEntry(ManifestEntryVerifier mev)
throws IOException
{
- JarEntry je = mev.getEntry();
- if ((je != null) && (je.signers == null)) {
- je.signers = mev.verify(verifiedSigners, sigFileSigners);
- je.certs = mapSignersToCertArray(je.signers);
+ if (!parsingBlockOrSF) {
+ JarEntry je = mev.getEntry();
+ if ((je != null) && (je.signers == null)) {
+ je.signers = mev.verify(verifiedSigners, sigFileSigners);
+ je.certs = mapSignersToCertArray(je.signers);
+ }
+ } else {
+
+ try {
+ parsingBlockOrSF = false;
+
+ if (debug != null) {
+ debug.println("processEntry: processing block");
+ }
+
+ String uname = mev.getEntry().getName()
+ .toUpperCase(Locale.ENGLISH);
+
+ if (uname.endsWith(".SF")) {
+ String key = uname.substring(0, uname.length()-3);
+ byte bytes[] = baos.toByteArray();
+ // add to sigFileData in case future blocks need it
+ sigFileData.put(key, bytes);
+ // check pending blocks, we can now process
+ // anyone waiting for this .SF file
+ Iterator it = pendingBlocks.iterator();
+ while (it.hasNext()) {
+ SignatureFileVerifier sfv =
+ (SignatureFileVerifier) it.next();
+ if (sfv.needSignatureFile(key)) {
+ if (debug != null) {
+ debug.println(
+ "processEntry: processing pending block");
+ }
+
+ sfv.setSignatureFile(bytes);
+ sfv.process(sigFileSigners, manifestDigests);
+ }
+ }
+ return;
+ }
+
+ // now we are parsing a signature block file
+
+ String key = uname.substring(0, uname.lastIndexOf("."));
+
+ if (signerCache == null)
+ signerCache = new ArrayList();
+
+ if (manDig == null) {
+ synchronized(manifestRawBytes) {
+ if (manDig == null) {
+ manDig = new ManifestDigester(manifestRawBytes);
+ manifestRawBytes = null;
+ }
+ }
+ }
+
+ SignatureFileVerifier sfv =
+ new SignatureFileVerifier(signerCache,
+ manDig, uname, baos.toByteArray());
+
+ if (sfv.needSignatureFileBytes()) {
+ // see if we have already parsed an external .SF file
+ byte[] bytes = (byte[]) sigFileData.get(key);
+
+ if (bytes == null) {
+ // put this block on queue for later processing
+ // since we don't have the .SF bytes yet
+ // (uname, block);
+ if (debug != null) {
+ debug.println("adding pending block");
+ }
+ pendingBlocks.add(sfv);
+ return;
+ } else {
+ sfv.setSignatureFile(bytes);
+ }
+ }
+ sfv.process(sigFileSigners, manifestDigests);
+
+ } catch (IOException ioe) {
+ // e.g. sun.security.pkcs.ParsingException
+ if (debug != null) debug.println("processEntry caught: "+ioe);
+ // ignore and treat as unsigned
+ } catch (SignatureException se) {
+ if (debug != null) debug.println("processEntry caught: "+se);
+ // ignore and treat as unsigned
+ } catch (NoSuchAlgorithmException nsae) {
+ if (debug != null) debug.println("processEntry caught: "+nsae);
+ // ignore and treat as unsigned
+ } catch (CertificateException ce) {
+ if (debug != null) debug.println("processEntry caught: "+ce);
+ // ignore and treat as unsigned
+ }
}
}
@@ -214,15 +354,15 @@
* Force a read of the entry data to generate the
* verification hash.
*/
- try (InputStream s = jar.getInputStream(entry)) {
+ try {
+ InputStream s = jar.getInputStream(entry);
byte[] buffer = new byte[1024];
int n = buffer.length;
while (n != -1) {
n = s.read(buffer, 0, buffer.length);
}
+ s.close();
} catch (IOException e) {
- // Ignore. When an exception is thrown, code signer
- // will not be assigned.
}
}
return getCodeSigners(name);
@@ -268,7 +408,11 @@
*/
void doneWithMeta()
{
+ parsingMeta = false;
anyToVerify = !sigFileSigners.isEmpty();
+ baos = null;
+ sigFileData = null;
+ pendingBlocks = null;
signerCache = null;
manDig = null;
// MANIFEST.MF is always treated as signed and verified,
@@ -279,41 +423,6 @@
}
}
- /**
- * Verifies a PKCS7 SignedData block
- * @param key name of block
- * @param block the pkcs7 file
- * @param ins the clear data
- */
- void verifyBlock(String key, byte[] block, InputStream ins) {
- try {
- if (signerCache == null)
- signerCache = new ArrayList();
-
- if (manDig == null) {
- synchronized(manifestRawBytes) {
- if (manDig == null) {
- manDig = new ManifestDigester(manifestRawBytes);
- manifestRawBytes = null;
- }
- }
- }
- SignatureFileVerifier sfv =
- new SignatureFileVerifier(signerCache, man,
- manDig, key, block);
-
- if (sfv.needSignatureFile()) {
- // see if we have already parsed an external .SF file
- sfv.setSignatureFile(ins);
- }
- sfv.process(sigFileSigners, manifestDigests);
- } catch (Exception e) {
- if (debug != null) {
- e.printStackTrace();
- }
- }
- }
-
static class VerifierStream extends java.io.InputStream {
private InputStream is;
@@ -444,7 +553,10 @@
* but this handles a CodeSource of any type, just in case.
*/
CodeSource[] sources = mapSignersToCodeSources(cs.getLocation(), getJarCodeSigners(), true);
- List sourceList = Arrays.asList(sources);
+ List sourceList = new ArrayList();
+ for (int i = 0; i < sources.length; i++) {
+ sourceList.add(sources[i]);
+ }
int j = sourceList.indexOf(cs);
if (j != -1) {
CodeSigner[] match;
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicSplitPaneDivider.java Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicSplitPaneDivider.java Tue May 03 22:14:39 2011 -0700
@@ -154,7 +154,7 @@
setBackground(UIManager.getColor("SplitPane.background"));
}
- private void revalidate() {
+ private void revalidateSplitPane() {
invalidate();
if (splitPane != null) {
splitPane.revalidate();
@@ -315,7 +315,7 @@
setCursor((orientation == JSplitPane.HORIZONTAL_SPLIT) ?
Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR) :
Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR));
- revalidate();
+ revalidateSplitPane();
}
else if (e.getPropertyName() == JSplitPane.
ONE_TOUCH_EXPANDABLE_PROPERTY) {
@@ -376,7 +376,7 @@
add(rightButton);
}
}
- revalidate();
+ revalidateSplitPane();
}
--- a/jdk/src/share/classes/sun/awt/datatransfer/DataTransferer.java Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/src/share/classes/sun/awt/datatransfer/DataTransferer.java Tue May 03 22:14:39 2011 -0700
@@ -29,12 +29,10 @@
import java.awt.EventQueue;
import java.awt.Image;
import java.awt.Graphics;
-import java.awt.Toolkit;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.FlavorMap;
import java.awt.datatransfer.FlavorTable;
-import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
@@ -66,8 +64,6 @@
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
-import java.security.AccessControlContext;
-import java.security.AccessControlException;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.security.PrivilegedActionException;
@@ -171,7 +167,26 @@
*/
public static final DataFlavor javaTextEncodingFlavor;
- private static SortedSet standardEncodings;
+ /**
+ * Lazy initialization of Standard Encodings.
+ */
+ private static class StandardEncodingsHolder {
+ private static final SortedSet standardEncodings = load();
+
+ private static SortedSet load() {
+ final Comparator comparator =
+ new CharsetComparator(IndexedComparator.SELECT_WORST);
+ final SortedSet tempSet = new TreeSet(comparator);
+ tempSet.add("US-ASCII");
+ tempSet.add("ISO-8859-1");
+ tempSet.add("UTF-8");
+ tempSet.add("UTF-16BE");
+ tempSet.add("UTF-16LE");
+ tempSet.add("UTF-16");
+ tempSet.add(getDefaultTextCharset());
+ return Collections.unmodifiableSortedSet(tempSet);
+ }
+ }
/**
* Tracks whether a particular text/* MIME type supports the charset
@@ -509,18 +524,7 @@
* non-standard, character sets are not included.
*/
public static Iterator standardEncodings() {
- if (standardEncodings == null) {
- TreeSet tempSet = new TreeSet(defaultCharsetComparator);
- tempSet.add("US-ASCII");
- tempSet.add("ISO-8859-1");
- tempSet.add("UTF-8");
- tempSet.add("UTF-16BE");
- tempSet.add("UTF-16LE");
- tempSet.add("UTF-16");
- tempSet.add(getDefaultTextCharset());
- standardEncodings = Collections.unmodifiableSortedSet(tempSet);
- }
- return standardEncodings.iterator();
+ return StandardEncodingsHolder.standardEncodings.iterator();
}
/**
@@ -2398,7 +2402,9 @@
public static DataFlavor[] setToSortedDataFlavorArray(Set flavorsSet) {
DataFlavor[] flavors = new DataFlavor[flavorsSet.size()];
flavorsSet.toArray(flavors);
- Arrays.sort(flavors, defaultFlavorComparator);
+ final Comparator comparator =
+ new DataFlavorComparator(IndexedComparator.SELECT_WORST);
+ Arrays.sort(flavors, comparator);
return flavors;
}
@@ -2455,11 +2461,6 @@
return new ArrayList();
}
- private static CharsetComparator defaultCharsetComparator =
- new CharsetComparator(IndexedComparator.SELECT_WORST);
- private static DataFlavorComparator defaultFlavorComparator =
- new DataFlavorComparator(IndexedComparator.SELECT_WORST);
-
/**
* A Comparator which includes a helper function for comparing two Objects
* which are likely to be keys in the specified Map.
--- a/jdk/src/share/classes/sun/java2d/pisces/Stroker.java Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/src/share/classes/sun/java2d/pisces/Stroker.java Tue May 03 22:14:39 2011 -0700
@@ -27,6 +27,8 @@
import java.util.Arrays;
import java.util.Iterator;
+import static java.lang.Math.ulp;
+import static java.lang.Math.sqrt;
import sun.awt.geom.PathConsumer2D;
@@ -130,7 +132,7 @@
private static void computeOffset(final float lx, final float ly,
final float w, final float[] m)
{
- final float len = (float)Math.sqrt(lx*lx + ly*ly);
+ final float len = (float) sqrt(lx*lx + ly*ly);
if (len == 0) {
m[0] = m[1] = 0;
} else {
@@ -217,7 +219,7 @@
// this normal's length is at least 0.5 and at most sqrt(2)/2 (because
// we know the angle of the arc is > 90 degrees).
float nx = my - omy, ny = omx - mx;
- float nlen = (float)Math.sqrt(nx*nx + ny*ny);
+ float nlen = (float) sqrt(nx*nx + ny*ny);
float scale = lineWidth2/nlen;
float mmx = nx * scale, mmy = ny * scale;
@@ -246,8 +248,8 @@
// define the bezier curve we're computing.
// It is computed using the constraints that P1-P0 and P3-P2 are parallel
// to the arc tangents at the endpoints, and that |P1-P0|=|P3-P2|.
- float cv = (float)((4.0 / 3.0) * Math.sqrt(0.5-cosext2) /
- (1.0 + Math.sqrt(cosext2+0.5)));
+ float cv = (float) ((4.0 / 3.0) * sqrt(0.5-cosext2) /
+ (1.0 + sqrt(cosext2+0.5)));
// if clockwise, we need to negate cv.
if (rev) { // rev is equivalent to isCW(omx, omy, mx, my)
cv = -cv;
@@ -284,28 +286,20 @@
false);
}
- // Return the intersection point of the lines (x0, y0) -> (x1, y1)
- // and (x0p, y0p) -> (x1p, y1p) in m[0] and m[1]
- private void computeMiter(final float x0, final float y0,
- final float x1, final float y1,
- final float x0p, final float y0p,
- final float x1p, final float y1p,
- final float[] m, int off)
+ // Put the intersection point of the lines (x0, y0) -> (x1, y1)
+ // and (x0p, y0p) -> (x1p, y1p) in m[off] and m[off+1].
+ // If the lines are parallel, it will put a non finite number in m.
+ private void computeIntersection(final float x0, final float y0,
+ final float x1, final float y1,
+ final float x0p, final float y0p,
+ final float x1p, final float y1p,
+ final float[] m, int off)
{
float x10 = x1 - x0;
float y10 = y1 - y0;
float x10p = x1p - x0p;
float y10p = y1p - y0p;
- // if this is 0, the lines are parallel. If they go in the
- // same direction, there is no intersection so m[off] and
- // m[off+1] will contain infinity, so no miter will be drawn.
- // If they go in the same direction that means that the start of the
- // current segment and the end of the previous segment have the same
- // tangent, in which case this method won't even be involved in
- // miter drawing because it won't be called by drawMiter (because
- // (mx == omx && my == omy) will be true, and drawMiter will return
- // immediately).
float den = x10*y10p - x10p*y10;
float t = x10p*(y0-y0p) - y10p*(x0-x0p);
t /= den;
@@ -321,7 +315,8 @@
{
if ((mx == omx && my == omy) ||
(pdx == 0 && pdy == 0) ||
- (dx == 0 && dy == 0)) {
+ (dx == 0 && dy == 0))
+ {
return;
}
@@ -332,12 +327,17 @@
my = -my;
}
- computeMiter((x0 - pdx) + omx, (y0 - pdy) + omy, x0 + omx, y0 + omy,
- (dx + x0) + mx, (dy + y0) + my, x0 + mx, y0 + my,
- miter, 0);
+ computeIntersection((x0 - pdx) + omx, (y0 - pdy) + omy, x0 + omx, y0 + omy,
+ (dx + x0) + mx, (dy + y0) + my, x0 + mx, y0 + my,
+ miter, 0);
float lenSq = (miter[0]-x0)*(miter[0]-x0) + (miter[1]-y0)*(miter[1]-y0);
+ // If the lines are parallel, lenSq will be either NaN or +inf
+ // (actually, I'm not sure if the latter is possible. The important
+ // thing is that -inf is not possible, because lenSq is a square).
+ // For both of those values, the comparison below will fail and
+ // no miter will be drawn, which is correct.
if (lenSq < miterLimitSq) {
emitLineTo(miter[0], miter[1], rev);
}
@@ -566,8 +566,8 @@
// if p1 == p2 && p3 == p4: draw line from p1->p4, unless p1 == p4,
// in which case ignore if p1 == p2
- final boolean p1eqp2 = within(x1,y1,x2,y2, 6 * Math.ulp(y2));
- final boolean p3eqp4 = within(x3,y3,x4,y4, 6 * Math.ulp(y4));
+ final boolean p1eqp2 = within(x1,y1,x2,y2, 6 * ulp(y2));
+ final boolean p3eqp4 = within(x3,y3,x4,y4, 6 * ulp(y4));
if (p1eqp2 && p3eqp4) {
getLineOffsets(x1, y1, x4, y4, leftOff, rightOff);
return 4;
@@ -583,7 +583,7 @@
float dotsq = (dx1 * dx4 + dy1 * dy4);
dotsq = dotsq * dotsq;
float l1sq = dx1 * dx1 + dy1 * dy1, l4sq = dx4 * dx4 + dy4 * dy4;
- if (Helpers.within(dotsq, l1sq * l4sq, 4 * Math.ulp(dotsq))) {
+ if (Helpers.within(dotsq, l1sq * l4sq, 4 * ulp(dotsq))) {
getLineOffsets(x1, y1, x4, y4, leftOff, rightOff);
return 4;
}
@@ -693,8 +693,6 @@
return 8;
}
- // compute offset curves using bezier spline through t=0.5 (i.e.
- // ComputedCurve(0.5) == IdealParallelCurve(0.5))
// return the kind of curve in the right and left arrays.
private int computeOffsetQuad(float[] pts, final int off,
float[] leftOff, float[] rightOff)
@@ -703,56 +701,67 @@
final float x2 = pts[off + 2], y2 = pts[off + 3];
final float x3 = pts[off + 4], y3 = pts[off + 5];
- float dx3 = x3 - x2;
- float dy3 = y3 - y2;
- float dx1 = x2 - x1;
- float dy1 = y2 - y1;
+ final float dx3 = x3 - x2;
+ final float dy3 = y3 - y2;
+ final float dx1 = x2 - x1;
+ final float dy1 = y2 - y1;
+
+ // this computes the offsets at t = 0, 1
+ computeOffset(dx1, dy1, lineWidth2, offset[0]);
+ computeOffset(dx3, dy3, lineWidth2, offset[1]);
+
+ leftOff[0] = x1 + offset[0][0]; leftOff[1] = y1 + offset[0][1];
+ leftOff[4] = x3 + offset[1][0]; leftOff[5] = y3 + offset[1][1];
+ rightOff[0] = x1 - offset[0][0]; rightOff[1] = y1 - offset[0][1];
+ rightOff[4] = x3 - offset[1][0]; rightOff[5] = y3 - offset[1][1];
+
+ float x1p = leftOff[0]; // start
+ float y1p = leftOff[1]; // point
+ float x3p = leftOff[4]; // end
+ float y3p = leftOff[5]; // point
- // if p1=p2 or p3=p4 it means that the derivative at the endpoint
- // vanishes, which creates problems with computeOffset. Usually
- // this happens when this stroker object is trying to winden
- // a curve with a cusp. What happens is that curveTo splits
- // the input curve at the cusp, and passes it to this function.
- // because of inaccuracies in the splitting, we consider points
- // equal if they're very close to each other.
+ // Corner cases:
+ // 1. If the two control vectors are parallel, we'll end up with NaN's
+ // in leftOff (and rightOff in the body of the if below), so we'll
+ // do getLineOffsets, which is right.
+ // 2. If the first or second two points are equal, then (dx1,dy1)==(0,0)
+ // or (dx3,dy3)==(0,0), so (x1p, y1p)==(x1p+dx1, y1p+dy1)
+ // or (x3p, y3p)==(x3p-dx3, y3p-dy3), which means that
+ // computeIntersection will put NaN's in leftOff and right off, and
+ // we will do getLineOffsets, which is right.
+ computeIntersection(x1p, y1p, x1p+dx1, y1p+dy1, x3p, y3p, x3p-dx3, y3p-dy3, leftOff, 2);
+ float cx = leftOff[2];
+ float cy = leftOff[3];
- // if p1 == p2 && p3 == p4: draw line from p1->p4, unless p1 == p4,
- // in which case ignore.
- final boolean p1eqp2 = within(x1,y1,x2,y2, 6 * Math.ulp(y2));
- final boolean p2eqp3 = within(x2,y2,x3,y3, 6 * Math.ulp(y3));
- if (p1eqp2 || p2eqp3) {
- getLineOffsets(x1, y1, x3, y3, leftOff, rightOff);
- return 4;
+ if (!(isFinite(cx) && isFinite(cy))) {
+ // maybe the right path is not degenerate.
+ x1p = rightOff[0];
+ y1p = rightOff[1];
+ x3p = rightOff[4];
+ y3p = rightOff[5];
+ computeIntersection(x1p, y1p, x1p+dx1, y1p+dy1, x3p, y3p, x3p-dx3, y3p-dy3, rightOff, 2);
+ cx = rightOff[2];
+ cy = rightOff[3];
+ if (!(isFinite(cx) && isFinite(cy))) {
+ // both are degenerate. This curve is a line.
+ getLineOffsets(x1, y1, x3, y3, leftOff, rightOff);
+ return 4;
+ }
+ // {left,right}Off[0,1,4,5] are already set to the correct values.
+ leftOff[2] = 2*x2 - cx;
+ leftOff[3] = 2*y2 - cy;
+ return 6;
}
- // if p2-p1 and p4-p3 are parallel, that must mean this curve is a line
- float dotsq = (dx1 * dx3 + dy1 * dy3);
- dotsq = dotsq * dotsq;
- float l1sq = dx1 * dx1 + dy1 * dy1, l3sq = dx3 * dx3 + dy3 * dy3;
- if (Helpers.within(dotsq, l1sq * l3sq, 4 * Math.ulp(dotsq))) {
- getLineOffsets(x1, y1, x3, y3, leftOff, rightOff);
- return 4;
- }
+ // rightOff[2,3] = (x2,y2) - ((left_x2, left_y2) - (x2, y2))
+ // == 2*(x2, y2) - (left_x2, left_y2)
+ rightOff[2] = 2*x2 - cx;
+ rightOff[3] = 2*y2 - cy;
+ return 6;
+ }
- // this computes the offsets at t=0, 0.5, 1, using the property that
- // for any bezier curve the vectors p2-p1 and p4-p3 are parallel to
- // the (dx/dt, dy/dt) vectors at the endpoints.
- computeOffset(dx1, dy1, lineWidth2, offset[0]);
- computeOffset(dx3, dy3, lineWidth2, offset[1]);
- float x1p = x1 + offset[0][0]; // start
- float y1p = y1 + offset[0][1]; // point
- float x3p = x3 + offset[1][0]; // end
- float y3p = y3 + offset[1][1]; // point
-
- computeMiter(x1p, y1p, x1p+dx1, y1p+dy1, x3p, y3p, x3p-dx3, y3p-dy3, leftOff, 2);
- leftOff[0] = x1p; leftOff[1] = y1p;
- leftOff[4] = x3p; leftOff[5] = y3p;
- x1p = x1 - offset[0][0]; y1p = y1 - offset[0][1];
- x3p = x3 - offset[1][0]; y3p = y3 - offset[1][1];
- computeMiter(x1p, y1p, x1p+dx1, y1p+dy1, x3p, y3p, x3p-dx3, y3p-dy3, rightOff, 2);
- rightOff[0] = x1p; rightOff[1] = y1p;
- rightOff[4] = x3p; rightOff[5] = y3p;
- return 6;
+ private static boolean isFinite(float x) {
+ return (Float.NEGATIVE_INFINITY < x && x < Float.POSITIVE_INFINITY);
}
// This is where the curve to be processed is put. We give it
@@ -812,12 +821,12 @@
// if these vectors are too small, normalize them, to avoid future
// precision problems.
if (Math.abs(dxs) < 0.1f && Math.abs(dys) < 0.1f) {
- float len = (float)Math.sqrt(dxs*dxs + dys*dys);
+ float len = (float) sqrt(dxs*dxs + dys*dys);
dxs /= len;
dys /= len;
}
if (Math.abs(dxf) < 0.1f && Math.abs(dyf) < 0.1f) {
- float len = (float)Math.sqrt(dxf*dxf + dyf*dyf);
+ float len = (float) sqrt(dxf*dxf + dyf*dyf);
dxf /= len;
dyf /= len;
}
@@ -834,7 +843,6 @@
while(it.hasNext()) {
int curCurveOff = it.next();
- kind = 0;
switch (type) {
case 8:
kind = computeOffsetCubic(middle, curCurveOff, lp, rp);
@@ -843,24 +851,22 @@
kind = computeOffsetQuad(middle, curCurveOff, lp, rp);
break;
}
- if (kind != 0) {
- emitLineTo(lp[0], lp[1]);
- switch(kind) {
- case 8:
- emitCurveTo(lp[0], lp[1], lp[2], lp[3], lp[4], lp[5], lp[6], lp[7], false);
- emitCurveTo(rp[0], rp[1], rp[2], rp[3], rp[4], rp[5], rp[6], rp[7], true);
- break;
- case 6:
- emitQuadTo(lp[0], lp[1], lp[2], lp[3], lp[4], lp[5], false);
- emitQuadTo(rp[0], rp[1], rp[2], rp[3], rp[4], rp[5], true);
- break;
- case 4:
- emitLineTo(lp[2], lp[3]);
- emitLineTo(rp[0], rp[1], true);
- break;
- }
- emitLineTo(rp[kind - 2], rp[kind - 1], true);
+ emitLineTo(lp[0], lp[1]);
+ switch(kind) {
+ case 8:
+ emitCurveTo(lp[0], lp[1], lp[2], lp[3], lp[4], lp[5], lp[6], lp[7], false);
+ emitCurveTo(rp[0], rp[1], rp[2], rp[3], rp[4], rp[5], rp[6], rp[7], true);
+ break;
+ case 6:
+ emitQuadTo(lp[0], lp[1], lp[2], lp[3], lp[4], lp[5], false);
+ emitQuadTo(rp[0], rp[1], rp[2], rp[3], rp[4], rp[5], true);
+ break;
+ case 4:
+ emitLineTo(lp[2], lp[3]);
+ emitLineTo(rp[0], rp[1], true);
+ break;
}
+ emitLineTo(rp[kind - 2], rp[kind - 1], true);
}
this.cmx = (lp[kind - 2] - rp[kind - 2]) / 2;
@@ -887,7 +893,7 @@
// we rotate it so that the first vector in the control polygon is
// parallel to the x-axis. This will ensure that rotated quarter
// circles won't be subdivided.
- final float hypot = (float)Math.sqrt(x12 * x12 + y12 * y12);
+ final float hypot = (float) sqrt(x12 * x12 + y12 * y12);
final float cos = x12 / hypot;
final float sin = y12 / hypot;
final float x1 = cos * pts[0] + sin * pts[1];
@@ -976,12 +982,12 @@
// if these vectors are too small, normalize them, to avoid future
// precision problems.
if (Math.abs(dxs) < 0.1f && Math.abs(dys) < 0.1f) {
- float len = (float)Math.sqrt(dxs*dxs + dys*dys);
+ float len = (float) sqrt(dxs*dxs + dys*dys);
dxs /= len;
dys /= len;
}
if (Math.abs(dxf) < 0.1f && Math.abs(dyf) < 0.1f) {
- float len = (float)Math.sqrt(dxf*dxf + dyf*dyf);
+ float len = (float) sqrt(dxf*dxf + dyf*dyf);
dxf /= len;
dyf /= len;
}
@@ -999,20 +1005,18 @@
int curCurveOff = it.next();
kind = computeOffsetCubic(middle, curCurveOff, lp, rp);
- if (kind != 0) {
- emitLineTo(lp[0], lp[1]);
- switch(kind) {
- case 8:
- emitCurveTo(lp[0], lp[1], lp[2], lp[3], lp[4], lp[5], lp[6], lp[7], false);
- emitCurveTo(rp[0], rp[1], rp[2], rp[3], rp[4], rp[5], rp[6], rp[7], true);
- break;
- case 4:
- emitLineTo(lp[2], lp[3]);
- emitLineTo(rp[0], rp[1], true);
- break;
- }
- emitLineTo(rp[kind - 2], rp[kind - 1], true);
+ emitLineTo(lp[0], lp[1]);
+ switch(kind) {
+ case 8:
+ emitCurveTo(lp[0], lp[1], lp[2], lp[3], lp[4], lp[5], lp[6], lp[7], false);
+ emitCurveTo(rp[0], rp[1], rp[2], rp[3], rp[4], rp[5], rp[6], rp[7], true);
+ break;
+ case 4:
+ emitLineTo(lp[2], lp[3]);
+ emitLineTo(rp[0], rp[1], true);
+ break;
}
+ emitLineTo(rp[kind - 2], rp[kind - 1], true);
}
this.cmx = (lp[kind - 2] - rp[kind - 2]) / 2;
@@ -1050,12 +1054,12 @@
// if these vectors are too small, normalize them, to avoid future
// precision problems.
if (Math.abs(dxs) < 0.1f && Math.abs(dys) < 0.1f) {
- float len = (float)Math.sqrt(dxs*dxs + dys*dys);
+ float len = (float) sqrt(dxs*dxs + dys*dys);
dxs /= len;
dys /= len;
}
if (Math.abs(dxf) < 0.1f && Math.abs(dyf) < 0.1f) {
- float len = (float)Math.sqrt(dxf*dxf + dyf*dyf);
+ float len = (float) sqrt(dxf*dxf + dyf*dyf);
dxf /= len;
dyf /= len;
}
@@ -1073,20 +1077,18 @@
int curCurveOff = it.next();
kind = computeOffsetQuad(middle, curCurveOff, lp, rp);
- if (kind != 0) {
- emitLineTo(lp[0], lp[1]);
- switch(kind) {
- case 6:
- emitQuadTo(lp[0], lp[1], lp[2], lp[3], lp[4], lp[5], false);
- emitQuadTo(rp[0], rp[1], rp[2], rp[3], rp[4], rp[5], true);
- break;
- case 4:
- emitLineTo(lp[2], lp[3]);
- emitLineTo(rp[0], rp[1], true);
- break;
- }
- emitLineTo(rp[kind - 2], rp[kind - 1], true);
+ emitLineTo(lp[0], lp[1]);
+ switch(kind) {
+ case 6:
+ emitQuadTo(lp[0], lp[1], lp[2], lp[3], lp[4], lp[5], false);
+ emitQuadTo(rp[0], rp[1], rp[2], rp[3], rp[4], rp[5], true);
+ break;
+ case 4:
+ emitLineTo(lp[2], lp[3]);
+ emitLineTo(rp[0], rp[1], true);
+ break;
}
+ emitLineTo(rp[kind - 2], rp[kind - 1], true);
}
this.cmx = (lp[kind - 2] - rp[kind - 2]) / 2;
--- a/jdk/src/share/classes/sun/security/pkcs/PKCS7.java Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/src/share/classes/sun/security/pkcs/PKCS7.java Tue May 03 22:14:39 2011 -0700
@@ -38,7 +38,6 @@
import sun.security.util.*;
import sun.security.x509.AlgorithmId;
import sun.security.x509.CertificateIssuerName;
-import sun.security.x509.KeyUsageExtension;
import sun.security.x509.X509CertImpl;
import sun.security.x509.X509CertInfo;
import sun.security.x509.X509CRLImpl;
@@ -493,7 +492,7 @@
// CRLs (optional)
if (crls != null && crls.length != 0) {
// cast to X509CRLImpl[] since X509CRLImpl implements DerEncoder
- Set<X509CRLImpl> implCRLs = new HashSet<>(crls.length);
+ Set<X509CRLImpl> implCRLs = new HashSet<X509CRLImpl>(crls.length);
for (X509CRL crl: crls) {
if (crl instanceof X509CRLImpl)
implCRLs.add((X509CRLImpl) crl);
@@ -531,168 +530,6 @@
}
/**
- * Verifying signed data using an external chunked data source.
- */
- public static class PKCS7Verifier {
-
- private final SignerInfo si; // Signer to verify
- private final MessageDigest md; // MessageDigest object for chunks
- private final Signature sig; // Signature object for chunks
-
- private PKCS7Verifier(SignerInfo si, MessageDigest md, Signature sig) {
- this.si = si;
- this.md = md;
- this.sig = sig;
- }
-
- public static PKCS7Verifier from(PKCS7 block, SignerInfo si) throws
- SignatureException, NoSuchAlgorithmException {
-
- try {
- MessageDigest md = null;
- Signature sig;
-
- ContentInfo content = block.getContentInfo();
- String digestAlgname = si.getDigestAlgorithmId().getName();
-
- // if there are authenticate attributes, feed data chunks to
- // the message digest. In this case, pv.md is not null
- if (si.authenticatedAttributes != null) {
- // first, check content type
- ObjectIdentifier contentType = (ObjectIdentifier)
- si.authenticatedAttributes.getAttributeValue(
- PKCS9Attribute.CONTENT_TYPE_OID);
- if (contentType == null ||
- !contentType.equals(content.contentType))
- return null; // contentType does not match, bad SignerInfo
-
- // now, check message digest
- byte[] messageDigest = (byte[])
- si.authenticatedAttributes.getAttributeValue(
- PKCS9Attribute.MESSAGE_DIGEST_OID);
-
- if (messageDigest == null) // fail if there is no message digest
- return null;
-
- md = MessageDigest.getInstance(digestAlgname);
- }
-
- // put together digest algorithm and encryption algorithm
- // to form signing algorithm
- String encryptionAlgname =
- si.getDigestEncryptionAlgorithmId().getName();
-
- // Workaround: sometimes the encryptionAlgname is actually
- // a signature name
- String tmp = AlgorithmId.getEncAlgFromSigAlg(encryptionAlgname);
- if (tmp != null) encryptionAlgname = tmp;
- String algname = AlgorithmId.makeSigAlg(
- digestAlgname, encryptionAlgname);
-
- sig = Signature.getInstance(algname);
- X509Certificate cert = si.getCertificate(block);
-
- if (cert == null) {
- return null;
- }
- if (cert.hasUnsupportedCriticalExtension()) {
- throw new SignatureException("Certificate has unsupported "
- + "critical extension(s)");
- }
-
- // Make sure that if the usage of the key in the certificate is
- // restricted, it can be used for digital signatures.
- // XXX We may want to check for additional extensions in the
- // future.
- boolean[] keyUsageBits = cert.getKeyUsage();
- if (keyUsageBits != null) {
- KeyUsageExtension keyUsage;
- try {
- // We don't care whether or not this extension was marked
- // critical in the certificate.
- // We're interested only in its value (i.e., the bits set)
- // and treat the extension as critical.
- keyUsage = new KeyUsageExtension(keyUsageBits);
- } catch (IOException ioe) {
- throw new SignatureException("Failed to parse keyUsage "
- + "extension");
- }
-
- boolean digSigAllowed = ((Boolean)keyUsage.get(
- KeyUsageExtension.DIGITAL_SIGNATURE)).booleanValue();
-
- boolean nonRepuAllowed = ((Boolean)keyUsage.get(
- KeyUsageExtension.NON_REPUDIATION)).booleanValue();
-
- if (!digSigAllowed && !nonRepuAllowed) {
- throw new SignatureException("Key usage restricted: "
- + "cannot be used for "
- + "digital signatures");
- }
- }
-
- PublicKey key = cert.getPublicKey();
- sig.initVerify(key);
- return new PKCS7Verifier(si, md, sig);
- } catch (IOException e) {
- throw new SignatureException("IO error verifying signature:\n" +
- e.getMessage());
-
- } catch (InvalidKeyException e) {
- throw new SignatureException("InvalidKey: " + e.getMessage());
-
- }
- }
-
- public void update(byte[] data, int off, int end)
- throws SignatureException {
- if (md != null) {
- md.update(data, off, end-off);
- } else {
- sig.update(data, off, end-off);
- }
- }
-
- public SignerInfo verify() throws SignatureException {
- try {
- // if there are authenticate attributes, get the message
- // digest and compare it with the digest of data
- if (md != null) {
- // now, check message digest
- byte[] messageDigest = (byte[])
- si.authenticatedAttributes.getAttributeValue(
- PKCS9Attribute.MESSAGE_DIGEST_OID);
-
- byte[] computedMessageDigest = md.digest();
-
- if (!MessageDigest.isEqual(
- messageDigest, computedMessageDigest)) {
- return null;
- }
-
- // message digest attribute matched
- // digest of original data
-
- // the data actually signed is the DER encoding of
- // the authenticated attributes (tagged with
- // the "SET OF" tag, not 0xA0).
- byte[] dataSigned = si.authenticatedAttributes.getDerEncoding();
- sig.update(dataSigned);
- }
-
- if (sig.verify(si.getEncryptedDigest())) {
- return si;
- }
-
- } catch (IOException e) {
- throw new SignatureException("IO error verifying signature:\n" +
- e.getMessage());
- }
- return null;
- }
- }
-
- /**
* This verifies a given SignerInfo.
*
* @param info the signer information.
@@ -717,16 +554,19 @@
public SignerInfo[] verify(byte[] bytes)
throws NoSuchAlgorithmException, SignatureException {
- List<SignerInfo> intResult = new ArrayList<>();
+ Vector<SignerInfo> intResult = new Vector<SignerInfo>();
for (int i = 0; i < signerInfos.length; i++) {
SignerInfo signerInfo = verify(signerInfos[i], bytes);
if (signerInfo != null) {
- intResult.add(signerInfo);
+ intResult.addElement(signerInfo);
}
}
- if (!intResult.isEmpty()) {
- return intResult.toArray(new SignerInfo[intResult.size()]);
+ if (intResult.size() != 0) {
+
+ SignerInfo[] result = new SignerInfo[intResult.size()];
+ intResult.copyInto(result);
+ return result;
}
return null;
}
--- a/jdk/src/share/classes/sun/security/pkcs/SignerInfo.java Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/src/share/classes/sun/security/pkcs/SignerInfo.java Tue May 03 22:14:39 2011 -0700
@@ -230,7 +230,7 @@
if (userCert == null)
return null;
- ArrayList<X509Certificate> certList = new ArrayList<>();
+ ArrayList<X509Certificate> certList = new ArrayList<X509Certificate>();
certList.add(userCert);
X509Certificate[] pkcsCerts = block.getCertificates();
@@ -276,20 +276,132 @@
/* Returns null if verify fails, this signerInfo if
verify succeeds. */
SignerInfo verify(PKCS7 block, byte[] data)
- throws NoSuchAlgorithmException, SignatureException {
+ throws NoSuchAlgorithmException, SignatureException {
+
+ try {
+
+ ContentInfo content = block.getContentInfo();
+ if (data == null) {
+ data = content.getContentBytes();
+ }
+
+ String digestAlgname = getDigestAlgorithmId().getName();
+
+ byte[] dataSigned;
+
+ // if there are authenticate attributes, get the message
+ // digest and compare it with the digest of data
+ if (authenticatedAttributes == null) {
+ dataSigned = data;
+ } else {
+
+ // first, check content type
+ ObjectIdentifier contentType = (ObjectIdentifier)
+ authenticatedAttributes.getAttributeValue(
+ PKCS9Attribute.CONTENT_TYPE_OID);
+ if (contentType == null ||
+ !contentType.equals(content.contentType))
+ return null; // contentType does not match, bad SignerInfo
+
+ // now, check message digest
+ byte[] messageDigest = (byte[])
+ authenticatedAttributes.getAttributeValue(
+ PKCS9Attribute.MESSAGE_DIGEST_OID);
+
+ if (messageDigest == null) // fail if there is no message digest
+ return null;
+
+ MessageDigest md = MessageDigest.getInstance(digestAlgname);
+ byte[] computedMessageDigest = md.digest(data);
+
+ if (messageDigest.length != computedMessageDigest.length)
+ return null;
+ for (int i = 0; i < messageDigest.length; i++) {
+ if (messageDigest[i] != computedMessageDigest[i])
+ return null;
+ }
+
+ // message digest attribute matched
+ // digest of original data
+
+ // the data actually signed is the DER encoding of
+ // the authenticated attributes (tagged with
+ // the "SET OF" tag, not 0xA0).
+ dataSigned = authenticatedAttributes.getDerEncoding();
+ }
+
+ // put together digest algorithm and encryption algorithm
+ // to form signing algorithm
+ String encryptionAlgname =
+ getDigestEncryptionAlgorithmId().getName();
- PKCS7.PKCS7Verifier p7v = PKCS7.PKCS7Verifier.from(block, this);
- if (p7v == null) return null;
- if (data == null) {
- try {
- data = block.getContentInfo().getContentBytes();
- } catch (IOException e) {
- throw new SignatureException("IO error verifying signature:\n" +
- e.getMessage());
+ // Workaround: sometimes the encryptionAlgname is actually
+ // a signature name
+ String tmp = AlgorithmId.getEncAlgFromSigAlg(encryptionAlgname);
+ if (tmp != null) encryptionAlgname = tmp;
+ String algname = AlgorithmId.makeSigAlg(
+ digestAlgname, encryptionAlgname);
+
+ Signature sig = Signature.getInstance(algname);
+ X509Certificate cert = getCertificate(block);
+
+ if (cert == null) {
+ return null;
+ }
+ if (cert.hasUnsupportedCriticalExtension()) {
+ throw new SignatureException("Certificate has unsupported "
+ + "critical extension(s)");
}
+
+ // Make sure that if the usage of the key in the certificate is
+ // restricted, it can be used for digital signatures.
+ // XXX We may want to check for additional extensions in the
+ // future.
+ boolean[] keyUsageBits = cert.getKeyUsage();
+ if (keyUsageBits != null) {
+ KeyUsageExtension keyUsage;
+ try {
+ // We don't care whether or not this extension was marked
+ // critical in the certificate.
+ // We're interested only in its value (i.e., the bits set)
+ // and treat the extension as critical.
+ keyUsage = new KeyUsageExtension(keyUsageBits);
+ } catch (IOException ioe) {
+ throw new SignatureException("Failed to parse keyUsage "
+ + "extension");
+ }
+
+ boolean digSigAllowed = ((Boolean)keyUsage.get(
+ KeyUsageExtension.DIGITAL_SIGNATURE)).booleanValue();
+
+ boolean nonRepuAllowed = ((Boolean)keyUsage.get(
+ KeyUsageExtension.NON_REPUDIATION)).booleanValue();
+
+ if (!digSigAllowed && !nonRepuAllowed) {
+ throw new SignatureException("Key usage restricted: "
+ + "cannot be used for "
+ + "digital signatures");
+ }
+ }
+
+ PublicKey key = cert.getPublicKey();
+ sig.initVerify(key);
+
+ sig.update(dataSigned);
+
+ if (sig.verify(encryptedDigest)) {
+ return this;
+ }
+
+ } catch (IOException e) {
+ throw new SignatureException("IO error verifying signature:\n" +
+ e.getMessage());
+
+ } catch (InvalidKeyException e) {
+ throw new SignatureException("InvalidKey: " + e.getMessage());
+
}
- p7v.update(data, 0, data.length);
- return p7v.verify();
+ return null;
}
/* Verify the content of the pkcs7 block. */
--- a/jdk/src/share/classes/sun/security/util/ManifestEntryVerifier.java Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/src/share/classes/sun/security/util/ManifestEntryVerifier.java Tue May 03 22:14:39 2011 -0700
@@ -191,8 +191,8 @@
*
*
*/
- public CodeSigner[] verify(Map<String, CodeSigner[]> verifiedSigners,
- Map<String, CodeSigner[]> sigFileSigners)
+ public CodeSigner[] verify(Hashtable<String, CodeSigner[]> verifiedSigners,
+ Hashtable<String, CodeSigner[]> sigFileSigners)
throws JarException
{
if (skip) {
--- a/jdk/src/share/classes/sun/security/util/SignatureFileManifest.java Fri Apr 29 16:03:09 2011 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,251 +0,0 @@
-/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.security.util;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Arrays;
-import java.util.jar.Attributes;
-import java.util.jar.Manifest;
-
-/**
- * This class provides streaming mode reading of manifest files.
- * Used by {@link SignatureFileVerifier}.
- */
-class SignatureFileManifest extends Manifest {
-
- /*
- * Reading a manifest into this object by calling update(byte[]) on chunks.
- * During the reading, the bytes are saved in (@code current} until a line
- * is complete and the key-value pair is saved in {@code currentAttr}. When
- * a section is complete, {@code consumeAttr} is called to merge
- * {@code currentAttr} into main attributes or a named entry.
- */
-
- // Internal state during update() style reading
- // 0. not in update mode
- // 1, in update mode but main attributes not completed yet
- // 2. main attributes completed, still reading the entries
- private int state = 0;
-
- // The partial line read
- private byte[] current;
-
- // Number of bytes in current
- private int currentPos = 0;
-
- // The current Attribute
- private Attributes currentAttr;
-
- /**
- * Reads a manifest in chunks.
- * <p>
- * This method must be called in a row, reading chunks from a single
- * manifest file by order. After all chunks are read, caller must call
- * {@code update(null)} to fully consume the manifest.
- * <p>
- * The entry names and attributes read will be merged in with the current
- * manifest entries. The {@link #read} method cannot be called inside a
- * row of update calls.
- * <p>
- * Along with the calls, caller can call {@link #getMainAttributes()},
- * {@link #getAttributes(java.lang.String)} or {@link #getEntries()}
- * to get already available contents. However, in order not to return
- * partial result, when the main attributes in the new manifest is not
- * consumed completely, {@link #getMainAttributes()} throws an
- * {@code IllegalStateException}. When a certain named entry is not
- * consumed completely, {@link #getAttributes(java.lang.String)}
- * returns the old {@code Attributes} for the name (if it exists).
- *
- * @param data null for last call, otherwise, feeding chunks
- * @param offset offset into data to begin read
- * @param length length of data after offset to read
- * @exception IOException if an I/O error has occurred
- * @exception IllegalStateException if {@code update(null)} is called
- * without any previous {@code update(non-null)} call
- */
- public void update(byte[] data, int offset, int length) throws IOException {
-
- // The last call
- if (data == null) {
- if (state == 0) {
- throw new IllegalStateException("No data to update");
- }
- // We accept manifest not ended with \n or \n\n
- if (hasLastByte()) {
- consumeCurrent();
- }
- // We accept empty lines at the end
- if (!currentAttr.isEmpty()) {
- consumeAttr();
- }
- state = 0; // back to non-update state
- current = null;
- currentAttr = null;
- return;
- }
-
- // The first call
- if (state == 0) {
- current = new byte[1024];
- currentAttr = super.getMainAttributes(); // the main attribute
- state = 1;
- }
-
- int end = offset + length;
-
- while (offset < end) {
- switch (data[offset]) {
- case '\r':
- break; // always skip
- case '\n':
- if (hasLastByte() && lastByte() == '\n') { // new section
- consumeCurrent();
- consumeAttr();
- if (state == 1) {
- state = 2;
- }
- currentAttr = new Attributes(2);
- } else {
- if (hasLastByte()) {
- // save \n into current but do not parse,
- // there might be a continuation later
- ensureCapacity();
- current[currentPos++] = data[offset];
- } else if (state == 1) {
- // there can be multiple empty lines between
- // sections, but cannot be at the beginning
- throw new IOException("invalid manifest format");
- }
- }
- break;
- case ' ':
- if (!hasLastByte()) {
- throw new IOException("invalid manifest format");
- } else if (lastByte() == '\n') {
- currentPos--; // continuation, remove last \n
- } else { // a very normal ' '
- ensureCapacity();
- current[currentPos++] = data[offset];
- }
- break;
- default:
- if (hasLastByte() && lastByte() == '\n') {
- // The start of a new pair, not continuation
- consumeCurrent(); // the last line read
- }
- ensureCapacity();
- current[currentPos++] = data[offset];
- break;
- }
- offset++;
- }
- }
-
- /**
- * Returns the main Attributes for the Manifest.
- * @exception IllegalStateException the main attributes is being read
- * @return the main Attributes for the Manifest
- */
- public Attributes getMainAttributes() {
- if (state == 1) {
- throw new IllegalStateException();
- }
- return super.getMainAttributes();
- }
-
- /**
- * Reads the Manifest from the specified InputStream. The entry
- * names and attributes read will be merged in with the current
- * manifest entries.
- *
- * @param is the input stream
- * @exception IOException if an I/O error has occurred
- * @exception IllegalStateException if called between two {@link #update}
- * calls
- */
- public void read(InputStream is) throws IOException {
- if (state != 0) {
- throw new IllegalStateException("Cannot call read between updates");
- }
- super.read(is);
- }
-
- /*
- * ---------- Helper methods -----------------
- */
-
- private void ensureCapacity() {
- if (currentPos >= current.length-1) {
- current = Arrays.copyOf(current, current.length*2);
- }
- }
-
- private boolean hasLastByte() {
- return currentPos > 0;
- }
-
- private byte lastByte() {
- return current[currentPos-1];
- }
-
- // Parse current as key:value and save into currentAttr.
- // There MUST be something inside current.
- private void consumeCurrent() throws IOException {
- // current normally has a \n end, except for the last line
- if (current[currentPos-1] == '\n') currentPos--;
- for (int i=0; i<currentPos; i++) {
- if (current[i] == ':') {
- String key = new String(current, 0, 0, i);
- i++;
- while (i < currentPos && current[i] == ' ') { i++; }
- String value = new String(current, i, currentPos-i, "UTF-8");
- currentAttr.putValue(key, value);
- currentPos = 0;
- return;
- }
- }
- throw new IOException("invalid header field");
- }
-
- // Merge currentAttr into Manifest
- private void consumeAttr() throws IOException {
- // Only needed for named entries. For the main attribute, key/value
- // is added into attr directly, but since getMainAttributes() throws
- // an exception, the partial data is not leaked.
- if (state != 1) {
- String name = currentAttr.getValue("Name");
- if (name != null) {
- currentAttr.remove(new Attributes.Name("Name"));
- Attributes old = getAttributes(name);
- if (old != null) old.putAll(currentAttr);
- else getEntries().put(name, currentAttr);
- } else {
- throw new IOException("invalid manifest format");
- }
- }
- }
-}
--- a/jdk/src/share/classes/sun/security/util/SignatureFileVerifier.java Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/src/share/classes/sun/security/util/SignatureFileVerifier.java Tue May 03 22:14:39 2011 -0700
@@ -55,8 +55,8 @@
/** the PKCS7 block for this .DSA/.RSA/.EC file */
private PKCS7 block;
- // the content of the raw .SF file as an InputStream
- private InputStream sfStream;
+ /** the raw bytes of the .SF file */
+ private byte sfBytes[];
/** the name of the signature block file, uppercased and without
* the extension (.DSA/.RSA/.EC)
@@ -66,9 +66,6 @@
/** the ManifestDigester */
private ManifestDigester md;
- /** The MANIFEST.MF */
- private Manifest man;
-
/** cache of created MessageDigest objects */
private HashMap<String, MessageDigest> createdDigests;
@@ -86,7 +83,6 @@
* @param rawBytes the raw bytes of the signature block file
*/
public SignatureFileVerifier(ArrayList<CodeSigner[]> signerCache,
- Manifest man,
ManifestDigester md,
String name,
byte rawBytes[])
@@ -98,18 +94,13 @@
try {
obj = Providers.startJarVerification();
block = new PKCS7(rawBytes);
- byte[] contentData = block.getContentInfo().getData();
- if (contentData != null) {
- sfStream = new ByteArrayInputStream(contentData);
- }
+ sfBytes = block.getContentInfo().getData();
certificateFactory = CertificateFactory.getInstance("X509");
} finally {
Providers.stopJarVerification(obj);
}
this.name = name.substring(0, name.lastIndexOf("."))
.toUpperCase(Locale.ENGLISH);
-
- this.man = man;
this.md = md;
this.signerCache = signerCache;
}
@@ -117,13 +108,31 @@
/**
* returns true if we need the .SF file
*/
- public boolean needSignatureFile()
+ public boolean needSignatureFileBytes()
{
- return sfStream == null;
+
+ return sfBytes == null;
}
- public void setSignatureFile(InputStream ins) {
- this.sfStream = ins;
+
+ /**
+ * returns true if we need this .SF file.
+ *
+ * @param name the name of the .SF file without the extension
+ *
+ */
+ public boolean needSignatureFile(String name)
+ {
+ return this.name.equalsIgnoreCase(name);
+ }
+
+ /**
+ * used to set the raw bytes of the .SF file when it
+ * is external to the signature block file.
+ */
+ public void setSignatureFile(byte sfBytes[])
+ {
+ this.sfBytes = sfBytes;
}
/**
@@ -136,18 +145,12 @@
* Signature File or PKCS7 block file name
*/
public static boolean isBlockOrSF(String s) {
- return s.endsWith(".SF") || isBlock(s);
- }
-
- /**
- * Utility method used by JarVerifier to determine PKCS7 block
- * files names that are supported
- *
- * @param s file name
- * @return true if the input file name is a PKCS7 block file name
- */
- public static boolean isBlock(String s) {
- return s.endsWith(".DSA") || s.endsWith(".RSA") || s.endsWith(".EC");
+ // we currently only support DSA and RSA PKCS7 blocks
+ if (s.endsWith(".SF") || s.endsWith(".DSA") ||
+ s.endsWith(".RSA") || s.endsWith(".EC")) {
+ return true;
+ }
+ return false;
}
/** get digest from cache */
@@ -177,7 +180,7 @@
*
*
*/
- public void process(Map<String, CodeSigner[]> signers,
+ public void process(Hashtable<String, CodeSigner[]> signers,
List manifestDigests)
throws IOException, SignatureException, NoSuchAlgorithmException,
JarException, CertificateException
@@ -194,86 +197,31 @@
}
- private void processImpl(Map<String, CodeSigner[]> signers,
+ private void processImpl(Hashtable<String, CodeSigner[]> signers,
List manifestDigests)
throws IOException, SignatureException, NoSuchAlgorithmException,
JarException, CertificateException
{
- SignatureFileManifest sf = new SignatureFileManifest();
- InputStream ins = sfStream;
+ Manifest sf = new Manifest();
+ sf.read(new ByteArrayInputStream(sfBytes));
- byte[] buffer = new byte[4096];
- int sLen = block.getSignerInfos().length;
- boolean mainOK = false; // main attributes of SF is available...
- boolean manifestSigned = false; // and it matches MANIFEST.MF
- BASE64Decoder decoder = new BASE64Decoder();
+ String version =
+ sf.getMainAttributes().getValue(Attributes.Name.SIGNATURE_VERSION);
- PKCS7.PKCS7Verifier[] pvs = new PKCS7.PKCS7Verifier[sLen];
- for (int i=0; i<sLen; i++) {
- pvs[i] = PKCS7.PKCS7Verifier.from(block, block.getSignerInfos()[i]);
+ if ((version == null) || !(version.equalsIgnoreCase("1.0"))) {
+ // XXX: should this be an exception?
+ // for now we just ignore this signature file
+ return;
}
- /*
- * Verify SF in streaming mode. The chunks of the file are fed into
- * the Manifest object sf and all PKCS7Verifiers. As soon as the main
- * attributes is available, we'll check if manifestSigned is true. If
- * yes, there is no need to fill in sf's entries field, since it should
- * be identical to entries in man.
- */
- while (true) {
- int len = ins.read(buffer);
- if (len < 0) {
- if (!manifestSigned) {
- sf.update(null, 0, 0);
- }
- break;
- } else {
- for (int i=0; i<sLen; i++) {
- if (pvs[i] != null) pvs[i].update(buffer, 0, len);
- }
- // Continue reading if verifyManifestHash fails (or, the
- // main attributes is not available yet)
- if (!manifestSigned) {
- sf.update(buffer, 0, len);
- if (!mainOK) {
- try {
- Attributes attr = sf.getMainAttributes();
- String version = attr.getValue(
- Attributes.Name.SIGNATURE_VERSION);
+ SignerInfo[] infos = block.verify(sfBytes);
- if ((version == null) ||
- !(version.equalsIgnoreCase("1.0"))) {
- // XXX: should this be an exception?
- // for now we just ignore this signature file
- return;
- }
-
- mainOK = true;
- manifestSigned = verifyManifestHash(
- sf, md, decoder, manifestDigests);
- } catch (IllegalStateException ise) {
- // main attributes not available yet
- }
- }
- }
- }
- }
- List<SignerInfo> intResult = new ArrayList<>(sLen);
- for (int i = 0; i < sLen; i++) {
- if (pvs[i] != null) {
- SignerInfo signerInfo = pvs[i].verify();
- if (signerInfo != null) {
- intResult.add(signerInfo);
- }
- }
- }
- if (intResult.isEmpty()) {
+ if (infos == null) {
throw new SecurityException("cannot verify signature block file " +
name);
}
- SignerInfo[] infos =
- intResult.toArray(new SignerInfo[intResult.size()]);
+ BASE64Decoder decoder = new BASE64Decoder();
CodeSigner[] newSigners = getSigners(infos, block);
@@ -281,37 +229,26 @@
if (newSigners == null)
return;
+ Iterator<Map.Entry<String,Attributes>> entries =
+ sf.getEntries().entrySet().iterator();
+
+ // see if we can verify the whole manifest first
+ boolean manifestSigned = verifyManifestHash(sf, md, decoder, manifestDigests);
+
// verify manifest main attributes
if (!manifestSigned && !verifyManifestMainAttrs(sf, md, decoder)) {
throw new SecurityException
("Invalid signature file digest for Manifest main attributes");
}
- Iterator<Map.Entry<String,Attributes>> entries;
-
- if (manifestSigned) {
- if (debug != null) {
- debug.println("full manifest signature match, "
- + "update signer info from MANIFEST.MF");
- }
- entries = man.getEntries().entrySet().iterator();
- } else {
- if (debug != null) {
- debug.println("full manifest signature unmatch, "
- + "update signer info from SF file");
- }
- entries = sf.getEntries().entrySet().iterator();
- }
-
- // go through each section
-
+ // go through each section in the signature file
while(entries.hasNext()) {
Map.Entry<String,Attributes> e = entries.next();
String name = e.getKey();
if (manifestSigned ||
- (verifySection(e.getValue(), name, md, decoder))) {
+ (verifySection(e.getValue(), name, md, decoder))) {
if (name.startsWith("./"))
name = name.substring(2);
@@ -656,6 +593,7 @@
if (set == subset)
return true;
+ boolean match;
for (int i = 0; i < subset.length; i++) {
if (!contains(set, subset[i]))
return false;
@@ -675,6 +613,8 @@
if ((oldSigners == null) && (signers == newSigners))
return true;
+ boolean match;
+
// make sure all oldSigners are in signers
if ((oldSigners != null) && !isSubSet(oldSigners, signers))
return false;
@@ -698,7 +638,7 @@
}
void updateSigners(CodeSigner[] newSigners,
- Map<String, CodeSigner[]> signers, String name) {
+ Hashtable<String, CodeSigner[]> signers, String name) {
CodeSigner[] oldSigners = signers.get(name);
--- a/jdk/src/share/native/sun/awt/giflib/dgif_lib.c Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/src/share/native/sun/awt/giflib/dgif_lib.c Tue May 03 22:14:39 2011 -0700
@@ -70,7 +70,7 @@
/* avoid extra function call in case we use fread (TVT) */
#define READ(_gif,_buf,_len) \
(((GifFilePrivateType*)_gif->Private)->Read ? \
- ((GifFilePrivateType*)_gif->Private)->Read(_gif,_buf,_len) : \
+ (size_t)((GifFilePrivateType*)_gif->Private)->Read(_gif,_buf,_len) : \
fread(_buf,1,_len,((GifFilePrivateType*)_gif->Private)->File))
static int DGifGetWord(GifFileType *GifFile, int *Word);
--- a/jdk/src/share/native/sun/font/fontscalerdefs.h Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/src/share/native/sun/font/fontscalerdefs.h Tue May 03 22:14:39 2011 -0700
@@ -55,13 +55,15 @@
typedef Int32 hsFract;
typedef UInt32 Bool32;
+#ifndef __cplusplus
#ifndef false
- #define false 0
+ #define false 0
#endif
#ifndef true
#define true 1
#endif
+#endif
#define kPosInfinity32 (0x7fffffff)
#define kNegInfinity32 (0x80000000)
--- a/jdk/src/share/native/sun/font/layout/HangulLayoutEngine.cpp Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/src/share/native/sun/font/layout/HangulLayoutEngine.cpp Tue May 03 22:14:39 2011 -0700
@@ -162,7 +162,7 @@
return 0;
}
- lead = LJMO_FIRST + (sIndex / HSYL_LVCNT);
+ lead = (LEUnicode)(LJMO_FIRST + (sIndex / HSYL_LVCNT));
vowel = VJMO_FIRST + (sIndex % HSYL_LVCNT) / TJMO_COUNT;
trail = TJMO_FIRST + (sIndex % TJMO_COUNT);
--- a/jdk/src/share/native/sun/font/layout/MPreFixups.cpp Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/src/share/native/sun/font/layout/MPreFixups.cpp Tue May 03 22:14:39 2011 -0700
@@ -65,9 +65,9 @@
}
}
-void MPreFixups::apply(LEGlyphStorage &glyphStorage, LEErrorCode& success)
+void MPreFixups::apply(LEGlyphStorage &glyphStorage, LEErrorCode& leSuccess)
{
- if (LE_FAILURE(success)) {
+ if (LE_FAILURE(leSuccess)) {
return;
}
--- a/jdk/src/solaris/classes/sun/awt/X11/XListPeer.java Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XListPeer.java Tue May 03 22:14:39 2011 -0700
@@ -1479,16 +1479,19 @@
int h = height - (SCROLLBAR_AREA + (2 * MARGIN));
hsb.setValue(hsb.getValue() + x);
+ int options = PAINT_ITEMS | PAINT_HSCROLL;
+
Rectangle source = null;
Point distance = null;
if (x < 0) {
source = new Rectangle(MARGIN + SPACE, MARGIN, w + x, h);
distance = new Point(-x, 0);
+ options |= COPY_AREA;
} else if (x > 0) {
source = new Rectangle(MARGIN + SPACE + x, MARGIN, w - x, h);
distance = new Point(-x, 0);
+ options |= COPY_AREA;
}
- int options = COPY_AREA | PAINT_ITEMS | PAINT_HSCROLL;
repaint(vsb.getValue(), lastItemDisplayed(), options, source, distance);
}
--- a/jdk/src/solaris/classes/sun/font/FcFontConfiguration.java Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/src/solaris/classes/sun/font/FcFontConfiguration.java Tue May 03 22:14:39 2011 -0700
@@ -256,9 +256,9 @@
}
if (installedFallbackFontFiles != null) {
- System.arraycopy(fileNames, index,
- installedFallbackFontFiles,
- 0, installedFallbackFontFiles.length);
+ System.arraycopy(installedFallbackFontFiles, 0,
+ fileNames, fcFonts.length,
+ installedFallbackFontFiles.length);
}
result[fontIndex * NUM_STYLES + styleIndex]
--- a/jdk/src/solaris/native/sun/awt/fontpath.c Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/src/solaris/native/sun/awt/fontpath.c Tue May 03 22:14:39 2011 -0700
@@ -1107,7 +1107,8 @@
arrlen = (*env)->GetArrayLength(env, fcCompFontArray);
for (i=0; i<arrlen; i++) {
FcFontSet* fontset;
- int fn, j, fontCount, nfonts, minGlyphs;
+ int fn, j, fontCount, nfonts;
+ unsigned int minGlyphs;
FcChar8 **family, **styleStr, **fullname, **file;
jarray fcFontArr;
--- a/jdk/src/windows/classes/sun/awt/windows/WDataTransferer.java Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/src/windows/classes/sun/awt/windows/WDataTransferer.java Tue May 03 22:14:39 2011 -0700
@@ -830,7 +830,14 @@
if( -1 == iStartOffset ){
throw new IOException(FAILURE_MSG + "invalid HTML format.");
}
- iReadCount = bufferedStream.skip(iStartOffset);
+
+ int curOffset = 0;
+ while (curOffset < iStartOffset){
+ curOffset += bufferedStream.skip(iStartOffset - curOffset);
+ }
+
+ iReadCount = curOffset;
+
if( iStartOffset != iReadCount ){
throw new IOException(FAILURE_MSG + "Byte stream ends in description.");
}
--- a/jdk/src/windows/native/sun/font/fontpath.c Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/src/windows/native/sun/font/fontpath.c Tue May 03 22:14:39 2011 -0700
@@ -235,7 +235,7 @@
}
fullname = (*env)->NewString(env, lpelfe->elfFullName,
- wcslen((LPWSTR)lpelfe->elfFullName));
+ (jsize)wcslen((LPWSTR)lpelfe->elfFullName));
fullnameLC = (*env)->CallObjectMethod(env, fullname,
fmi->toLowerCaseMID, fmi->locale);
(*env)->CallBooleanMethod(env, fmi->list, fmi->addMID, fullname);
@@ -314,7 +314,7 @@
GdiFontMapInfo *fmi = (GdiFontMapInfo*)lParam;
JNIEnv *env = fmi->env;
jstring familyLC;
- int slen;
+ size_t slen;
LOGFONTW lfw;
/* Both Vista and XP return DEVICE_FONTTYPE for OTF fonts */
@@ -336,7 +336,7 @@
return 1;
}
slen = wcslen(lpelfe->elfLogFont.lfFaceName);
- fmi->family = (*env)->NewString(env,lpelfe->elfLogFont.lfFaceName, slen);
+ fmi->family = (*env)->NewString(env,lpelfe->elfLogFont.lfFaceName, (jsize)slen);
familyLC = (*env)->CallObjectMethod(env, fmi->family,
fmi->toLowerCaseMID, fmi->locale);
/* check if already seen this family with a different charset */
@@ -386,10 +386,10 @@
static BOOL RegistryToBaseTTNameA(LPSTR name) {
static const char TTSUFFIX[] = " (TrueType)";
static const char OTSUFFIX[] = " (OpenType)";
- int TTSLEN = strlen(TTSUFFIX);
+ size_t TTSLEN = strlen(TTSUFFIX);
char *suffix;
- int len = strlen(name);
+ size_t len = strlen(name);
if (len == 0) {
return FALSE;
}
@@ -412,10 +412,10 @@
static BOOL RegistryToBaseTTNameW(LPWSTR name) {
static const wchar_t TTSUFFIX[] = L" (TrueType)";
static const wchar_t OTSUFFIX[] = L" (OpenType)";
- int TTSLEN = wcslen(TTSUFFIX);
+ size_t TTSLEN = wcslen(TTSUFFIX);
wchar_t *suffix;
- int len = wcslen(name);
+ size_t len = wcslen(name);
if (len == 0) {
return FALSE;
}
@@ -439,7 +439,7 @@
LPSTR ptr1, ptr2;
jstring fontStr;
JNIEnv *env = fmi->env;
- int dslen = strlen(data);
+ size_t dslen = strlen(data);
jstring fileStr = JNU_NewStringPlatform(env, data);
/* TTC or ttc means it may be a collection. Need to parse out
@@ -488,8 +488,8 @@
wchar_t *ptr1, *ptr2;
jstring fontStr;
JNIEnv *env = fmi->env;
- int dslen = wcslen(data);
- jstring fileStr = (*env)->NewString(env, data, dslen);
+ size_t dslen = wcslen(data);
+ jstring fileStr = (*env)->NewString(env, data, (jsize)dslen);
/* TTC or ttc means it may be a collection. Need to parse out
* multiple font face names separated by " & "
@@ -510,7 +510,7 @@
while ((ptr2 = wcsstr(ptr1, L" & ")) != NULL) {
ptr1 = ptr2+3;
}
- fontStr = (*env)->NewString(env, ptr1, wcslen(ptr1));
+ fontStr = (*env)->NewString(env, ptr1, (jsize)wcslen(ptr1));
fontStr = (*env)->CallObjectMethod(env, fontStr,
fmi->toLowerCaseMID,
fmi->locale);
@@ -524,7 +524,7 @@
}
}
} else {
- fontStr = (*env)->NewString(env, name, wcslen(name));
+ fontStr = (*env)->NewString(env, name, (jsize)wcslen(name));
fontStr = (*env)->CallObjectMethod(env, fontStr,
fmi->toLowerCaseMID, fmi->locale);
(*env)->CallObjectMethod(env, fontToFileMap, fmi->putMID,
--- a/jdk/src/windows/native/sun/windows/ObjectList.cpp Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/src/windows/native/sun/windows/ObjectList.cpp Tue May 03 22:14:39 2011 -0700
@@ -48,7 +48,7 @@
m_head = item;
}
-void AwtObjectList::Remove(AwtObject* obj)
+BOOL AwtObjectList::Remove(AwtObject* obj)
{
CriticalSection::Lock l(m_lock);
@@ -64,11 +64,14 @@
}
DASSERT(item != NULL);
delete item;
- return;
+ return TRUE;
}
lastItem = item;
item = item->next;
}
+
+ return FALSE;
+
// DASSERT(FALSE); // should never get here...
// even if it does it shouldn't be fatal.
}
--- a/jdk/src/windows/native/sun/windows/ObjectList.h Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/src/windows/native/sun/windows/ObjectList.h Tue May 03 22:14:39 2011 -0700
@@ -46,7 +46,7 @@
AwtObjectList();
void Add(AwtObject* obj);
- void Remove(AwtObject* obj);
+ BOOL Remove(AwtObject* obj);
#ifdef DEBUG
/* Used for sanity checks only. */
AwtObject* LookUp(AwtObject* obj);
--- a/jdk/src/windows/native/sun/windows/awt_Clipboard.cpp Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_Clipboard.cpp Tue May 03 22:14:39 2011 -0700
@@ -294,7 +294,7 @@
if (format == CF_HDROP) {
DROPFILES *dropfiles = (DROPFILES *)dataout;
dropfiles->pFiles = sizeof(DROPFILES);
- dropfiles->fWide = FALSE; // good guess!
+ dropfiles->fWide = TRUE; // we publish only Unicode
dataout += sizeof(DROPFILES);
}
--- a/jdk/src/windows/native/sun/windows/awt_Component.cpp Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_Component.cpp Tue May 03 22:14:39 2011 -0700
@@ -549,8 +549,6 @@
m_hwnd = hwnd;
- ImmAssociateContext(NULL);
-
SetDrawState((jint)JAWT_LOCK_SURFACE_CHANGED |
(jint)JAWT_LOCK_BOUNDS_CHANGED |
(jint)JAWT_LOCK_CLIP_CHANGED);
@@ -1203,7 +1201,7 @@
WIN_MSG(WM_IME_COMPOSITIONFULL)
WIN_MSG(WM_IME_SELECT)
WIN_MSG(WM_IME_CHAR)
- FMT_MSG(0x0288, "WM_IME_REQUEST")
+ FMT_MSG(WM_IME_REQUEST)
WIN_MSG(WM_IME_KEYDOWN)
WIN_MSG(WM_IME_KEYUP)
FMT_MSG(0x02A1, "WM_MOUSEHOVER")
@@ -1733,7 +1731,7 @@
case WM_IME_SELECT:
case WM_IME_KEYUP:
case WM_IME_KEYDOWN:
- case 0x0288: // WM_IME_REQUEST
+ case WM_IME_REQUEST:
CallProxyDefWindowProc(message, wParam, lParam, retValue, mr);
break;
case WM_CHAR:
@@ -1969,7 +1967,9 @@
{
// fix for 6259348: we should enter the SyncCall critical section before
// disposing the native object, that is value 1 of lParam is intended for
- AwtToolkit::GetInstance().SendMessage(WM_AWT_DISPOSE, (WPARAM)this, (LPARAM)1);
+ if(m_peerObject != NULL) { // is not being terminating
+ AwtToolkit::GetInstance().SendMessage(WM_AWT_DISPOSE, (WPARAM)m_peerObject, (LPARAM)1);
+ }
return mrConsume;
}
@@ -2020,25 +2020,6 @@
MsgRouting AwtComponent::WmShowWindow(BOOL show, UINT status)
{
- // NULL-InputContext is associated to all window just after they created.
- // ( see CreateHWnd() )
- // But to TextField and TextArea on Win95, valid InputContext is associated
- // by system after that. This is not happen on NT4.0
- // For workaround, force context to NULL here.
-
- // Fix for 4730228
- // Check if we already have Java-associated input method
- HIMC context = 0;
- if (m_InputMethod != NULL) {
- // If so get the appropriate context from it and use it instead of empty context
- JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
- context = (HIMC)(UINT_PTR)(JNU_GetFieldByName(env, NULL, m_InputMethod, "context", "I").i);
- }
-
- if (ImmGetContext() != 0 && ImmGetContext() != context) {
- ImmAssociateContext(context);
- }
-
return mrDoDefault;
}
@@ -4655,10 +4636,6 @@
ret:
if (c && ::IsWindow(c->GetHWnd())) {
sm_focusOwner = c->GetHWnd();
- AwtFrame *owner = (AwtFrame*)GetComponent(c->GetProxyToplevelContainer());
- if (owner) {
- owner->SetLastProxiedFocusOwner(sm_focusOwner);
- }
} else {
sm_focusOwner = NULL;
}
@@ -6534,8 +6511,7 @@
{
TRY_NO_HANG;
- PDATA pData = JNI_GET_PDATA(self);
- AwtObject::_Dispose(pData);
+ AwtObject::_Dispose(self);
CATCH_BAD_ALLOC;
}
--- a/jdk/src/windows/native/sun/windows/awt_DnDDS.cpp Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_DnDDS.cpp Tue May 03 22:14:39 2011 -0700
@@ -843,7 +843,7 @@
dropfiles->pt.x = m_dropPoint.x;
dropfiles->pt.y = m_dropPoint.y;
dropfiles->fNC = m_fNC;
- dropfiles->fWide = TRUE; // good guess!
+ dropfiles->fWide = TRUE; // we publish only Unicode
dataout += sizeof(DROPFILES);
}
--- a/jdk/src/windows/native/sun/windows/awt_Frame.cpp Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_Frame.cpp Tue May 03 22:14:39 2011 -0700
@@ -109,7 +109,7 @@
m_isMenuDropped = FALSE;
m_isInputMethodWindow = FALSE;
m_isUndecorated = FALSE;
- m_lastProxiedFocusOwner = NULL;
+ m_imeTargetComponent = NULL;
m_actualFocusedWindow = NULL;
m_iconic = FALSE;
m_zoomed = FALSE;
@@ -311,6 +311,8 @@
LRESULT retValue = 0L;
AwtComponent *focusOwner = NULL;
+ AwtComponent *imeTargetComponent = NULL;
+
// IME and input language related messages need to be sent to a window
// which has the Java input focus
switch (message) {
@@ -323,15 +325,29 @@
case WM_IME_COMPOSITIONFULL:
case WM_IME_SELECT:
case WM_IME_CHAR:
- case 0x0288: // WM_IME_REQUEST
+ case WM_IME_REQUEST:
case WM_IME_KEYDOWN:
case WM_IME_KEYUP:
case WM_INPUTLANGCHANGEREQUEST:
case WM_INPUTLANGCHANGE:
+ if (message == WM_IME_STARTCOMPOSITION) {
+ SetImeTargetComponent(sm_focusOwner);
+ }
+ imeTargetComponent = AwtComponent::GetComponent(GetImeTargetComponent());
+ if (imeTargetComponent != NULL &&
+ imeTargetComponent != this) // avoid recursive calls
+ {
+ retValue = imeTargetComponent->WindowProc(message, wParam, lParam);
+ mr = mrConsume;
+ }
+ if (message == WM_IME_ENDCOMPOSITION) {
+ SetImeTargetComponent(NULL);
+ }
+ break;
// TODO: when a Choice's list is dropped down and we're scrolling in
// the list WM_MOUSEWHEEL messages come to the poxy, not to the list. Why?
case WM_MOUSEWHEEL:
- focusOwner = AwtComponent::GetComponent(GetLastProxiedFocusOwner());
+ focusOwner = AwtComponent::GetComponent(sm_focusOwner);
if (focusOwner != NULL &&
focusOwner != this) // avoid recursive calls
{
@@ -340,12 +356,16 @@
}
break;
case WM_SETFOCUS:
+ if (sm_inSynthesizeFocus) break; // pass it up the WindowProc chain
+
if (!sm_suppressFocusAndActivation && IsEmbeddedFrame()) {
AwtSetActiveWindow();
}
mr = mrConsume;
break;
case WM_KILLFOCUS:
+ if (sm_inSynthesizeFocus) break; // pass it up the WindowProc chain
+
if (!sm_suppressFocusAndActivation && IsEmbeddedFrame()) {
AwtWindow::SynthesizeWmActivate(FALSE, GetHWnd(), NULL);
--- a/jdk/src/windows/native/sun/windows/awt_Frame.h Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_Frame.h Tue May 03 22:14:39 2011 -0700
@@ -150,8 +150,8 @@
void CheckRetainActualFocusedWindow(HWND activatedOpositeHWnd);
BOOL CheckActivateActualFocusedWindow(HWND deactivatedOpositeHWnd);
- INLINE HWND GetLastProxiedFocusOwner() { return m_lastProxiedFocusOwner; }
- INLINE void SetLastProxiedFocusOwner(HWND hwnd) { m_lastProxiedFocusOwner = hwnd; }
+ INLINE HWND GetImeTargetComponent() { return m_imeTargetComponent; }
+ INLINE void SetImeTargetComponent(HWND hwnd) { m_imeTargetComponent = hwnd; }
protected:
/* The frame is undecorated. */
@@ -179,9 +179,8 @@
/* The frame is an InputMethodWindow */
BOOL m_isInputMethodWindow;
- /* Retains the last/current sm_focusOwner proxied. Actually, it should be
- * a component of an owned window last/currently active. */
- HWND m_lastProxiedFocusOwner;
+ // retains the target component for the IME messages
+ HWND m_imeTargetComponent;
/*
* Fix for 4823903.
--- a/jdk/src/windows/native/sun/windows/awt_MenuItem.cpp Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_MenuItem.cpp Tue May 03 22:14:39 2011 -0700
@@ -974,8 +974,7 @@
{
TRY_NO_HANG;
- PDATA pData = JNI_GET_PDATA(self);
- AwtObject::_Dispose(pData);
+ AwtObject::_Dispose(self);
CATCH_BAD_ALLOC;
}
--- a/jdk/src/windows/native/sun/windows/awt_Object.cpp Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_Object.cpp Tue May 03 22:14:39 2011 -0700
@@ -60,11 +60,20 @@
void AwtObject::Dispose()
{
- theAwtObjectList.Remove(this);
+ AwtToolkit::GetInstance().PostMessage(WM_AWT_DELETEOBJECT, (WPARAM)this, (LPARAM)0);
+}
+
+void AwtObject::_Dispose(jobject self)
+{
+ TRY_NO_VERIFY;
+
+ CriticalSection::Lock l(AwtToolkit::GetInstance().GetSyncCS());
// value 0 of lParam means that we should not attempt to enter the
// SyncCall critical section, as it was entered someshere earlier
- AwtToolkit::GetInstance().PostMessage(WM_AWT_DELETEOBJECT, (WPARAM)this, (LPARAM)0);
+ AwtToolkit::GetInstance().SendMessage(WM_AWT_DISPOSE, (WPARAM)self, (LPARAM)0);
+
+ CATCH_BAD_ALLOC;
}
void AwtObject::_Dispose(PDATA pData)
@@ -73,14 +82,10 @@
CriticalSection::Lock l(AwtToolkit::GetInstance().GetSyncCS());
- if (pData != NULL) {
- AwtObject *o = (AwtObject *)pData;
- AwtToolkit::GetInstance().SendMessage(WM_AWT_DISPOSE, (WPARAM)o, (LPARAM)0);
- }
+ AwtToolkit::GetInstance().SendMessage(WM_AWT_DISPOSEPDATA, (WPARAM)pData, (LPARAM)0);
CATCH_BAD_ALLOC;
}
-
/*
* Return the peer associated with some target. This information is
* maintained in a hashtable at the java level.
--- a/jdk/src/windows/native/sun/windows/awt_Object.h Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_Object.h Tue May 03 22:14:39 2011 -0700
@@ -67,6 +67,10 @@
virtual void Dispose();
// Static method to be called from JNI methods to dispose AwtObject
+ // specified by jobject
+ static void _Dispose(jobject self);
+
+ // Static method to be called from JNI methods to dispose AwtObject
// specified by pData
static void _Dispose(PDATA pData);
--- a/jdk/src/windows/native/sun/windows/awt_Robot.cpp Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_Robot.cpp Tue May 03 22:14:39 2011 -0700
@@ -353,8 +353,7 @@
{
TRY_NO_VERIFY;
- PDATA pData = JNI_GET_PDATA(self);
- AwtObject::_Dispose(pData);
+ AwtObject::_Dispose(self);
CATCH_BAD_ALLOC;
}
--- a/jdk/src/windows/native/sun/windows/awt_TextComponent.cpp Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_TextComponent.cpp Tue May 03 22:14:39 2011 -0700
@@ -191,8 +191,11 @@
{
HIMC hIMC = ImmGetContext();
// rc is not used for text component.
- COMPOSITIONFORM cf = { CFS_POINT, {0,0}, {0,0,0,0} };
+ COMPOSITIONFORM cf = { CFS_FORCE_POSITION, {0,0}, {0,0,0,0} };
GetCaretPos(&(cf.ptCurrentPos));
+ // the proxy is the native focus owner and it contains the composition window
+ // let's convert the position to a coordinate space relative to proxy
+ ::MapWindowPoints(GetHWnd(), GetProxyFocusOwner(), (LPPOINT)&cf.ptCurrentPos, 1);
ImmSetCompositionWindow(hIMC, &cf);
LOGFONT lf;
--- a/jdk/src/windows/native/sun/windows/awt_Toolkit.cpp Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_Toolkit.cpp Tue May 03 22:14:39 2011 -0700
@@ -740,18 +740,34 @@
canDispose = syncCS.TryEnter();
}
if (canDispose) {
- AwtObject *o = (AwtObject *)wParam;
- o->Dispose();
- if (shouldEnterCriticalSection) {
- syncCS.Leave();
+ if(wParam != NULL) {
+ AwtObject *o = (AwtObject *) JNI_GET_PDATA((jobject)wParam);
+ if(o != NULL && theAwtObjectList.Remove(o)) {
+ o->Dispose();
+ }
+ if (shouldEnterCriticalSection) {
+ syncCS.Leave();
+ }
}
} else {
AwtToolkit::GetInstance().PostMessage(WM_AWT_DISPOSE, wParam, lParam);
}
return 0;
}
+ case WM_AWT_DISPOSEPDATA: {
+ /*
+ * NOTE: synchronization routine (like in WM_AWT_DISPOSE) was omitted because
+ * this handler is called ONLY while disposing Cursor and Font objects where
+ * synchronization takes place.
+ */
+ AwtObject *o = (AwtObject *) wParam;
+ if(o != NULL && theAwtObjectList.Remove(o)) {
+ o->Dispose();
+ }
+ return 0;
+ }
case WM_AWT_DELETEOBJECT: {
- AwtObject *p = (AwtObject *)wParam;
+ AwtObject *p = (AwtObject *) wParam;
if (p->CanBeDeleted()) {
// all the messages for this component are processed, so
// it can be deleted
--- a/jdk/src/windows/native/sun/windows/awt_TrayIcon.cpp Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_TrayIcon.cpp Tue May 03 22:14:39 2011 -0700
@@ -926,8 +926,7 @@
{
TRY;
- PDATA pData = JNI_GET_PDATA(self);
- AwtObject::_Dispose(pData);
+ AwtObject::_Dispose(self);
CATCH_BAD_ALLOC;
}
--- a/jdk/src/windows/native/sun/windows/awtmsg.h Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/src/windows/native/sun/windows/awtmsg.h Tue May 03 22:14:39 2011 -0700
@@ -219,6 +219,7 @@
WM_AWT_ENDCOMPOSITION,
WM_AWT_DISPOSE,
+ WM_AWT_DISPOSEPDATA,
WM_AWT_DELETEOBJECT,
WM_AWT_SETCONVERSIONSTATUS,
WM_AWT_GETCONVERSIONSTATUS,
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Component/Revalidate/Revalidate.java Tue May 03 22:14:39 2011 -0700
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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 7036669
+ @summary Test Component.revalidate() method
+ @author anthony.petrov@oracle.com: area=awt.component
+ @run main Revalidate
+*/
+
+import java.awt.*;
+
+public class Revalidate {
+ private static Frame frame = new Frame();
+ private static Panel panel = new Panel() {
+ @Override
+ public boolean isValidateRoot() {
+ return true;
+ }
+ };
+ private static Button button = new Button("Test");
+
+ private static void sleep() {
+ try { Thread.sleep(500); } catch (Exception e) {}
+ }
+
+ private static void printState(String str) {
+ System.out.println(str + " isValid state: ");
+ System.out.println(" frame: " + frame.isValid());
+ System.out.println(" panel: " + panel.isValid());
+ System.out.println(" button: " + button.isValid());
+ }
+
+ private static void fail(String msg) {
+ frame.dispose();
+ throw new RuntimeException(msg);
+ }
+
+ private static void check(String n, Component c, boolean v) {
+ if (c.isValid() != v) {
+ fail(n + ".isValid() = " + c.isValid() + "; expected: " + v);
+ }
+ }
+ private static void check(String str, boolean f, boolean p, boolean b) {
+ printState(str);
+
+ check("frame", frame, f);
+ check("panel", panel, p);
+ check("button", button, b);
+ }
+
+ public static void main(String[] args) {
+ // setup
+ frame.add(panel);
+ panel.add(button);
+ frame.setBounds(200, 200, 300, 200);
+ frame.setVisible(true);
+ sleep();
+ check("Upon showing", true, true, true);
+
+ button.setBounds(1, 1, 30, 30);
+ sleep();
+ check("button.setBounds():", true, false, false);
+
+ button.revalidate();
+ sleep();
+ check("button.revalidate():", true, true, true);
+
+ button.setBounds(1, 1, 30, 30);
+ sleep();
+ check("button.setBounds():", true, false, false);
+
+ panel.revalidate();
+ sleep();
+ // because the panel's validate root is actually OK
+ check("panel.revalidate():", true, false, false);
+
+ button.revalidate();
+ sleep();
+ check("button.revalidate():", true, true, true);
+
+ panel.setBounds(2, 2, 125, 130);
+ sleep();
+ check("panel.setBounds():", false, false, true);
+
+ button.revalidate();
+ sleep();
+ check("button.revalidate():", false, true, true);
+
+ panel.setBounds(3, 3, 152, 121);
+ sleep();
+ check("panel.setBounds():", false, false, true);
+
+ panel.revalidate();
+ sleep();
+ check("panel.revalidate():", true, true, true);
+
+ // cleanup
+ frame.dispose();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Graphics2D/MTGraphicsAccessTest/MTGraphicsAccessTest.java Tue May 03 22:14:39 2011 -0700
@@ -0,0 +1,361 @@
+/*
+ * Copyright (c) 2010, 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 5089429 6982632
+ @summary Checks that we don't crash if rendering operations and state
+ changes are performed on a graphics context from different threads.
+
+ @author Dmitri.Trembovetski@sun.com area=Graphics
+ @run main MTGraphicsAccessTest
+ */
+
+import java.awt.*;
+import java.awt.image.*;
+import java.awt.geom.*;
+
+public class MTGraphicsAccessTest {
+
+ // in seconds
+ static final long STANDALONE_RUN_TIME = 20;
+ static final long JTREG_RUN_TIME = 7;
+
+ static boolean standaloneMode;
+ static boolean allowExceptions = true;
+ static long testRunTime;
+
+ volatile boolean done;
+ volatile int stillRunning;
+ volatile int numexceptions;
+
+ Graphics2D sharedGraphics;
+ BufferedImage sharedBI =
+ new BufferedImage(50, 50, BufferedImage.TYPE_INT_RGB);
+
+ static final Paint colors[] = {
+ Color.red,
+ new Color(0x7f, 0xff, 0x00, 0x7f),
+ new GradientPaint(0, 0, Color.red,
+ 50, 50, new Color(0x7f, 0xff, 0x00, 0x7f)),
+ };
+ static final Font fonts[] = {
+ new Font("Dialog", Font.PLAIN, 12),
+ new Font("Dialog", Font.BOLD, 16),
+ new Font("Dialog", Font.ITALIC, 18),
+ };
+ static final AlphaComposite comps[] = {
+ AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f),
+ AlphaComposite.Src,
+ AlphaComposite.Xor,
+ AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f),
+ null,
+ };
+ static final Stroke strokes[] = {
+ new BasicStroke(),
+ new BasicStroke(0.0f),
+ new BasicStroke(2.0f),
+ new BasicStroke(2.0f, BasicStroke.CAP_ROUND,
+ BasicStroke.JOIN_BEVEL),
+ new BasicStroke(5.0f, BasicStroke.CAP_SQUARE,
+ BasicStroke.JOIN_ROUND),
+ new BasicStroke(0.0f, BasicStroke.CAP_ROUND,
+ BasicStroke.JOIN_ROUND, 0,
+ new float[]{0,6,0,6}, 0),
+ };
+ static final AffineTransform transforms[] = {
+ new AffineTransform(),
+ AffineTransform.getRotateInstance(10.0),
+ AffineTransform.getShearInstance(10.0, 4.0),
+ AffineTransform.getScaleInstance(1.1, 1.2),
+ AffineTransform.getScaleInstance(3.0, 2.0),
+ };
+
+ public MTGraphicsAccessTest() {
+ BufferedImage bi =
+ new BufferedImage(50, 50, BufferedImage.TYPE_INT_RGB);
+ sharedGraphics = (Graphics2D)bi.getGraphics();
+
+ done = false;
+ numexceptions = 0;
+
+ for (int i = 0; i < (standaloneMode ? stateChangers.length : 3); i++) {
+ (new TesterThread(stateChangers[i])).start();
+ }
+ for (int i = 0; i < (standaloneMode ? renderTests.length : 5); i++) {
+ (new TesterThread(renderTests[i])).start();
+ }
+
+ mysleep(testRunTime);
+ done = true;
+ while (stillRunning > 0) { mysleep(500); }
+
+ if (numexceptions == 0) {
+ System.err.println("Test passed");
+ } else if (!allowExceptions) {
+ throw new RuntimeException("Test failed with "+
+ numexceptions+" exceptions");
+ } else {
+ System.err.println("Test finished with "+
+ numexceptions+" exceptions");
+ }
+ }
+
+ private void mysleep(long time) {
+ try {
+ // add +/-5ms variance to increase randomness
+ Thread.sleep(time + (long)(5 - Math.random()*10));
+ } catch (InterruptedException e) {};
+ }
+
+ public static void usage(String message) {
+ if (message != null) {
+ System.err.println(message);
+ }
+ System.err.println("Usage: MTGraphicsAccessTest [-full] "+
+ "[-time N/forever] [-help]");
+ System.err.println(" -full: run full suite of tests "+
+ "(default: limited number of tests is run)");
+ System.err.println(" -time N: test duration in seconds/forever"+
+ " (default: "+JTREG_RUN_TIME+"s for the short suite, "+
+ STANDALONE_RUN_TIME+"s for the full suite)");
+ System.err.println(" -help: print this help page");
+ System.exit(1);
+ }
+
+ public static void main(String[] args) {
+ boolean testRunSet = false;
+ for (int i = 0; i < args.length; i++) {
+ if ("-full".equals(args[i])) {
+ standaloneMode = true;
+ System.err.println("Running complete list of tests");
+ } else if ("-noexc".equals(args[i])) {
+ allowExceptions = false;
+ } else if ("-time".equals(args[i])) {
+ try {
+ String time = args[++i];
+ if ("forever".equals(time)) {
+ testRunTime = (Long.MAX_VALUE - 20)/1000;
+ } else {
+ testRunTime = 1000*Integer.parseInt(time);
+ }
+ testRunSet = true;
+ } catch (NumberFormatException e) {
+ usage("Can't parse number of seconds: " + args[i]);
+ } catch (ArrayIndexOutOfBoundsException e1) {
+ usage("Missing the 'seconds' argument for -time parameter");
+ }
+ } else if ("-help".equals(args[i])) {
+ usage(null);
+ } else {
+ usage("Unknown argument:" + args[i]);
+ }
+ }
+
+ if (!testRunSet) {
+ testRunTime = 1000 *
+ (standaloneMode ? STANDALONE_RUN_TIME : JTREG_RUN_TIME);
+ }
+
+ System.err.println("Approximate test run time: "+
+ testRunTime/1000+" seconds");
+
+ new MTGraphicsAccessTest();
+ }
+
+ class TesterThread extends Thread {
+ Runnable testRunnable;
+
+ public TesterThread(Runnable testRunnable) {
+ stillRunning++;
+ this.testRunnable = testRunnable;
+ }
+
+ public void run() {
+ try {
+ while (!done) {
+ try {
+ testRunnable.run();
+ yield();
+ } catch (Throwable t) {
+ numexceptions++;
+ t.printStackTrace();
+ }
+ }
+ } finally {
+ stillRunning--;
+ }
+ }
+ }
+
+ final Runnable stateChangers[] = {
+ new Runnable() {
+ public void run() {
+ sharedGraphics.setClip(10, 10, 30, 30);
+ mysleep(10);
+ }
+ },
+ new Runnable() {
+ public void run() {
+ sharedGraphics.setClip(10, 10, 30, 30);
+ mysleep(10);
+ }
+ },
+ new Runnable() {
+ int c = 0;
+ public void run() {
+ sharedGraphics.setPaint(colors[c++ % colors.length]);
+ mysleep(10);
+ }
+ },
+ new Runnable() {
+ boolean AA = false;
+ public void run() {
+ if (AA) {
+ sharedGraphics.setRenderingHint(
+ RenderingHints.KEY_ANTIALIASING,
+ RenderingHints.VALUE_ANTIALIAS_ON);
+ } else {
+ sharedGraphics.setRenderingHint(
+ RenderingHints.KEY_ANTIALIASING,
+ RenderingHints.VALUE_ANTIALIAS_OFF);
+ }
+ AA = !AA;
+ mysleep(10);
+ }
+ },
+ new Runnable() {
+ int t = 0;
+ public void run() {
+ sharedGraphics.setTransform(
+ transforms[t++ % transforms.length]);
+ mysleep(10);
+ }
+ },
+ new Runnable() {
+ int c = 0;
+ public void run() {
+ AlphaComposite comp = comps[c++ % comps.length];
+ if (comp == null) {
+ sharedGraphics.setXORMode(Color.green);
+ } else {
+ sharedGraphics.setComposite(comp);
+ }
+ mysleep(10);
+ }
+ },
+ new Runnable() {
+ int s = 0;
+ public void run() {
+ sharedGraphics.setStroke(strokes[s++ % strokes.length]);
+ mysleep(10);
+ }
+ },
+ new Runnable() {
+ int f = 0;
+ public void run() {
+ sharedGraphics.setFont(fonts[f++ % fonts.length]);
+ mysleep(10);
+ }
+ },
+ };
+
+ final Runnable renderTests[] = {
+ new Runnable() {
+ public void run() {
+ sharedGraphics.drawLine(10, 10, 30, 30);
+ }
+ },
+ new Runnable() {
+ public void run() {
+ sharedGraphics.drawLine(10, 10, 30, 30);
+ }
+ },
+ new Runnable() {
+ public void run() {
+ sharedGraphics.drawRect(10, 10, 30, 30);
+ }
+ },
+ new Runnable() {
+ public void run() {
+ sharedGraphics.fillRect(10, 10, 30, 30);
+ }
+ },
+ new Runnable() {
+ public void run() {
+ sharedGraphics.drawString("Stuff", 10, 10);
+ }
+ },
+ new Runnable() {
+ public void run() {
+ sharedGraphics.draw3DRect(10, 10, 30, 30, true);
+ }
+ },
+ new Runnable() {
+ public void run() {
+ sharedGraphics.drawImage(sharedBI, 10, 10, null);
+ }
+ },
+ new Runnable() {
+ public void run() {
+ sharedGraphics.fill3DRect(10, 10, 30, 30, false);
+ }
+ },
+ // REMIND: copyArea doesn't work when transform is set..
+ // new Runnable() {
+ // public void run() {
+ // sharedGraphics.copyArea(10, 10, 30, 30, 20, 20);
+ // }
+ // },
+ new Runnable() {
+ public void run() {
+ sharedGraphics.drawRoundRect(10, 10, 30, 30, 20, 20);
+ }
+ },
+ new Runnable() {
+ public void run() {
+ sharedGraphics.fillRoundRect(10, 10, 30, 30, 20, 20);
+ }
+ },
+ new Runnable() {
+ public void run() {
+ sharedGraphics.drawArc(10, 10, 30, 30, 0, 90);
+ }
+ },
+ new Runnable() {
+ public void run() {
+ sharedGraphics.fillArc(10, 10, 30, 30, 0, 90);
+ }
+ },
+ new Runnable() {
+ public void run() {
+ sharedGraphics.drawOval(10, 10, 30, 30);
+ }
+ },
+ new Runnable() {
+ public void run() {
+ sharedGraphics.fillOval(10, 10, 30, 30);
+ }
+ }
+ };
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/List/ScrollOutside/ScrollOut.java Tue May 03 22:14:39 2011 -0700
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2011 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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 7036733
+ @summary Regression : NullPointerException when scrolling horizontally on AWT List
+ @author Andrei Dmitriev area=awt-list
+ @library ../../regtesthelpers
+ @build Util
+ @run main ScrollOut
+*/
+
+import java.awt.*;
+import java.awt.event.*;
+import sun.awt.SunToolkit;
+import test.java.awt.regtesthelpers.Util;
+
+public class ScrollOut
+{
+ public static final void main(String args[])
+ {
+ final Frame frame = new Frame();
+ final List list = new List();
+ Robot robot = null;
+
+ for (int i = 0; i < 5; i++){
+ list.add("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz");
+ }
+
+ frame.add(list);
+
+ frame.pack();
+ frame.setLocationRelativeTo(null);
+ frame.setVisible(true);
+
+ ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+
+ try{
+ robot = new Robot();
+ }catch(AWTException e){
+ throw new RuntimeException(e);
+ }
+
+ //Drag from center to the outside on left
+ Point from = new Point(list.getLocationOnScreen().x + list.getWidth()/2,
+ list.getLocationOnScreen().y + list.getHeight()/2);
+ Point to = new Point(list.getLocationOnScreen().x - 30,
+ from.y);
+
+ ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ Util.drag(robot, from, to, InputEvent.BUTTON1_MASK);
+
+ ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+
+ //Drag from center to the outside on up
+ to = new Point(from.x,
+ list.getLocationOnScreen().y - 50);
+
+ ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ Util.drag(robot, from, to, InputEvent.BUTTON1_MASK);
+
+ }//End init()
+}
--- a/jdk/test/java/awt/event/MouseWheelEvent/InfiniteRecursion/InfiniteRecursion.java Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/test/java/awt/event/MouseWheelEvent/InfiniteRecursion/InfiniteRecursion.java Tue May 03 22:14:39 2011 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2011 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -50,6 +50,11 @@
public class InfiniteRecursion {
final static Robot robot = Util.createRobot();
final static int MOVE_COUNT = 5;
+
+ //*2 for both rotation directions,
+ //*2 as Java sends the wheel event to every for nested component in hierarchy under cursor
+ final static int EXPECTED_COUNT = MOVE_COUNT * 2 * 2;
+
static int actualEvents = 0;
public static void main(String []s)
@@ -96,8 +101,10 @@
Util.waitForIdle(robot);
- if (actualEvents != MOVE_COUNT * 2) {
- AbstractTest.fail("Expected events count: "+ MOVE_COUNT+" Actual events count: "+ actualEvents);
+ //Not fair to check for multiplier 4 as it's not specified actual number of WheelEvents
+ //result in a single wheel rotation.
+ if (actualEvents != EXPECTED_COUNT) {
+ AbstractTest.fail("Expected events count: "+ EXPECTED_COUNT+" Actual events count: "+ actualEvents);
}
}
}
--- a/jdk/test/java/awt/event/MouseWheelEvent/InfiniteRecursion/InfiniteRecursion_1.java Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/test/java/awt/event/MouseWheelEvent/InfiniteRecursion/InfiniteRecursion_1.java Tue May 03 22:14:39 2011 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2011 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -50,6 +50,9 @@
public class InfiniteRecursion_1 {
final static Robot robot = Util.createRobot();
final static int MOVE_COUNT = 5;
+ //*2 for both rotation directions,
+ //*2 as Java sends the wheel event to every for nested component in hierarchy under cursor
+ final static int EXPECTED_COUNT = MOVE_COUNT * 2 * 2;
static int actualEvents = 0;
public static void main(String []s)
@@ -95,8 +98,10 @@
}
Util.waitForIdle(robot);
- if (actualEvents != MOVE_COUNT * 2) {
- AbstractTest.fail("Expected events count: "+ MOVE_COUNT+" Actual events count: "+ actualEvents);
+ //Not fair to check for multiplier 4 as it's not specified actual number of WheelEvents
+ //result in a single wheel rotation.
+ if (actualEvents != EXPECTED_COUNT) {
+ AbstractTest.fail("Expected events count: "+ EXPECTED_COUNT+" Actual events count: "+ actualEvents);
}
}
}
--- a/jdk/test/java/awt/event/MouseWheelEvent/InfiniteRecursion/InfiniteRecursion_2.java Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/test/java/awt/event/MouseWheelEvent/InfiniteRecursion/InfiniteRecursion_2.java Tue May 03 22:14:39 2011 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2011 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -56,6 +56,9 @@
public class InfiniteRecursion_2 extends Applet {
final static Robot robot = Util.createRobot();
final static int MOVE_COUNT = 5;
+ //*2 for both rotation directions,
+ //*2 as Java sends the wheel event to every for nested component in hierarchy under cursor
+ final static int EXPECTED_COUNT = MOVE_COUNT * 2 * 2;
static int actualEvents = 0;
public void init()
@@ -107,8 +110,10 @@
}
Util.waitForIdle(robot);
- if (actualEvents != MOVE_COUNT * 2) {
- AbstractTest.fail("Expected events count: "+ MOVE_COUNT+" Actual events count: "+ actualEvents);
+ //Not fair to check for multiplier 4 as it's not specified actual number of WheelEvents
+ //result in a single wheel rotation.
+ if (actualEvents != EXPECTED_COUNT) {
+ AbstractTest.fail("Expected events count: "+ EXPECTED_COUNT+" Actual events count: "+ actualEvents);
}
}// start()
}
--- a/jdk/test/java/awt/event/MouseWheelEvent/InfiniteRecursion/InfiniteRecursion_3.java Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/test/java/awt/event/MouseWheelEvent/InfiniteRecursion/InfiniteRecursion_3.java Tue May 03 22:14:39 2011 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2011 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -50,6 +50,9 @@
public class InfiniteRecursion_3 extends Applet {
final static Robot robot = Util.createRobot();
final static int MOVE_COUNT = 5;
+ //*2 for both rotation directions,
+ //*2 as Java sends the wheel event to every for nested component in hierarchy under cursor
+ final static int EXPECTED_COUNT = MOVE_COUNT * 2 * 2;
static int actualEvents = 0;
public void init()
@@ -91,8 +94,10 @@
}
Util.waitForIdle(robot);
- if (actualEvents != MOVE_COUNT * 2) {
- AbstractTest.fail("Expected events count: "+ MOVE_COUNT+" Actual events count: "+ actualEvents);
+ //Not fair to check for multiplier 4 as it's not specified actual number of WheelEvents
+ //result in a single wheel rotation.
+ if (actualEvents != EXPECTED_COUNT) {
+ AbstractTest.fail("Expected events count: "+ EXPECTED_COUNT+" Actual events count: "+ actualEvents);
}
}// start()
}
--- a/jdk/test/java/awt/event/MouseWheelEvent/InfiniteRecursion/InfiniteRecursion_4.java Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/test/java/awt/event/MouseWheelEvent/InfiniteRecursion/InfiniteRecursion_4.java Tue May 03 22:14:39 2011 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2011 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -47,6 +47,8 @@
public class InfiniteRecursion_4 {
final static Robot robot = Util.createRobot();
final static int MOVE_COUNT = 5;
+ //*2 for both rotation directions over a single frame without any siblings
+ final static int EXPECTED_COUNT = MOVE_COUNT * 2;
static int actualEvents = 0;
public static void main(String []s)
@@ -80,8 +82,10 @@
}
Util.waitForIdle(robot);
- if (actualEvents != MOVE_COUNT * 2) {
- AbstractTest.fail("Expected events count: "+ MOVE_COUNT+" Actual events count: "+ actualEvents);
+ //Not fair to check for multiplier 4 as it's not specified actual number of WheelEvents
+ //result in a single wheel rotation.
+ if (actualEvents != EXPECTED_COUNT) {
+ AbstractTest.fail("Expected events count: "+ EXPECTED_COUNT+" Actual events count: "+ actualEvents);
}
}
}
--- a/jdk/test/java/util/jar/JarInputStream/ScanSignedJar.java Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/test/java/util/jar/JarInputStream/ScanSignedJar.java Tue May 03 22:14:39 2011 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,11 +27,9 @@
* @summary Confirm that JarEntry.getCertificates identifies signed entries.
*/
-import java.io.*;
import java.net.URL;
import java.security.CodeSigner;
import java.security.cert.Certificate;
-import java.util.Enumeration;
import java.util.jar.*;
/*
@@ -72,6 +70,9 @@
if (signers == null && certificates == null) {
System.out.println("[unsigned]\t" + name + "\t(" + size +
" bytes)");
+ if (name.equals("Count.class")) {
+ throw new Exception("Count.class should be signed");
+ }
} else if (signers != null && certificates != null) {
System.out.println("[" + signers.length +
(signers.length == 1 ? " signer" : " signers") + "]\t" +
--- a/jdk/test/java/util/jar/JarInputStream/TestIndexedJarWithBadSignature.java Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/test/java/util/jar/JarInputStream/TestIndexedJarWithBadSignature.java Tue May 03 22:14:39 2011 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -37,7 +37,7 @@
public static void main(String...args) throws Throwable {
try (JarInputStream jis = new JarInputStream(
- new FileInputStream(System.getProperty("tst.src", ".") +
+ new FileInputStream(System.getProperty("test.src", ".") +
System.getProperty("file.separator") +
"BadSignedJar.jar")))
{
--- a/jdk/test/sun/java2d/pipe/Test7027667.java Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/test/sun/java2d/pipe/Test7027667.java Tue May 03 22:14:39 2011 -0700
@@ -23,7 +23,7 @@
/**
* @test
- * @bug 7027667, 7023591
+ * @bug 7027667 7023591 7037091
*
* @summary Verifies that aa clipped rectangles are drawn, not filled.
*
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/java2d/pisces/Test7036754.java Tue May 03 22:14:39 2011 -0700
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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 7036754
+ *
+ * @summary Verifies that there are no non-finite numbers when stroking
+ * certain quadratic curves.
+ *
+ * @author Jim Graham
+ * @run main Test7036754
+ */
+
+import java.awt.*;
+import java.awt.geom.*;
+
+public class Test7036754 {
+ public static void main(String argv[]) {
+ Shape s = new QuadCurve2D.Float(839.24677f, 508.97888f,
+ 839.2953f, 508.97122f,
+ 839.3438f, 508.96353f);
+ s = new BasicStroke(10f).createStrokedShape(s);
+ float nsegs[] = {2, 2, 4, 6, 0};
+ float coords[] = new float[6];
+ PathIterator pi = s.getPathIterator(null);
+ while (!pi.isDone()) {
+ int type = pi.currentSegment(coords);
+ for (int i = 0; i < nsegs[type]; i++) {
+ float c = coords[i];
+ if (Float.isNaN(c) || Float.isInfinite(c)) {
+ throw new RuntimeException("bad value in stroke");
+ }
+ }
+ pi.next();
+ }
+ }
+}