# HG changeset patch
# User chegar
# Date 1365880560 -3600
# Node ID 5f46a666e06d321c77b6acef91db1e2fbe37111f
# Parent e62a707a77d821ea4fe8d1416c78a388231412ea# Parent b057eaf53935d15ede8cfec8f00d71776816c77a
Merge
diff -r e62a707a77d8 -r 5f46a666e06d make/sun/font/FILES_c.gmk
--- a/make/sun/font/FILES_c.gmk Thu Apr 11 19:15:24 2013 -0700
+++ b/make/sun/font/FILES_c.gmk Sat Apr 13 20:16:00 2013 +0100
@@ -106,7 +106,21 @@
OpenTypeLayoutEngine.cpp \
ThaiLayoutEngine.cpp \
ScriptAndLanguageTags.cpp \
- FontInstanceAdapter.cpp
+ FontInstanceAdapter.cpp \
+ ContextualGlyphInsertionProc2.cpp \
+ ContextualGlyphSubstProc2.cpp \
+ GXLayoutEngine2.cpp \
+ IndicRearrangementProcessor2.cpp \
+ LigatureSubstProc2.cpp \
+ MorphTables2.cpp \
+ NonContextualGlyphSubstProc2.cpp \
+ SegmentArrayProcessor2.cpp \
+ SegmentSingleProcessor2.cpp \
+ SimpleArrayProcessor2.cpp \
+ SingleTableProcessor2.cpp \
+ StateTableProcessor2.cpp \
+ SubtableProcessor2.cpp \
+ TrimmedArrayProcessor2.cpp
ifeq ($(PLATFORM),windows)
diff -r e62a707a77d8 -r 5f46a666e06d src/macosx/classes/sun/lwawt/LWWindowPeer.java
--- a/src/macosx/classes/sun/lwawt/LWWindowPeer.java Thu Apr 11 19:15:24 2013 -0700
+++ b/src/macosx/classes/sun/lwawt/LWWindowPeer.java Sat Apr 13 20:16:00 2013 +0100
@@ -170,7 +170,7 @@
setTitle(((Dialog) getTarget()).getTitle());
}
- setAlwaysOnTop(getTarget().isAlwaysOnTop());
+ updateAlwaysOnTopState();
updateMinimumSize();
final Shape shape = getTarget().getShape();
@@ -357,8 +357,8 @@
}
@Override
- public void setAlwaysOnTop(boolean value) {
- platformWindow.setAlwaysOnTop(value);
+ public void updateAlwaysOnTopState() {
+ platformWindow.setAlwaysOnTop(getTarget().isAlwaysOnTop());
}
@Override
diff -r e62a707a77d8 -r 5f46a666e06d src/macosx/classes/sun/lwawt/macosx/CFileDialog.java
--- a/src/macosx/classes/sun/lwawt/macosx/CFileDialog.java Thu Apr 11 19:15:24 2013 -0700
+++ b/src/macosx/classes/sun/lwawt/macosx/CFileDialog.java Sat Apr 13 20:16:00 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, 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
@@ -180,7 +180,7 @@
}
@Override
- public void setAlwaysOnTop(boolean alwaysOnTop) {
+ public void updateAlwaysOnTopState() {
}
@Override
diff -r e62a707a77d8 -r 5f46a666e06d src/macosx/classes/sun/lwawt/macosx/CPrinterDialogPeer.java
--- a/src/macosx/classes/sun/lwawt/macosx/CPrinterDialogPeer.java Thu Apr 11 19:15:24 2013 -0700
+++ b/src/macosx/classes/sun/lwawt/macosx/CPrinterDialogPeer.java Sat Apr 13 20:16:00 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, 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
@@ -87,7 +87,7 @@
}
// 1.6 peer method
- public void setAlwaysOnTop(boolean value) {
+ public void updateAlwaysOnTopState() {
// no-op, since we just show the native print dialog
}
diff -r e62a707a77d8 -r 5f46a666e06d src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java
--- a/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java Thu Apr 11 19:15:24 2013 -0700
+++ b/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java Sat Apr 13 20:16:00 2013 +0100
@@ -243,12 +243,17 @@
* sending warnings to listeners.
*/
protected void warningOccurred(int code) {
- if ((code < 0) || (code > MAX_WARNING)){
- throw new InternalError("Invalid warning index");
+ cbLock.lock();
+ try {
+ if ((code < 0) || (code > MAX_WARNING)){
+ throw new InternalError("Invalid warning index");
+ }
+ processWarningOccurred
+ ("com.sun.imageio.plugins.jpeg.JPEGImageReaderResources",
+ Integer.toString(code));
+ } finally {
+ cbLock.unlock();
}
- processWarningOccurred
- ("com.sun.imageio.plugins.jpeg.JPEGImageReaderResources",
- Integer.toString(code));
}
/**
@@ -265,7 +270,12 @@
* library warnings from being printed to stderr.
*/
protected void warningWithMessage(String msg) {
- processWarningOccurred(msg);
+ cbLock.lock();
+ try {
+ processWarningOccurred(msg);
+ } finally {
+ cbLock.unlock();
+ }
}
public void setInput(Object input,
@@ -274,18 +284,55 @@
{
setThreadLock();
try {
+ cbLock.check();
+
super.setInput(input, seekForwardOnly, ignoreMetadata);
this.ignoreMetadata = ignoreMetadata;
resetInternalState();
iis = (ImageInputStream) input; // Always works
- setSource(structPointer, iis);
+ setSource(structPointer);
} finally {
clearThreadLock();
}
}
- private native void setSource(long structPointer,
- ImageInputStream source);
+ /**
+ * This method is called from native code in order to fill
+ * native input buffer.
+ *
+ * We block any attempt to change the reading state during this
+ * method, in order to prevent a corruption of the native decoder
+ * state.
+ *
+ * @return number of bytes read from the stream.
+ */
+ private int readInputData(byte[] buf, int off, int len) throws IOException {
+ cbLock.lock();
+ try {
+ return iis.read(buf, off, len);
+ } finally {
+ cbLock.unlock();
+ }
+ }
+
+ /**
+ * This method is called from the native code in order to
+ * skip requested number of bytes in the input stream.
+ *
+ * @param n
+ * @return
+ * @throws IOException
+ */
+ private long skipInputBytes(long n) throws IOException {
+ cbLock.lock();
+ try {
+ return iis.skipBytes(n);
+ } finally {
+ cbLock.unlock();
+ }
+ }
+
+ private native void setSource(long structPointer);
private void checkTablesOnly() throws IOException {
if (debug) {
@@ -337,6 +384,8 @@
public int getNumImages(boolean allowSearch) throws IOException {
setThreadLock();
try { // locked thread
+ cbLock.check();
+
return getNumImagesOnThread(allowSearch);
} finally {
clearThreadLock();
@@ -536,8 +585,13 @@
if (debug) {
System.out.println("pushing back " + num + " bytes");
}
- iis.seek(iis.getStreamPosition()-num);
- // The buffer is clear after this, so no need to set haveSeeked.
+ cbLock.lock();
+ try {
+ iis.seek(iis.getStreamPosition()-num);
+ // The buffer is clear after this, so no need to set haveSeeked.
+ } finally {
+ cbLock.unlock();
+ }
}
/**
@@ -644,7 +698,12 @@
* Ignore this profile.
*/
iccCS = null;
- warningOccurred(WARNING_IGNORE_INVALID_ICC);
+ cbLock.lock();
+ try {
+ warningOccurred(WARNING_IGNORE_INVALID_ICC);
+ } finally {
+ cbLock.unlock();
+ }
}
}
}
@@ -653,6 +712,7 @@
setThreadLock();
try {
if (currentImage != imageIndex) {
+ cbLock.check();
readHeader(imageIndex, true);
}
return width;
@@ -665,6 +725,7 @@
setThreadLock();
try {
if (currentImage != imageIndex) {
+ cbLock.check();
readHeader(imageIndex, true);
}
return height;
@@ -693,6 +754,8 @@
setThreadLock();
try {
if (currentImage != imageIndex) {
+ cbLock.check();
+
readHeader(imageIndex, true);
}
@@ -716,6 +779,7 @@
private Iterator getImageTypesOnThread(int imageIndex)
throws IOException {
if (currentImage != imageIndex) {
+ cbLock.check();
readHeader(imageIndex, true);
}
@@ -931,6 +995,7 @@
setThreadLock();
try {
if (!tablesOnlyChecked) {
+ cbLock.check();
checkTablesOnly();
}
return streamMetadata;
@@ -951,6 +1016,8 @@
return imageMetadata;
}
+ cbLock.check();
+
gotoImage(imageIndex);
imageMetadata = new JPEGMetadata(false, false, iis, this);
@@ -967,6 +1034,7 @@
throws IOException {
setThreadLock();
try {
+ cbLock.check();
try {
readInternal(imageIndex, param, false);
} catch (RuntimeException e) {
@@ -1196,58 +1264,63 @@
}
target.setRect(destROI.x, destROI.y + y, raster);
- processImageUpdate(image,
- destROI.x, destROI.y+y,
- raster.getWidth(), 1,
- 1, 1,
- destinationBands);
- if ((y > 0) && (y%progInterval == 0)) {
- int height = target.getHeight()-1;
- float percentOfPass = ((float)y)/height;
- if (progressive) {
- if (knownPassCount != UNKNOWN) {
- processImageProgress((pass + percentOfPass)*100.0F
- / knownPassCount);
- } else if (maxProgressivePass != Integer.MAX_VALUE) {
- // Use the range of allowed progressive passes
- processImageProgress((pass + percentOfPass)*100.0F
- / (maxProgressivePass - minProgressivePass + 1));
+ cbLock.lock();
+ try {
+ processImageUpdate(image,
+ destROI.x, destROI.y+y,
+ raster.getWidth(), 1,
+ 1, 1,
+ destinationBands);
+ if ((y > 0) && (y%progInterval == 0)) {
+ int height = target.getHeight()-1;
+ float percentOfPass = ((float)y)/height;
+ if (progressive) {
+ if (knownPassCount != UNKNOWN) {
+ processImageProgress((pass + percentOfPass)*100.0F
+ / knownPassCount);
+ } else if (maxProgressivePass != Integer.MAX_VALUE) {
+ // Use the range of allowed progressive passes
+ processImageProgress((pass + percentOfPass)*100.0F
+ / (maxProgressivePass - minProgressivePass + 1));
+ } else {
+ // Assume there are a minimum of MIN_ESTIMATED_PASSES
+ // and that there is always one more pass
+ // Compute the percentage as the percentage at the end
+ // of the previous pass, plus the percentage of this
+ // pass scaled to be the percentage of the total remaining,
+ // assuming a minimum of MIN_ESTIMATED_PASSES passes and
+ // that there is always one more pass. This is monotonic
+ // and asymptotic to 1.0, which is what we need.
+ int remainingPasses = // including this one
+ Math.max(2, MIN_ESTIMATED_PASSES-pass);
+ int totalPasses = pass + remainingPasses-1;
+ progInterval = Math.max(height/20*totalPasses,
+ totalPasses);
+ if (y%progInterval == 0) {
+ percentToDate = previousPassPercentage +
+ (1.0F - previousPassPercentage)
+ * (percentOfPass)/remainingPasses;
+ if (debug) {
+ System.out.print("pass= " + pass);
+ System.out.print(", y= " + y);
+ System.out.print(", progInt= " + progInterval);
+ System.out.print(", % of pass: " + percentOfPass);
+ System.out.print(", rem. passes: "
+ + remainingPasses);
+ System.out.print(", prev%: "
+ + previousPassPercentage);
+ System.out.print(", %ToDate: " + percentToDate);
+ System.out.print(" ");
+ }
+ processImageProgress(percentToDate*100.0F);
+ }
+ }
} else {
- // Assume there are a minimum of MIN_ESTIMATED_PASSES
- // and that there is always one more pass
- // Compute the percentage as the percentage at the end
- // of the previous pass, plus the percentage of this
- // pass scaled to be the percentage of the total remaining,
- // assuming a minimum of MIN_ESTIMATED_PASSES passes and
- // that there is always one more pass. This is monotonic
- // and asymptotic to 1.0, which is what we need.
- int remainingPasses = // including this one
- Math.max(2, MIN_ESTIMATED_PASSES-pass);
- int totalPasses = pass + remainingPasses-1;
- progInterval = Math.max(height/20*totalPasses,
- totalPasses);
- if (y%progInterval == 0) {
- percentToDate = previousPassPercentage +
- (1.0F - previousPassPercentage)
- * (percentOfPass)/remainingPasses;
- if (debug) {
- System.out.print("pass= " + pass);
- System.out.print(", y= " + y);
- System.out.print(", progInt= " + progInterval);
- System.out.print(", % of pass: " + percentOfPass);
- System.out.print(", rem. passes: "
- + remainingPasses);
- System.out.print(", prev%: "
- + previousPassPercentage);
- System.out.print(", %ToDate: " + percentToDate);
- System.out.print(" ");
- }
- processImageProgress(percentToDate*100.0F);
- }
+ processImageProgress(percentOfPass * 100.0F);
}
- } else {
- processImageProgress(percentOfPass * 100.0F);
}
+ } finally {
+ cbLock.unlock();
}
}
@@ -1260,33 +1333,58 @@
}
private void passStarted (int pass) {
- this.pass = pass;
- previousPassPercentage = percentToDate;
- processPassStarted(image,
- pass,
- minProgressivePass,
- maxProgressivePass,
- 0, 0,
- 1,1,
- destinationBands);
+ cbLock.lock();
+ try {
+ this.pass = pass;
+ previousPassPercentage = percentToDate;
+ processPassStarted(image,
+ pass,
+ minProgressivePass,
+ maxProgressivePass,
+ 0, 0,
+ 1,1,
+ destinationBands);
+ } finally {
+ cbLock.unlock();
+ }
}
private void passComplete () {
- processPassComplete(image);
+ cbLock.lock();
+ try {
+ processPassComplete(image);
+ } finally {
+ cbLock.unlock();
+ }
}
void thumbnailStarted(int thumbnailIndex) {
- processThumbnailStarted(currentImage, thumbnailIndex);
+ cbLock.lock();
+ try {
+ processThumbnailStarted(currentImage, thumbnailIndex);
+ } finally {
+ cbLock.unlock();
+ }
}
// Provide access to protected superclass method
void thumbnailProgress(float percentageDone) {
- processThumbnailProgress(percentageDone);
+ cbLock.lock();
+ try {
+ processThumbnailProgress(percentageDone);
+ } finally {
+ cbLock.unlock();
+ }
}
// Provide access to protected superclass method
void thumbnailComplete() {
- processThumbnailComplete();
+ cbLock.lock();
+ try {
+ processThumbnailComplete();
+ } finally {
+ cbLock.unlock();
+ }
}
/**
@@ -1310,6 +1408,11 @@
public void abort() {
setThreadLock();
try {
+ /**
+ * NB: we do not check the call back lock here,
+ * we allow to abort the reader any time.
+ */
+
super.abort();
abortRead(structPointer);
} finally {
@@ -1332,6 +1435,7 @@
setThreadLock();
Raster retval = null;
try {
+ cbLock.check();
/*
* This could be further optimized by not resetting the dest.
* offset and creating a translated raster in readInternal()
@@ -1371,6 +1475,8 @@
public int getNumThumbnails(int imageIndex) throws IOException {
setThreadLock();
try {
+ cbLock.check();
+
getImageMetadata(imageIndex); // checks iis state for us
// Now check the jfif segments
JFIFMarkerSegment jfif =
@@ -1391,6 +1497,8 @@
throws IOException {
setThreadLock();
try {
+ cbLock.check();
+
if ((thumbnailIndex < 0)
|| (thumbnailIndex >= getNumThumbnails(imageIndex))) {
throw new IndexOutOfBoundsException("No such thumbnail");
@@ -1409,6 +1517,8 @@
throws IOException {
setThreadLock();
try {
+ cbLock.check();
+
if ((thumbnailIndex < 0)
|| (thumbnailIndex >= getNumThumbnails(imageIndex))) {
throw new IndexOutOfBoundsException("No such thumbnail");
@@ -1428,6 +1538,8 @@
throws IOException {
setThreadLock();
try {
+ cbLock.check();
+
if ((thumbnailIndex < 0)
|| (thumbnailIndex >= getNumThumbnails(imageIndex))) {
throw new IndexOutOfBoundsException("No such thumbnail");
@@ -1468,6 +1580,7 @@
public void reset() {
setThreadLock();
try {
+ cbLock.check();
super.reset();
} finally {
clearThreadLock();
@@ -1479,6 +1592,8 @@
public void dispose() {
setThreadLock();
try {
+ cbLock.check();
+
if (structPointer != 0) {
disposerRecord.dispose();
structPointer = 0;
@@ -1540,6 +1655,36 @@
theThread = null;
}
}
+
+ private CallBackLock cbLock = new CallBackLock();
+
+ private static class CallBackLock {
+
+ private State lockState;
+
+ CallBackLock() {
+ lockState = State.Unlocked;
+ }
+
+ void check() {
+ if (lockState != State.Unlocked) {
+ throw new IllegalStateException("Access to the reader is not allowed");
+ }
+ }
+
+ private void lock() {
+ lockState = State.Locked;
+ }
+
+ private void unlock() {
+ lockState = State.Unlocked;
+ }
+
+ private static enum State {
+ Unlocked,
+ Locked
+ }
+ }
}
/**
diff -r e62a707a77d8 -r 5f46a666e06d src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriter.java
--- a/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriter.java Thu Apr 11 19:15:24 2013 -0700
+++ b/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriter.java Sat Apr 13 20:16:00 2013 +0100
@@ -183,8 +183,7 @@
return null;
}
});
- initWriterIDs(ImageOutputStream.class,
- JPEGQTable.class,
+ initWriterIDs(JPEGQTable.class,
JPEGHuffmanTable.class);
}
@@ -200,11 +199,13 @@
public void setOutput(Object output) {
setThreadLock();
try {
+ cbLock.check();
+
super.setOutput(output); // validates output
resetInternalState();
ios = (ImageOutputStream) output; // so this will always work
// Set the native destination
- setDest(structPointer, ios);
+ setDest(structPointer);
} finally {
clearThreadLock();
}
@@ -359,6 +360,8 @@
ImageWriteParam param) throws IOException {
setThreadLock();
try {
+ cbLock.check();
+
writeOnThread(streamMetadata, image, param);
} finally {
clearThreadLock();
@@ -1082,13 +1085,18 @@
haveMetadata,
restartInterval);
- if (aborted) {
- processWriteAborted();
- } else {
- processImageComplete();
+ cbLock.lock();
+ try {
+ if (aborted) {
+ processWriteAborted();
+ } else {
+ processImageComplete();
+ }
+
+ ios.flush();
+ } finally {
+ cbLock.unlock();
}
-
- ios.flush();
currentImage++; // After a successful write
}
@@ -1096,6 +1104,8 @@
throws IOException {
setThreadLock();
try {
+ cbLock.check();
+
prepareWriteSequenceOnThread(streamMetadata);
} finally {
clearThreadLock();
@@ -1175,6 +1185,8 @@
throws IOException {
setThreadLock();
try {
+ cbLock.check();
+
if (sequencePrepared == false) {
throw new IllegalStateException("sequencePrepared not called!");
}
@@ -1188,6 +1200,8 @@
public void endWriteSequence() throws IOException {
setThreadLock();
try {
+ cbLock.check();
+
if (sequencePrepared == false) {
throw new IllegalStateException("sequencePrepared not called!");
}
@@ -1200,6 +1214,10 @@
public synchronized void abort() {
setThreadLock();
try {
+ /**
+ * NB: we do not check the call back lock here, we allow to abort
+ * the reader any time.
+ */
super.abort();
abortWrite(structPointer);
} finally {
@@ -1223,6 +1241,8 @@
public void reset() {
setThreadLock();
try {
+ cbLock.check();
+
super.reset();
} finally {
clearThreadLock();
@@ -1232,6 +1252,8 @@
public void dispose() {
setThreadLock();
try {
+ cbLock.check();
+
if (structPointer != 0) {
disposerRecord.dispose();
structPointer = 0;
@@ -1251,13 +1273,18 @@
* sending warnings to listeners.
*/
void warningOccurred(int code) {
- if ((code < 0) || (code > MAX_WARNING)){
- throw new InternalError("Invalid warning index");
+ cbLock.lock();
+ try {
+ if ((code < 0) || (code > MAX_WARNING)){
+ throw new InternalError("Invalid warning index");
+ }
+ processWarningOccurred
+ (currentImage,
+ "com.sun.imageio.plugins.jpeg.JPEGImageWriterResources",
+ Integer.toString(code));
+ } finally {
+ cbLock.unlock();
}
- processWarningOccurred
- (currentImage,
- "com.sun.imageio.plugins.jpeg.JPEGImageWriterResources",
- Integer.toString(code));
}
/**
@@ -1274,21 +1301,41 @@
* library warnings from being printed to stderr.
*/
void warningWithMessage(String msg) {
- processWarningOccurred(currentImage, msg);
+ cbLock.lock();
+ try {
+ processWarningOccurred(currentImage, msg);
+ } finally {
+ cbLock.unlock();
+ }
}
void thumbnailStarted(int thumbnailIndex) {
- processThumbnailStarted(currentImage, thumbnailIndex);
+ cbLock.lock();
+ try {
+ processThumbnailStarted(currentImage, thumbnailIndex);
+ } finally {
+ cbLock.unlock();
+ }
}
// Provide access to protected superclass method
void thumbnailProgress(float percentageDone) {
- processThumbnailProgress(percentageDone);
+ cbLock.lock();
+ try {
+ processThumbnailProgress(percentageDone);
+ } finally {
+ cbLock.unlock();
+ }
}
// Provide access to protected superclass method
void thumbnailComplete() {
- processThumbnailComplete();
+ cbLock.lock();
+ try {
+ processThumbnailComplete();
+ } finally {
+ cbLock.unlock();
+ }
}
///////// End of Package-access API
@@ -1615,16 +1662,14 @@
////////////// Native methods and callbacks
/** Sets up static native structures. */
- private static native void initWriterIDs(Class iosClass,
- Class qTableClass,
+ private static native void initWriterIDs(Class qTableClass,
Class huffClass);
/** Sets up per-writer native structure and returns a pointer to it. */
private native long initJPEGImageWriter();
/** Sets up native structures for output stream */
- private native void setDest(long structPointer,
- ImageOutputStream ios);
+ private native void setDest(long structPointer);
/**
* Returns true
if the write was aborted.
@@ -1749,7 +1794,12 @@
}
raster.setRect(sourceLine);
if ((y > 7) && (y%8 == 0)) { // Every 8 scanlines
- processImageProgress((float) y / (float) sourceHeight * 100.0F);
+ cbLock.lock();
+ try {
+ processImageProgress((float) y / (float) sourceHeight * 100.0F);
+ } finally {
+ cbLock.unlock();
+ }
}
}
@@ -1777,6 +1827,25 @@
}
}
+ /**
+ * This method is called from native code in order to write encoder
+ * output to the destination.
+ *
+ * We block any attempt to change the writer state during this
+ * method, in order to prevent a corruption of the native encoder
+ * state.
+ */
+ private void writeOutputData(byte[] data, int offset, int len)
+ throws IOException
+ {
+ cbLock.lock();
+ try {
+ ios.write(data, offset, len);
+ } finally {
+ cbLock.unlock();
+ }
+ }
+
private Thread theThread = null;
private int theLockCount = 0;
@@ -1811,4 +1880,34 @@
theThread = null;
}
}
+
+ private CallBackLock cbLock = new CallBackLock();
+
+ private static class CallBackLock {
+
+ private State lockState;
+
+ CallBackLock() {
+ lockState = State.Unlocked;
+ }
+
+ void check() {
+ if (lockState != State.Unlocked) {
+ throw new IllegalStateException("Access to the writer is not allowed");
+ }
+ }
+
+ private void lock() {
+ lockState = State.Locked;
+ }
+
+ private void unlock() {
+ lockState = State.Unlocked;
+ }
+
+ private static enum State {
+ Unlocked,
+ Locked
+ }
+ }
}
diff -r e62a707a77d8 -r 5f46a666e06d src/share/classes/com/sun/jmx/mbeanserver/MBeanInstantiator.java
--- a/src/share/classes/com/sun/jmx/mbeanserver/MBeanInstantiator.java Thu Apr 11 19:15:24 2013 -0700
+++ b/src/share/classes/com/sun/jmx/mbeanserver/MBeanInstantiator.java Sat Apr 13 20:16:00 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2013, 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
@@ -32,6 +32,7 @@
import java.io.ObjectInputStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Modifier;
import java.security.Permission;
import java.util.Map;
import java.util.logging.Level;
@@ -213,7 +214,6 @@
Object moi;
-
// ------------------------------
// ------------------------------
Constructor> cons = findConstructor(theClass, null);
@@ -224,6 +224,7 @@
// Instantiate the new object
try {
ReflectUtil.checkPackageAccess(theClass);
+ ensureClassAccess(theClass);
moi= cons.newInstance();
} catch (InvocationTargetException e) {
// Wrap the exception.
@@ -270,7 +271,6 @@
checkMBeanPermission(theClass, null, null, "instantiate");
// Instantiate the new object
-
// ------------------------------
// ------------------------------
final Class>[] tab;
@@ -300,6 +300,7 @@
}
try {
ReflectUtil.checkPackageAccess(theClass);
+ ensureClassAccess(theClass);
moi = cons.newInstance(params);
}
catch (NoSuchMethodError error) {
@@ -741,4 +742,13 @@
sm.checkPermission(perm);
}
}
+
+ private static void ensureClassAccess(Class clazz)
+ throws IllegalAccessException
+ {
+ int mod = clazz.getModifiers();
+ if (!Modifier.isPublic(mod)) {
+ throw new IllegalAccessException("Class is not public and can't be instantiated");
+ }
+ }
}
diff -r e62a707a77d8 -r 5f46a666e06d src/share/classes/com/sun/media/sound/AbstractMidiDevice.java
--- a/src/share/classes/com/sun/media/sound/AbstractMidiDevice.java Thu Apr 11 19:15:24 2013 -0700
+++ b/src/share/classes/com/sun/media/sound/AbstractMidiDevice.java Sat Apr 13 20:16:00 2013 +0100
@@ -56,7 +56,7 @@
// from simultaneous creation and destruction
// reduces possibility of deadlock, compared to
// synchronizing to the class instance
- private Object traRecLock = new Object();
+ private final Object traRecLock = new Object();
// DEVICE ATTRIBUTES
@@ -474,7 +474,7 @@
This is necessary for Receivers retrieved via MidiSystem.getReceiver()
(which opens the device implicitely).
*/
- protected abstract class AbstractReceiver implements MidiDeviceReceiver {
+ abstract class AbstractReceiver implements MidiDeviceReceiver {
private boolean open = true;
@@ -483,24 +483,24 @@
Receiver. Therefore, subclasses should not override this method.
Instead, they should implement implSend().
*/
- public synchronized void send(MidiMessage message, long timeStamp) {
- if (open) {
- implSend(message, timeStamp);
- } else {
+ @Override
+ public final synchronized void send(final MidiMessage message,
+ final long timeStamp) {
+ if (!open) {
throw new IllegalStateException("Receiver is not open");
}
+ implSend(message, timeStamp);
}
-
- protected abstract void implSend(MidiMessage message, long timeStamp);
-
+ abstract void implSend(MidiMessage message, long timeStamp);
/** Close the Receiver.
* Here, the call to the magic method closeInternal() takes place.
* Therefore, subclasses that override this method must call
* 'super.close()'.
*/
- public void close() {
+ @Override
+ public final void close() {
open = false;
synchronized (AbstractMidiDevice.this.traRecLock) {
AbstractMidiDevice.this.getReceiverList().remove(this);
@@ -508,11 +508,12 @@
AbstractMidiDevice.this.closeInternal(this);
}
- public MidiDevice getMidiDevice() {
+ @Override
+ public final MidiDevice getMidiDevice() {
return AbstractMidiDevice.this;
}
- protected boolean isOpen() {
+ final boolean isOpen() {
return open;
}
diff -r e62a707a77d8 -r 5f46a666e06d src/share/classes/com/sun/media/sound/FastShortMessage.java
--- a/src/share/classes/com/sun/media/sound/FastShortMessage.java Thu Apr 11 19:15:24 2013 -0700
+++ b/src/share/classes/com/sun/media/sound/FastShortMessage.java Sat Apr 13 20:16:00 2013 +0100
@@ -32,7 +32,7 @@
*
* @author Florian Bomers
*/
-class FastShortMessage extends ShortMessage {
+final class FastShortMessage extends ShortMessage {
private int packedMsg;
public FastShortMessage(int packedMsg) throws InvalidMidiDataException {
diff -r e62a707a77d8 -r 5f46a666e06d src/share/classes/com/sun/media/sound/FastSysexMessage.java
--- a/src/share/classes/com/sun/media/sound/FastSysexMessage.java Thu Apr 11 19:15:24 2013 -0700
+++ b/src/share/classes/com/sun/media/sound/FastSysexMessage.java Sat Apr 13 20:16:00 2013 +0100
@@ -32,7 +32,7 @@
*
* @author Florian Bomers
*/
-class FastSysexMessage extends SysexMessage {
+final class FastSysexMessage extends SysexMessage {
FastSysexMessage(byte[] data) throws InvalidMidiDataException {
super(data);
diff -r e62a707a77d8 -r 5f46a666e06d src/share/classes/com/sun/media/sound/MidiOutDevice.java
--- a/src/share/classes/com/sun/media/sound/MidiOutDevice.java Thu Apr 11 19:15:24 2013 -0700
+++ b/src/share/classes/com/sun/media/sound/MidiOutDevice.java Sat Apr 13 20:16:00 2013 +0100
@@ -103,9 +103,9 @@
class MidiOutReceiver extends AbstractReceiver {
- protected void implSend(MidiMessage message, long timeStamp) {
- int length = message.getLength();
- int status = message.getStatus();
+ void implSend(final MidiMessage message, final long timeStamp) {
+ final int length = message.getLength();
+ final int status = message.getStatus();
if (length <= 3 && status != 0xF0 && status != 0xF7) {
int packedMsg;
if (message instanceof ShortMessage) {
@@ -140,11 +140,15 @@
}
nSendShortMessage(id, packedMsg, timeStamp);
} else {
+ final byte[] data;
if (message instanceof FastSysexMessage) {
- nSendLongMessage(id, ((FastSysexMessage) message).getReadOnlyMessage(),
- length, timeStamp);
+ data = ((FastSysexMessage) message).getReadOnlyMessage();
} else {
- nSendLongMessage(id, message.getMessage(), length, timeStamp);
+ data = message.getMessage();
+ }
+ final int dataLength = Math.min(length, data.length);
+ if (dataLength > 0) {
+ nSendLongMessage(id, data, dataLength, timeStamp);
}
}
}
diff -r e62a707a77d8 -r 5f46a666e06d src/share/classes/com/sun/media/sound/RealTimeSequencer.java
--- a/src/share/classes/com/sun/media/sound/RealTimeSequencer.java Thu Apr 11 19:15:24 2013 -0700
+++ b/src/share/classes/com/sun/media/sound/RealTimeSequencer.java Sat Apr 13 20:16:00 2013 +0100
@@ -1026,7 +1026,7 @@
class SequencerReceiver extends AbstractReceiver {
- protected void implSend(MidiMessage message, long timeStamp) {
+ void implSend(MidiMessage message, long timeStamp) {
if (recording) {
long tickPos = 0;
diff -r e62a707a77d8 -r 5f46a666e06d src/share/classes/java/awt/Window.java
--- a/src/share/classes/java/awt/Window.java Thu Apr 11 19:15:24 2013 -0700
+++ b/src/share/classes/java/awt/Window.java Sat Apr 13 20:16:00 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2013, 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
@@ -2234,7 +2234,7 @@
WindowPeer peer = (WindowPeer)this.peer;
synchronized(getTreeLock()) {
if (peer != null) {
- peer.setAlwaysOnTop(alwaysOnTop);
+ peer.updateAlwaysOnTopState();
}
}
}
diff -r e62a707a77d8 -r 5f46a666e06d src/share/classes/java/awt/peer/WindowPeer.java
--- a/src/share/classes/java/awt/peer/WindowPeer.java Thu Apr 11 19:15:24 2013 -0700
+++ b/src/share/classes/java/awt/peer/WindowPeer.java Sat Apr 13 20:16:00 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2013, 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
@@ -53,15 +53,14 @@
void toBack();
/**
- * Sets if the window should always stay on top of all other windows or
- * not.
+ * Updates the window's always-on-top state.
+ * Sets if the window should always stay
+ * on top of all other windows or not.
*
- * @param alwaysOnTop if the window should always stay on top of all other
- * windows or not
- *
+ * @see Window#getAlwaysOnTop()
* @see Window#setAlwaysOnTop(boolean)
*/
- void setAlwaysOnTop(boolean alwaysOnTop);
+ void updateAlwaysOnTopState();
/**
* Updates the window's focusable state.
diff -r e62a707a77d8 -r 5f46a666e06d src/share/classes/java/beans/ThreadGroupContext.java
--- a/src/share/classes/java/beans/ThreadGroupContext.java Thu Apr 11 19:15:24 2013 -0700
+++ b/src/share/classes/java/beans/ThreadGroupContext.java Sat Apr 13 20:16:00 2013 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, 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
@@ -29,7 +29,6 @@
import com.sun.beans.finder.PropertyEditorFinder;
import java.awt.GraphicsEnvironment;
-import java.util.HashMap;
import java.util.Map;
import java.util.WeakHashMap;
@@ -42,7 +41,7 @@
*/
final class ThreadGroupContext {
- private static final Map contexts = new WeakHashMap<>();
+ private static final WeakIdentityMap contexts = new WeakIdentityMap<>();
/**
* Returns the appropriate {@code AppContext} for the caller,
@@ -69,6 +68,8 @@
private BeanInfoFinder beanInfoFinder;
private PropertyEditorFinder propertyEditorFinder;
+ private ThreadGroupContext() {
+ }
boolean isDesignTime() {
return this.isDesignTime;
diff -r e62a707a77d8 -r 5f46a666e06d src/share/classes/java/beans/WeakIdentityMap.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/java/beans/WeakIdentityMap.java Sat Apr 13 20:16:00 2013 +0100
@@ -0,0 +1,181 @@
+/*
+ * Copyright (c) 2013, 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 java.beans;
+
+import java.lang.ref.ReferenceQueue;
+import java.lang.ref.WeakReference;
+
+/**
+ * Hash table based mapping, which uses weak references to store keys
+ * and reference-equality in place of object-equality to compare them.
+ * An entry will automatically be removed when its key is no longer
+ * in ordinary use. Both null values and the null key are supported.
+ *
+ * @see java.util.IdentityHashMap
+ * @see java.util.WeakHashMap
+ */
+final class WeakIdentityMap {
+
+ private static final int MAXIMUM_CAPACITY = 1 << 30; // it MUST be a power of two
+ private static final Object NULL = new Object(); // special object for null key
+
+ private final ReferenceQueue