diff --git a/make/sun/font/FILES_c.gmk b/make/sun/font/FILES_c.gmk
index c94370642168a2352bcc4b454aa05bf8ea0ef2c6..b1895c50f16f689338b973b1e4fc6b3ba3781111 100644
--- a/make/sun/font/FILES_c.gmk
+++ b/make/sun/font/FILES_c.gmk
@@ -106,7 +106,21 @@ FILES_cpp_shared = \
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 --git a/src/macosx/classes/sun/lwawt/LWWindowPeer.java b/src/macosx/classes/sun/lwawt/LWWindowPeer.java
index d50335f7cd5d9860e43aa05a02fb1c101e01e900..0a789c415b36115572387883245caef79c83592b 100644
--- a/src/macosx/classes/sun/lwawt/LWWindowPeer.java
+++ b/src/macosx/classes/sun/lwawt/LWWindowPeer.java
@@ -170,7 +170,7 @@ public class LWWindowPeer
setTitle(((Dialog) getTarget()).getTitle());
}
- setAlwaysOnTop(getTarget().isAlwaysOnTop());
+ updateAlwaysOnTopState();
updateMinimumSize();
final Shape shape = getTarget().getShape();
@@ -357,8 +357,8 @@ public class LWWindowPeer
}
@Override
- public void setAlwaysOnTop(boolean value) {
- platformWindow.setAlwaysOnTop(value);
+ public void updateAlwaysOnTopState() {
+ platformWindow.setAlwaysOnTop(getTarget().isAlwaysOnTop());
}
@Override
diff --git a/src/macosx/classes/sun/lwawt/macosx/CFileDialog.java b/src/macosx/classes/sun/lwawt/macosx/CFileDialog.java
index 359f606636409720b563612b4a81b73afdf21317..29129394a379935cd00eeba4b0cd151dd762e685 100644
--- a/src/macosx/classes/sun/lwawt/macosx/CFileDialog.java
+++ b/src/macosx/classes/sun/lwawt/macosx/CFileDialog.java
@@ -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 @@ class CFileDialog implements FileDialogPeer {
}
@Override
- public void setAlwaysOnTop(boolean alwaysOnTop) {
+ public void updateAlwaysOnTopState() {
}
@Override
diff --git a/src/macosx/classes/sun/lwawt/macosx/CPrinterDialogPeer.java b/src/macosx/classes/sun/lwawt/macosx/CPrinterDialogPeer.java
index 1ca65e7faae4fd88163110be6f955547ebb92b67..8dfe7e1e51e9fb0c0fb94bf8035d45ec72678fed 100644
--- a/src/macosx/classes/sun/lwawt/macosx/CPrinterDialogPeer.java
+++ b/src/macosx/classes/sun/lwawt/macosx/CPrinterDialogPeer.java
@@ -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 @@ public class CPrinterDialogPeer extends LWWindowPeer {
}
// 1.6 peer method
- public void setAlwaysOnTop(boolean value) {
+ public void updateAlwaysOnTopState() {
// no-op, since we just show the native print dialog
}
diff --git a/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java b/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java
index 219f5bf5873199c768a984f68d00ff455754ec71..d69200c1408a859ea38aadab94bd991c0f91eeb2 100644
--- a/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java
+++ b/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java
@@ -243,12 +243,17 @@ public class JPEGImageReader extends ImageReader {
* 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 @@ public class JPEGImageReader extends ImageReader {
* 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 @@ public class JPEGImageReader extends ImageReader {
{
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 class JPEGImageReader extends ImageReader {
public int getNumImages(boolean allowSearch) throws IOException {
setThreadLock();
try { // locked thread
+ cbLock.check();
+
return getNumImagesOnThread(allowSearch);
} finally {
clearThreadLock();
@@ -536,8 +585,13 @@ public class JPEGImageReader extends ImageReader {
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 @@ public class JPEGImageReader extends ImageReader {
* 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 @@ public class JPEGImageReader extends ImageReader {
setThreadLock();
try {
if (currentImage != imageIndex) {
+ cbLock.check();
readHeader(imageIndex, true);
}
return width;
@@ -665,6 +725,7 @@ public class JPEGImageReader extends ImageReader {
setThreadLock();
try {
if (currentImage != imageIndex) {
+ cbLock.check();
readHeader(imageIndex, true);
}
return height;
@@ -693,6 +754,8 @@ public class JPEGImageReader extends ImageReader {
setThreadLock();
try {
if (currentImage != imageIndex) {
+ cbLock.check();
+
readHeader(imageIndex, true);
}
@@ -716,6 +779,7 @@ public class JPEGImageReader extends ImageReader {
private Iterator getImageTypesOnThread(int imageIndex)
throws IOException {
if (currentImage != imageIndex) {
+ cbLock.check();
readHeader(imageIndex, true);
}
@@ -931,6 +995,7 @@ public class JPEGImageReader extends ImageReader {
setThreadLock();
try {
if (!tablesOnlyChecked) {
+ cbLock.check();
checkTablesOnly();
}
return streamMetadata;
@@ -951,6 +1016,8 @@ public class JPEGImageReader extends ImageReader {
return imageMetadata;
}
+ cbLock.check();
+
gotoImage(imageIndex);
imageMetadata = new JPEGMetadata(false, false, iis, this);
@@ -967,6 +1034,7 @@ public class JPEGImageReader extends ImageReader {
throws IOException {
setThreadLock();
try {
+ cbLock.check();
try {
readInternal(imageIndex, param, false);
} catch (RuntimeException e) {
@@ -1196,58 +1264,63 @@ public class JPEGImageReader extends ImageReader {
}
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));
- } 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(" ");
+ 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);
}
- processImageProgress(percentToDate*100.0F);
}
+ } else {
+ processImageProgress(percentOfPass * 100.0F);
}
- } else {
- processImageProgress(percentOfPass * 100.0F);
}
+ } finally {
+ cbLock.unlock();
}
}
@@ -1260,33 +1333,58 @@ public class JPEGImageReader extends ImageReader {
}
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 class JPEGImageReader extends ImageReader {
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 @@ public class JPEGImageReader extends ImageReader {
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 class JPEGImageReader extends ImageReader {
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 @@ public class JPEGImageReader extends ImageReader {
throws IOException {
setThreadLock();
try {
+ cbLock.check();
+
if ((thumbnailIndex < 0)
|| (thumbnailIndex >= getNumThumbnails(imageIndex))) {
throw new IndexOutOfBoundsException("No such thumbnail");
@@ -1409,6 +1517,8 @@ public class JPEGImageReader extends ImageReader {
throws IOException {
setThreadLock();
try {
+ cbLock.check();
+
if ((thumbnailIndex < 0)
|| (thumbnailIndex >= getNumThumbnails(imageIndex))) {
throw new IndexOutOfBoundsException("No such thumbnail");
@@ -1428,6 +1538,8 @@ public class JPEGImageReader extends ImageReader {
throws IOException {
setThreadLock();
try {
+ cbLock.check();
+
if ((thumbnailIndex < 0)
|| (thumbnailIndex >= getNumThumbnails(imageIndex))) {
throw new IndexOutOfBoundsException("No such thumbnail");
@@ -1468,6 +1580,7 @@ public class JPEGImageReader extends ImageReader {
public void reset() {
setThreadLock();
try {
+ cbLock.check();
super.reset();
} finally {
clearThreadLock();
@@ -1479,6 +1592,8 @@ public class JPEGImageReader extends ImageReader {
public void dispose() {
setThreadLock();
try {
+ cbLock.check();
+
if (structPointer != 0) {
disposerRecord.dispose();
structPointer = 0;
@@ -1540,6 +1655,36 @@ public class JPEGImageReader extends ImageReader {
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 --git a/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriter.java b/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriter.java
index bc8d435d464442e75d9018916e21c777ce74b4d7..b8564176df85e9fdf0b6bc6e26d972215214ac35 100644
--- a/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriter.java
+++ b/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriter.java
@@ -183,8 +183,7 @@ public class JPEGImageWriter extends ImageWriter {
return null;
}
});
- initWriterIDs(ImageOutputStream.class,
- JPEGQTable.class,
+ initWriterIDs(JPEGQTable.class,
JPEGHuffmanTable.class);
}
@@ -200,11 +199,13 @@ public class JPEGImageWriter extends ImageWriter {
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 @@ public class JPEGImageWriter extends ImageWriter {
ImageWriteParam param) throws IOException {
setThreadLock();
try {
+ cbLock.check();
+
writeOnThread(streamMetadata, image, param);
} finally {
clearThreadLock();
@@ -1082,13 +1085,18 @@ public class JPEGImageWriter extends ImageWriter {
haveMetadata,
restartInterval);
- if (aborted) {
- processWriteAborted();
- } else {
- processImageComplete();
- }
+ cbLock.lock();
+ try {
+ if (aborted) {
+ processWriteAborted();
+ } else {
+ processImageComplete();
+ }
- ios.flush();
+ ios.flush();
+ } finally {
+ cbLock.unlock();
+ }
currentImage++; // After a successful write
}
@@ -1096,6 +1104,8 @@ public class JPEGImageWriter extends ImageWriter {
throws IOException {
setThreadLock();
try {
+ cbLock.check();
+
prepareWriteSequenceOnThread(streamMetadata);
} finally {
clearThreadLock();
@@ -1175,6 +1185,8 @@ public class JPEGImageWriter extends ImageWriter {
throws IOException {
setThreadLock();
try {
+ cbLock.check();
+
if (sequencePrepared == false) {
throw new IllegalStateException("sequencePrepared not called!");
}
@@ -1188,6 +1200,8 @@ public class JPEGImageWriter extends ImageWriter {
public void endWriteSequence() throws IOException {
setThreadLock();
try {
+ cbLock.check();
+
if (sequencePrepared == false) {
throw new IllegalStateException("sequencePrepared not called!");
}
@@ -1200,6 +1214,10 @@ public class JPEGImageWriter extends ImageWriter {
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 class JPEGImageWriter extends ImageWriter {
public void reset() {
setThreadLock();
try {
+ cbLock.check();
+
super.reset();
} finally {
clearThreadLock();
@@ -1232,6 +1252,8 @@ public class JPEGImageWriter extends ImageWriter {
public void dispose() {
setThreadLock();
try {
+ cbLock.check();
+
if (structPointer != 0) {
disposerRecord.dispose();
structPointer = 0;
@@ -1251,13 +1273,18 @@ public class JPEGImageWriter extends ImageWriter {
* 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 @@ public class JPEGImageWriter extends ImageWriter {
* 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 @@ public class JPEGImageWriter extends ImageWriter {
////////////// 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 @@ public class JPEGImageWriter extends ImageWriter {
}
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 @@ public class JPEGImageWriter extends ImageWriter {
}
}
+ /**
+ * 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 @@ public class JPEGImageWriter extends ImageWriter {
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 --git a/src/share/classes/com/sun/jmx/mbeanserver/MBeanInstantiator.java b/src/share/classes/com/sun/jmx/mbeanserver/MBeanInstantiator.java
index ab62660be493f71bbb03ea66efce2b068d11bc00..1adb4dd937350da2e134ba84fc04c74f7413562a 100644
--- a/src/share/classes/com/sun/jmx/mbeanserver/MBeanInstantiator.java
+++ b/src/share/classes/com/sun/jmx/mbeanserver/MBeanInstantiator.java
@@ -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.IOException;
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 @@ public class MBeanInstantiator {
Object moi;
-
// ------------------------------
// ------------------------------
Constructor> cons = findConstructor(theClass, null);
@@ -224,6 +224,7 @@ public class MBeanInstantiator {
// Instantiate the new object
try {
ReflectUtil.checkPackageAccess(theClass);
+ ensureClassAccess(theClass);
moi= cons.newInstance();
} catch (InvocationTargetException e) {
// Wrap the exception.
@@ -270,7 +271,6 @@ public class MBeanInstantiator {
checkMBeanPermission(theClass, null, null, "instantiate");
// Instantiate the new object
-
// ------------------------------
// ------------------------------
final Class>[] tab;
@@ -300,6 +300,7 @@ public class MBeanInstantiator {
}
try {
ReflectUtil.checkPackageAccess(theClass);
+ ensureClassAccess(theClass);
moi = cons.newInstance(params);
}
catch (NoSuchMethodError error) {
@@ -741,4 +742,13 @@ public class MBeanInstantiator {
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 --git a/src/share/classes/com/sun/media/sound/AbstractMidiDevice.java b/src/share/classes/com/sun/media/sound/AbstractMidiDevice.java
index a0f06c3ed07f0410a04e3a18410c42e1e68acdb9..dacefba8f4955a8eeeddcbc0b17fa87473fbee5a 100644
--- a/src/share/classes/com/sun/media/sound/AbstractMidiDevice.java
+++ b/src/share/classes/com/sun/media/sound/AbstractMidiDevice.java
@@ -56,7 +56,7 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
// 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 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
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 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
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 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
AbstractMidiDevice.this.closeInternal(this);
}
- public MidiDevice getMidiDevice() {
+ @Override
+ public final MidiDevice getMidiDevice() {
return AbstractMidiDevice.this;
}
- protected boolean isOpen() {
+ final boolean isOpen() {
return open;
}
diff --git a/src/share/classes/com/sun/media/sound/FastShortMessage.java b/src/share/classes/com/sun/media/sound/FastShortMessage.java
index b4ca9c82ce88ac9478f843acc517353cb65b06a5..39f85da154ce9f4ed74ec2e21eb7522b60d9f7c3 100644
--- a/src/share/classes/com/sun/media/sound/FastShortMessage.java
+++ b/src/share/classes/com/sun/media/sound/FastShortMessage.java
@@ -32,7 +32,7 @@ import javax.sound.midi.*;
*
* @author Florian Bomers
*/
-class FastShortMessage extends ShortMessage {
+final class FastShortMessage extends ShortMessage {
private int packedMsg;
public FastShortMessage(int packedMsg) throws InvalidMidiDataException {
diff --git a/src/share/classes/com/sun/media/sound/FastSysexMessage.java b/src/share/classes/com/sun/media/sound/FastSysexMessage.java
index d00ec68aa63e4262edcd9f5351cb20592c1fc999..7f2e2def2ee0b1886705157cfa5d7a450003e880 100644
--- a/src/share/classes/com/sun/media/sound/FastSysexMessage.java
+++ b/src/share/classes/com/sun/media/sound/FastSysexMessage.java
@@ -32,7 +32,7 @@ import javax.sound.midi.*;
*
* @author Florian Bomers
*/
-class FastSysexMessage extends SysexMessage {
+final class FastSysexMessage extends SysexMessage {
FastSysexMessage(byte[] data) throws InvalidMidiDataException {
super(data);
diff --git a/src/share/classes/com/sun/media/sound/MidiOutDevice.java b/src/share/classes/com/sun/media/sound/MidiOutDevice.java
index e1ada68a80eaffb31cd8c66305ef4ec45f066fd2..a9193005e5fa240b84a4b39e4d6f41ac539f65e0 100644
--- a/src/share/classes/com/sun/media/sound/MidiOutDevice.java
+++ b/src/share/classes/com/sun/media/sound/MidiOutDevice.java
@@ -103,9 +103,9 @@ class MidiOutDevice extends AbstractMidiDevice {
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 @@ class MidiOutDevice extends AbstractMidiDevice {
}
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 --git a/src/share/classes/com/sun/media/sound/RealTimeSequencer.java b/src/share/classes/com/sun/media/sound/RealTimeSequencer.java
index 8b4ae6e7ad13a4b1614f4fd9972b1b1eff4016ff..93b7b0612eb2831f683e551adfb998a1eda87c9f 100644
--- a/src/share/classes/com/sun/media/sound/RealTimeSequencer.java
+++ b/src/share/classes/com/sun/media/sound/RealTimeSequencer.java
@@ -1026,7 +1026,7 @@ class RealTimeSequencer extends AbstractMidiDevice implements Sequencer, AutoCon
class SequencerReceiver extends AbstractReceiver {
- protected void implSend(MidiMessage message, long timeStamp) {
+ void implSend(MidiMessage message, long timeStamp) {
if (recording) {
long tickPos = 0;
diff --git a/src/share/classes/java/awt/Window.java b/src/share/classes/java/awt/Window.java
index 68b9af95a96cda281c7bdca34719da31969f5457..89270e27df11b7c5265d66e68e9ecab30fef1172 100644
--- a/src/share/classes/java/awt/Window.java
+++ b/src/share/classes/java/awt/Window.java
@@ -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 @@ public class Window extends Container implements Accessible {
WindowPeer peer = (WindowPeer)this.peer;
synchronized(getTreeLock()) {
if (peer != null) {
- peer.setAlwaysOnTop(alwaysOnTop);
+ peer.updateAlwaysOnTopState();
}
}
}
diff --git a/src/share/classes/java/awt/peer/WindowPeer.java b/src/share/classes/java/awt/peer/WindowPeer.java
index fca78b7eed42944dd73e2dbb865b898a885e0ba9..b44bfa00da90005267dac0ab64ee5b95615d7ead 100644
--- a/src/share/classes/java/awt/peer/WindowPeer.java
+++ b/src/share/classes/java/awt/peer/WindowPeer.java
@@ -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 @@ public interface WindowPeer extends ContainerPeer {
void toBack();
/**
- * 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
+ * Updates the window's always-on-top state.
+ * Sets 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 --git a/src/share/classes/java/beans/ThreadGroupContext.java b/src/share/classes/java/beans/ThreadGroupContext.java
index dc1d38a1457705a695c4f19e49b9824efbf66fa8..6236ec2b38c1a0f2ede2b6c580a0c8e8e2f67bad 100644
--- a/src/share/classes/java/beans/ThreadGroupContext.java
+++ b/src/share/classes/java/beans/ThreadGroupContext.java
@@ -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.BeanInfoFinder;
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 @@ import java.util.WeakHashMap;
*/
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 @@ final class ThreadGroupContext {
private BeanInfoFinder beanInfoFinder;
private PropertyEditorFinder propertyEditorFinder;
+ private ThreadGroupContext() {
+ }
boolean isDesignTime() {
return this.isDesignTime;
diff --git a/src/share/classes/java/beans/WeakIdentityMap.java b/src/share/classes/java/beans/WeakIdentityMap.java
new file mode 100644
index 0000000000000000000000000000000000000000..42ac821a3928e4f97c844e25256951052bf89584
--- /dev/null
+++ b/src/share/classes/java/beans/WeakIdentityMap.java
@@ -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