提交 84887128 编写于 作者: A asaha

Merge

......@@ -279,3 +279,4 @@ e291ac47c9a90366c3c0787a6f7ce547a2bda308 jdk8-b131
1ecfc0fac3e7b931f09728b7594384ea5b5f9f0f jdk8u20-b06
db30cb9eb18dacea39c35daf15a3ee5fea41fd86 jdk8u20-b07
0e717bd55bc9e3f3fa3432e545944d81ed887ab0 jdk8u20-b08
bfcdcc29c8823595a5d70b5b633bedcd5ee3ba8e jdk8u20-b09
......@@ -295,14 +295,8 @@ public class AquaIcon {
}
Image createImage() {
int w = getIconWidth();
int h = getIconHeight();
return new AquaImageFactory.MultiResolutionIconImage(
AquaUtils.getCImageCreator().createSystemImageFromSelector(
selector, w, h),
AquaUtils.getCImageCreator().createSystemImageFromSelector(
selector, 2 * w, 2 * h)
);
return AquaUtils.getCImageCreator().createSystemImageFromSelector(
selector, getIconWidth(), getIconHeight());
}
}
}
......@@ -125,16 +125,14 @@ public class AquaImageFactory {
private static final int kAlertIconSize = 64;
static IconUIResource getAppIconCompositedOn(final Image background) {
final BufferedImage iconImage = getAppIconImageCompositedOn(background, 1);
if (background instanceof MultiResolutionIconImage) {
BufferedImage background2x
= ((MultiResolutionIconImage) background).resolutionVariant;
BufferedImage icon2xImage = getAppIconImageCompositedOn(background2x, 2);
return new IconUIResource(new ImageIcon(
new MultiResolutionIconImage(iconImage, icon2xImage)));
if (background instanceof MultiResolutionBufferedImage) {
int width = background.getWidth(null);
Image mrIconImage = ((MultiResolutionBufferedImage) background).map(
rv -> getAppIconImageCompositedOn(rv, rv.getWidth(null) / width));
return new IconUIResource(new ImageIcon(mrIconImage));
}
BufferedImage iconImage = getAppIconImageCompositedOn(background, 1);
return new IconUIResource(new ImageIcon(iconImage));
}
......@@ -312,10 +310,16 @@ public class AquaImageFactory {
return icon;
}
Image icon2x = AquaUtils.getCImageCreator().createImageFromName(
imageName, 2 * icon.getWidth(null), 2 * icon.getHeight(null));
return new MultiResolutionBufferedImage(
BufferedImage.TYPE_INT_ARGB_PRE, 0, icon, icon2x);
int w = icon.getWidth(null);
int h = icon.getHeight(null);
Dimension[] sizes = new Dimension[]{
new Dimension(w, h), new Dimension(2 * w, 2 * h)
};
return new MultiResolutionBufferedImage(icon, sizes, (width, height) ->
AquaUtils.getCImageCreator().createImageFromName(
imageName, width, height));
}
public static class NineSliceMetrics {
......@@ -524,29 +528,4 @@ public class AquaImageFactory {
public static Color getSelectionInactiveForegroundColorUIResource() {
return new SystemColorProxy(LWCToolkit.getAppleColor(LWCToolkit.INACTIVE_SELECTION_FOREGROUND_COLOR));
}
static class MultiResolutionIconImage extends BufferedImage
implements MultiResolutionImage {
BufferedImage resolutionVariant;
public MultiResolutionIconImage(BufferedImage image, BufferedImage resolutionVariant) {
super(image.getWidth(), image.getHeight(), image.getType());
this.resolutionVariant = resolutionVariant;
Graphics g = getGraphics();
g.drawImage(image, 0, 0, null);
g.dispose();
}
@Override
public Image getResolutionVariant(int width, int height) {
return ((width <= getWidth() && height <= getHeight()))
? this : resolutionVariant;
}
@Override
public List<Image> getResolutionVariants() {
return Arrays.asList(this, resolutionVariant);
}
}
}
}
\ No newline at end of file
......@@ -38,6 +38,7 @@ import sun.java2d.*;
import sun.print.*;
import apple.laf.*;
import apple.laf.JRSUIUtils.NineSliceMetricsProvider;
import sun.awt.image.ImageCache;
abstract class AquaPainter <T extends JRSUIState> {
static <T extends JRSUIState> AquaPainter<T> create(final T state) {
......@@ -155,10 +156,15 @@ abstract class AquaPainter <T extends JRSUIState> {
final ImageCache cache = ImageCache.getInstance();
final int imgW = bounds.width * scale;
final int imgH = bounds.height * scale;
BufferedImage img = (BufferedImage) cache.getImage(config, imgW, imgH, scale, controlState);
AquaPixelsKey key = new AquaPixelsKey(config,
imgW, imgH, scale, controlState);
BufferedImage img = (BufferedImage) cache.getImage(key);
if (img == null) {
img = new BufferedImage(imgW, imgH, BufferedImage.TYPE_INT_ARGB_PRE);
cache.setImage(img, config, imgW, imgH, scale, controlState);
if (!controlState.is(JRSUIConstants.Animating.YES)) {
cache.setImage(key, img);
}
final WritableRaster raster = img.getRaster();
final DataBufferInt buffer = (DataBufferInt) raster.getDataBuffer();
......@@ -172,6 +178,59 @@ abstract class AquaPainter <T extends JRSUIState> {
}
}
private static class AquaPixelsKey implements ImageCache.PixelsKey {
private final int pixelCount;
private final int hash;
// key parts
private final GraphicsConfiguration config;
private final int w;
private final int h;
private final int scale;
private final JRSUIState state;
AquaPixelsKey(final GraphicsConfiguration config,
final int w, final int h, final int scale,
final JRSUIState state) {
this.pixelCount = w * h;
this.config = config;
this.w = w;
this.h = h;
this.scale = scale;
this.state = state;
this.hash = hash();
}
public int getPixelCount() {
return pixelCount;
}
private int hash() {
int hash = config != null ? config.hashCode() : 0;
hash = 31 * hash + w;
hash = 31 * hash + h;
hash = 31 * hash + scale;
hash = 31 * hash + state.hashCode();
return hash;
}
@Override
public int hashCode() {
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj instanceof AquaPixelsKey) {
AquaPixelsKey key = (AquaPixelsKey) obj;
return config == key.config && w == key.w && h == key.h
&& scale == key.scale && state.equals(key.state);
}
return false;
}
}
private static class RecyclableJRSUISlicedImageControl
extends RecyclableSlicedImageControl {
......
......@@ -177,16 +177,7 @@ final class AquaUtils {
abstract static class RecyclableSingleton<T> {
final T get() {
final AppContext appContext = AppContext.getAppContext();
SoftReference<T> ref = (SoftReference<T>) appContext.get(this);
if (ref != null) {
final T object = ref.get();
if (object != null) return object;
}
final T object = getInstance();
ref = new SoftReference<T>(object);
appContext.put(this, ref);
return object;
return AppContext.getSoftReferenceValue(this, () -> getInstance());
}
void reset() {
......
......@@ -32,6 +32,7 @@ import java.awt.image.*;
import java.util.Arrays;
import java.util.List;
import sun.awt.image.MultiResolutionImage;
import sun.awt.image.MultiResolutionBufferedImage;
import sun.awt.image.SunWritableRaster;
......@@ -42,10 +43,11 @@ public class CImage extends CFRetainedResource {
private static native long nativeCreateNSImageOfFileFromLaunchServices(String file);
private static native long nativeCreateNSImageFromImageName(String name);
private static native long nativeCreateNSImageFromIconSelector(int selector);
private static native void nativeCopyNSImageIntoArray(long image, int[] buffer, int w, int h);
private static native void nativeCopyNSImageIntoArray(long image, int[] buffer, int sw, int sh, int dw, int dh);
private static native Dimension2D nativeGetNSImageSize(long image);
private static native void nativeSetNSImageSize(long image, double w, double h);
private static native void nativeResizeNSImageRepresentations(long image, double w, double h);
private static native Dimension2D[] nativeGetNSImageRepresentationSizes(long image, double w, double h);
static Creator creator = new Creator();
static Creator getCreator() {
......@@ -210,18 +212,30 @@ public class CImage extends CFRetainedResource {
super(nsImagePtr, true);
}
/** @return A BufferedImage created from nsImagePtr, or null. */
public BufferedImage toImage() {
/** @return A MultiResolution image created from nsImagePtr, or null. */
private BufferedImage toImage() {
if (ptr == 0) return null;
final Dimension2D size = nativeGetNSImageSize(ptr);
final int w = (int)size.getWidth();
final int h = (int)size.getHeight();
final BufferedImage bimg = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB_PRE);
Dimension2D[] sizes
= nativeGetNSImageRepresentationSizes(ptr,
size.getWidth(), size.getHeight());
BufferedImage baseImage = toImage(w, h, w, h);
return sizes == null || sizes.length < 2 ? baseImage
: new MultiResolutionBufferedImage(baseImage, sizes,
(width, height) -> toImage(w, h, width, height));
}
private BufferedImage toImage(int srcWidth, int srcHeight, int dstWidth, int dstHeight) {
final BufferedImage bimg = new BufferedImage(dstWidth, dstHeight, BufferedImage.TYPE_INT_ARGB_PRE);
final DataBufferInt dbi = (DataBufferInt)bimg.getRaster().getDataBuffer();
final int[] buffer = SunWritableRaster.stealData(dbi, 0);
nativeCopyNSImageIntoArray(ptr, buffer, w, h);
nativeCopyNSImageIntoArray(ptr, buffer, srcWidth, srcHeight, dstWidth, dstHeight);
SunWritableRaster.markDirty(dbi);
return bimg;
}
......
......@@ -41,7 +41,7 @@ import javax.print.attribute.standard.PageRanges;
import sun.java2d.*;
import sun.print.*;
final class CPrinterJob extends RasterPrinterJob {
public final class CPrinterJob extends RasterPrinterJob {
// NOTE: This uses RasterPrinterJob as a base, but it doesn't use
// all of the RasterPrinterJob functions. RasterPrinterJob will
// break down printing to pieces that aren't necessary under MacOSX
......
......@@ -762,6 +762,10 @@ AWT_ASSERT_APPKIT_THREAD;
return lastKeyWindow;
}
- (BOOL)windowShouldZoom:(NSWindow *)window toFrame:(NSRect)newFrame {
return !NSEqualSizes(self.nsWindow.frame.size, newFrame.size);
}
@end // AWTWindow
......
......@@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
#import "jni_util.h"
#import <Cocoa/Cocoa.h>
#import <JavaNativeFoundation/JavaNativeFoundation.h>
......@@ -52,18 +53,21 @@ static void CImage_CopyArrayIntoNSImageRep
}
static void CImage_CopyNSImageIntoArray
(NSImage *srcImage, jint *dstPixels, int width, int height)
(NSImage *srcImage, jint *dstPixels, NSRect fromRect, NSRect toRect)
{
int width = toRect.size.width;
int height = toRect.size.height;
CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();
CGContextRef cgRef = CGBitmapContextCreate(dstPixels, width, height, 8, width * 4, colorspace, kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host);
CGContextRef cgRef = CGBitmapContextCreate(dstPixels, width, height,
8, width * 4, colorspace,
kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host);
CGColorSpaceRelease(colorspace);
NSGraphicsContext *context = [NSGraphicsContext graphicsContextWithGraphicsPort:cgRef flipped:NO];
CGContextRelease(cgRef);
NSGraphicsContext *oldContext = [[NSGraphicsContext currentContext] retain];
[NSGraphicsContext setCurrentContext:context];
NSRect rect = NSMakeRect(0, 0, width, height);
[srcImage drawInRect:rect
fromRect:rect
[srcImage drawInRect:toRect
fromRect:fromRect
operation:NSCompositeSourceOver
fraction:1.0];
[NSGraphicsContext setCurrentContext:oldContext];
......@@ -266,17 +270,20 @@ JNF_COCOA_EXIT(env);
/*
* Class: sun_lwawt_macosx_CImage
* Method: nativeCopyNSImageIntoArray
* Signature: (J[III)V
* Signature: (J[IIIII)V
*/
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CImage_nativeCopyNSImageIntoArray
(JNIEnv *env, jclass klass, jlong nsImgPtr, jintArray buffer, jint w, jint h)
(JNIEnv *env, jclass klass, jlong nsImgPtr, jintArray buffer, jint sw, jint sh,
jint dw, jint dh)
{
JNF_COCOA_ENTER(env);
NSImage *img = (NSImage *)jlong_to_ptr(nsImgPtr);
jint *dst = (*env)->GetPrimitiveArrayCritical(env, buffer, NULL);
if (dst) {
CImage_CopyNSImageIntoArray(img, dst, w, h);
NSRect fromRect = NSMakeRect(0, 0, sw, sh);
NSRect toRect = NSMakeRect(0, 0, dw, dh);
CImage_CopyNSImageIntoArray(img, dst, fromRect, toRect);
(*env)->ReleasePrimitiveArrayCritical(env, buffer, dst, JNI_ABORT);
}
......@@ -343,3 +350,87 @@ JNF_COCOA_ENTER(env);
JNF_COCOA_EXIT(env);
}
NSComparisonResult getOrder(BOOL order){
return (NSComparisonResult) (order ? NSOrderedAscending : NSOrderedDescending);
}
/*
* Class: sun_lwawt_macosx_CImage
* Method: nativeGetNSImageRepresentationsCount
* Signature: (JDD)[Ljava/awt/geom/Dimension2D;
*/
JNIEXPORT jobjectArray JNICALL
Java_sun_lwawt_macosx_CImage_nativeGetNSImageRepresentationSizes
(JNIEnv *env, jclass clazz, jlong image, jdouble w, jdouble h)
{
if (!image) return NULL;
jobjectArray jreturnArray = NULL;
NSImage *img = (NSImage *)jlong_to_ptr(image);
JNF_COCOA_ENTER(env);
NSArray *imageRepresentations = [img representations];
if([imageRepresentations count] == 0){
return NULL;
}
NSArray *sortedImageRepresentations = [imageRepresentations
sortedArrayUsingComparator: ^(id obj1, id obj2) {
NSImageRep *imageRep1 = (NSImageRep *) obj1;
NSImageRep *imageRep2 = (NSImageRep *) obj2;
NSSize size1 = [imageRep1 size];
NSSize size2 = [imageRep2 size];
if (NSEqualSizes(size1, size2)) {
return getOrder([imageRep1 pixelsWide] <= [imageRep2 pixelsWide] &&
[imageRep1 pixelsHigh] <= [imageRep2 pixelsHigh]);
}
return getOrder(size1.width <= size2.width && size1.height <= size2.height);
}];
NSMutableArray *sortedPixelSizes = [[[NSMutableArray alloc] init] autorelease];
NSSize lastSize = [[sortedImageRepresentations lastObject] size];
NSUInteger i = [sortedImageRepresentations indexOfObjectPassingTest:
^BOOL(id obj, NSUInteger idx, BOOL *stop) {
NSSize imageRepSize = [obj size];
return (w <= imageRepSize.width && h <= imageRepSize.height)
|| NSEqualSizes(imageRepSize, lastSize);
}];
NSUInteger count = [sortedImageRepresentations count];
i = (i == NSNotFound) ? count - 1 : i;
NSSize bestFitSize = [[sortedImageRepresentations objectAtIndex: i] size];
for(; i < count; i++){
NSImageRep *imageRep = [sortedImageRepresentations objectAtIndex: i];
if (!NSEqualSizes([imageRep size], bestFitSize)) {
break;
}
NSSize pixelSize = NSMakeSize(
[imageRep pixelsWide], [imageRep pixelsHigh]);
[sortedPixelSizes addObject: [NSValue valueWithSize: pixelSize]];
}
count = [sortedPixelSizes count];
static JNF_CLASS_CACHE(jc_Dimension, "java/awt/Dimension");
jreturnArray = JNFNewObjectArray(env, &jc_Dimension, count);
CHECK_NULL_RETURN(jreturnArray, NULL);
for(i = 0; i < count; i++){
NSSize pixelSize = [[sortedPixelSizes objectAtIndex: i] sizeValue];
(*env)->SetObjectArrayElement(env, jreturnArray, i,
NSToJavaSize(env, pixelSize));
JNU_CHECK_EXCEPTION_RETURN(env, NULL);
}
JNF_COCOA_EXIT(env);
return jreturnArray;
}
\ No newline at end of file
......@@ -147,7 +147,7 @@ void JavaCT_DrawGlyphVector
CGAffineTransform invTx = CGAffineTransformInvert(strike->fTx);
NSUInteger i;
NSInteger i;
for (i = 0; i < length; i++)
{
CGGlyph glyph = glyphs[i];
......@@ -355,19 +355,31 @@ static inline void doDrawGlyphsPipe_checkForPerGlyphTransforms
static JNF_CLASS_CACHE(jc_StandardGlyphVector_GlyphTransformInfo, "sun/font/StandardGlyphVector$GlyphTransformInfo");
static JNF_MEMBER_CACHE(jm_StandardGlyphVector_GlyphTransformInfo_transforms, jc_StandardGlyphVector_GlyphTransformInfo, "transforms", "[D");
jdoubleArray g_gtiTransformsArray = JNFGetObjectField(env, gti, jm_StandardGlyphVector_GlyphTransformInfo_transforms); //(*env)->GetObjectField(env, gti, g_gtiTransforms);
if (g_gtiTransformsArray == NULL) {
return;
}
jdouble *g_gvTransformsAsDoubles = (*env)->GetPrimitiveArrayCritical(env, g_gtiTransformsArray, NULL);
if (g_gvTransformsAsDoubles == NULL) {
(*env)->DeleteLocalRef(env, g_gtiTransformsArray);
return;
}
static JNF_MEMBER_CACHE(jm_StandardGlyphVector_GlyphTransformInfo_indices, jc_StandardGlyphVector_GlyphTransformInfo, "indices", "[I");
jintArray g_gtiTXIndicesArray = JNFGetObjectField(env, gti, jm_StandardGlyphVector_GlyphTransformInfo_indices);
jint *g_gvTXIndicesAsInts = (*env)->GetPrimitiveArrayCritical(env, g_gtiTXIndicesArray, NULL);
if (g_gvTXIndicesAsInts == NULL) {
(*env)->ReleasePrimitiveArrayCritical(env, g_gtiTransformsArray, g_gvTransformsAsDoubles, JNI_ABORT);
(*env)->DeleteLocalRef(env, g_gtiTransformsArray);
(*env)->DeleteLocalRef(env, g_gtiTXIndicesArray);
return;
}
// slowest case, we have per-glyph transforms, and possibly glyph substitution as well
JavaCT_DrawGlyphVector(qsdo, strike, useSubstituion, uniChars, glyphs, advances, g_gvTXIndicesAsInts, g_gvTransformsAsDoubles, length);
(*env)->ReleasePrimitiveArrayCritical(env, g_gtiTransformsArray, g_gvTransformsAsDoubles, JNI_ABORT);
(*env)->DeleteLocalRef(env, g_gtiTransformsArray);
(*env)->ReleasePrimitiveArrayCritical(env, g_gtiTXIndicesArray, g_gvTXIndicesAsInts, JNI_ABORT);
(*env)->DeleteLocalRef(env, g_gtiTransformsArray);
(*env)->DeleteLocalRef(env, g_gtiTXIndicesArray);
}
......@@ -403,6 +415,9 @@ static inline void doDrawGlyphsPipe_fillGlyphAndAdvanceBuffers
{
// fill the glyph buffer
jint *glyphsAsInts = (*env)->GetPrimitiveArrayCritical(env, glyphsArray, NULL);
if (glyphsAsInts == NULL) {
return;
}
// if a glyph code from Java is negative, that means it is really a unicode value
// which we can use in CoreText to strike the character in another font
......@@ -429,11 +444,15 @@ static inline void doDrawGlyphsPipe_fillGlyphAndAdvanceBuffers
// fill the advance buffer
static JNF_MEMBER_CACHE(jm_StandardGlyphVector_positions, jc_StandardGlyphVector, "positions", "[F");
jfloatArray posArray = JNFGetObjectField(env, gVector, jm_StandardGlyphVector_positions);
if (posArray != NULL)
{
jfloat *positions = NULL;
if (posArray != NULL) {
// in this case, the positions have already been pre-calculated for us on the Java side
jfloat *positions = (*env)->GetPrimitiveArrayCritical(env, posArray, NULL);
positions = (*env)->GetPrimitiveArrayCritical(env, posArray, NULL);
if (positions == NULL) {
(*env)->DeleteLocalRef(env, posArray);
}
}
if (positions != NULL) {
CGPoint prev;
prev.x = positions[0];
prev.y = positions[1];
......
......@@ -849,7 +849,7 @@ PRINT(" copyARGB_PRE_bitToIndexed_8bit")
indexOfBest = 0;
distanceOfBest = DBL_MAX;
for (i=0; i<lutDataSize; i++)
for (i=0; (unsigned)i<lutDataSize; i++)
{
p2 = lutdata[i];
......@@ -899,7 +899,7 @@ static void releaseDataFromProvider(void *info, const void *data, size_t size)
{
if (data != NULL)
{
free(data);
free((void*)data);
}
}
......@@ -1577,7 +1577,9 @@ JNIEXPORT jobject JNICALL Java_sun_awt_image_BufImgSurfaceData_getSurfaceData
{
static char *bimgName = "java/awt/image/BufferedImage";
jclass bimg = (*env)->FindClass(env, bimgName);
CHECK_NULL_RETURN(bimg, NULL);
sDataID = (*env)->GetFieldID(env, bimg, "sData", "Lsun/java2d/SurfaceData;");
CHECK_NULL_RETURN(sDataID, NULL);
}
return (*env)->GetObjectField(env, bufImg, sDataID);
......@@ -1591,7 +1593,9 @@ JNIEXPORT void JNICALL Java_sun_awt_image_BufImgSurfaceData_setSurfaceData
{
static char *bimgName = "java/awt/image/BufferedImage";
jclass bimg = (*env)->FindClass(env, bimgName);
CHECK_NULL(bimg);
sDataID = (*env)->GetFieldID(env, bimg, "sData", "Lsun/java2d/SurfaceData;");
CHECK_NULL(sDataID);
}
(*env)->SetObjectField(env, bufImg, sDataID, sData);
......@@ -1610,18 +1614,11 @@ JNIEXPORT void JNICALL Java_sun_java2d_OSXOffScreenSurfaceData_initIDs(JNIEnv *e
return;
}
icm = (*env)->FindClass(env, icmName);
if (icm == NULL) {
return;
}
rgbID = (*env)->GetFieldID(env, icm, "rgb", "[I");
allGrayID = (*env)->GetFieldID(env, icm, "allgrayopaque", "Z");
mapSizeID = (*env)->GetFieldID(env, icm, "map_size", "I");
CMpDataID = (*env)->GetFieldID(env, icm, "pData", "J");
if (allGrayID == 0 || rgbID == 0 || mapSizeID == 0 || CMpDataID == 0) {
JNU_ThrowInternalError(env, "Could not get field IDs");
}
CHECK_NULL(icm = (*env)->FindClass(env, icmName));
CHECK_NULL(rgbID = (*env)->GetFieldID(env, icm, "rgb", "[I"));
CHECK_NULL(allGrayID = (*env)->GetFieldID(env, icm, "allgrayopaque", "Z"));
CHECK_NULL(mapSizeID = (*env)->GetFieldID(env, icm, "map_size", "I"));
CHECK_NULL(CMpDataID = (*env)->GetFieldID(env, icm, "pData", "J"));
}
gColorspaceRGB = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
......@@ -1795,6 +1792,7 @@ PRINT("Java_sun_java2d_OSXOffScreenSurfaceData_initRaster")
//bisdo->sdOps.Dispose = BufImg_Dispose;
bisdo->array = (*env)->NewWeakGlobalRef(env, array);
if (array != NULL) CHECK_NULL(bisdo->array);
bisdo->offset = offset;
//bisdo->scanStr = scanStr;
bisdo->scanStr = scanStride;
......@@ -1807,8 +1805,10 @@ PRINT("Java_sun_java2d_OSXOffScreenSurfaceData_initRaster")
} else {
jobject lutarray = (*env)->GetObjectField(env, icm, rgbID);
bisdo->lutarray = (*env)->NewWeakGlobalRef(env, lutarray);
if (lutarray != NULL) CHECK_NULL(bisdo->lutarray);
bisdo->lutsize = (*env)->GetIntField(env, icm, mapSizeID);
bisdo->icm = (*env)->NewWeakGlobalRef(env, icm);
if (icm != NULL) CHECK_NULL(bisdo->icm);
}
bisdo->rasbounds.x1 = 0;
bisdo->rasbounds.y1 = 0;
......@@ -1887,7 +1887,7 @@ PRINT("Java_sun_java2d_OSXOffScreenSurfaceData_initRaster")
Pixel32bit* src = lutdata;
Pixel32bit* dst = isdo->lutData;
jint i;
for (i=0; i<isdo->lutDataSize; i++)
for (i=0; (unsigned)i<isdo->lutDataSize; i++)
{
if (i != transparent_index)
{
......@@ -1919,7 +1919,7 @@ PRINT("Java_sun_java2d_OSXOffScreenSurfaceData_initRaster")
Pixel32bit* src = lutdata;
Pixel32bit* dst = isdo->lutData;
jint i;
for (i=0; i<isdo->lutDataSize; i++)
for (i=0; (unsigned)i<isdo->lutDataSize; i++)
{
*dst = *src | mask;
dst++; src++;
......
......@@ -438,6 +438,9 @@ QUARTZ_RENDERER_INLINE SDRenderType doPolyUsingCG(JNIEnv *env, CGContextRef cgRe
{
SDRenderType renderType = SD_Nothing;
if (xpointsarray == NULL || ypointsarray == NULL) {
return SD_Nothing;
}
if (npoints > 1)
{
if (fill == YES)
......@@ -452,7 +455,14 @@ QUARTZ_RENDERER_INLINE SDRenderType doPolyUsingCG(JNIEnv *env, CGContextRef cgRe
jint i;
jint* xpoints = (jint*)(*env)->GetPrimitiveArrayCritical(env, xpointsarray, NULL);
if (xpoints == NULL) {
return SD_Nothing;
}
jint* ypoints = (jint*)(*env)->GetPrimitiveArrayCritical(env, ypointsarray, NULL);
if (ypoints == NULL) {
(*env)->ReleasePrimitiveArrayCritical(env, xpointsarray, xpoints, 0);
return SD_Nothing;
}
CGContextMoveToPoint(cgRef, xpoints[0]+offsetX, ypoints[0]+offsetY);
......
......@@ -778,6 +778,10 @@ PRINT(" SetUpCGContext")
qsdo->graphicsStateInfo.simpleStroke = NO;
jint length = (*env)->GetArrayLength(env, dasharray);
jfloat* jdashes = (jfloat*)(*env)->GetPrimitiveArrayCritical(env, dasharray, NULL);
if (jdashes == NULL) {
CGContextSetLineDash(cgRef, 0, NULL, 0);
return;
}
CGFloat* dashes = (CGFloat*)malloc(sizeof(CGFloat)*length);
if (dashes != NULL)
{
......
......@@ -127,6 +127,9 @@ GetTxFromDoubles(JNIEnv *env, jdoubleArray txArray)
}
jdouble *txPtr = (*env)->GetPrimitiveArrayCritical(env, txArray, NULL);
if (txPtr == NULL) {
return CGAffineTransformIdentity;
}
CGAffineTransform tx =
CGAffineTransformMake(txPtr[0], txPtr[1], txPtr[2],
......@@ -311,18 +314,22 @@ JNF_COCOA_ENTER(env);
jlong *glyphInfos =
(*env)->GetPrimitiveArrayCritical(env, glyphInfoLongArray, NULL);
if (glyphInfos != NULL) {
jint *rawGlyphCodes =
(*env)->GetPrimitiveArrayCritical(env, glyphCodes, NULL);
if (rawGlyphCodes != NULL) {
CGGlyphImages_GetGlyphImagePtrs(glyphInfos, awtStrike,
rawGlyphCodes, len);
(*env)->ReleasePrimitiveArrayCritical(env, glyphCodes,
rawGlyphCodes, JNI_ABORT);
}
// Do not use JNI_COMMIT, as that will not free the buffer copy
// when +ProtectJavaHeap is on.
(*env)->ReleasePrimitiveArrayCritical(env, glyphInfoLongArray,
glyphInfos, 0);
}
JNF_COCOA_EXIT(env);
}
......
......@@ -101,10 +101,13 @@ JNF_COCOA_ENTER(env);
jchar *unicodesAsChars =
(*env)->GetPrimitiveArrayCritical(env, unicodes, NULL);
AllocateGlyphBuffer(env, awtFont, count, (UniChar *)unicodesAsChars, glyphs);
if (unicodesAsChars != NULL) {
AllocateGlyphBuffer(env, awtFont, count,
(UniChar *)unicodesAsChars, glyphs);
(*env)->ReleasePrimitiveArrayCritical(env, unicodes,
unicodesAsChars, JNI_ABORT);
}
JNF_COCOA_EXIT(env);
}
......@@ -787,6 +787,14 @@ public abstract class ClientNotifForwarder {
if (!reconnected) {
try {
NotificationResult nr = fetchNotifs(-1, 0, 0);
if (state != STOPPED) { // JDK-8038940
// reconnection must happen during
// fetchNotifs(-1, 0, 0), and a new
// thread takes over the fetching job
return;
}
clientSequenceNumber = nr.getNextSequenceNumber();
} catch (ClassNotFoundException e) {
// can't happen
......
......@@ -862,4 +862,18 @@ import jdk.internal.org.objectweb.asm.Type;
* All subclasses must provide such a value describing their type signature.
*/
static final SpeciesData SPECIES_DATA = SpeciesData.EMPTY;
private static final SpeciesData[] SPECIES_DATA_CACHE = new SpeciesData[5];
private static SpeciesData checkCache(int size, String types) {
int idx = size - 1;
SpeciesData data = SPECIES_DATA_CACHE[idx];
if (data != null) return data;
SPECIES_DATA_CACHE[idx] = data = getSpeciesData(types);
return data;
}
static SpeciesData speciesData_L() { return checkCache(1, "L"); }
static SpeciesData speciesData_LL() { return checkCache(2, "LL"); }
static SpeciesData speciesData_LLL() { return checkCache(3, "LLL"); }
static SpeciesData speciesData_LLLL() { return checkCache(4, "LLLL"); }
static SpeciesData speciesData_LLLLL() { return checkCache(5, "LLLLL"); }
}
......@@ -27,7 +27,6 @@ package java.lang.invoke;
import sun.invoke.util.VerifyAccess;
import java.lang.invoke.LambdaForm.Name;
import java.lang.invoke.MethodHandles.Lookup;
import sun.invoke.util.Wrapper;
......@@ -39,8 +38,6 @@ import jdk.internal.org.objectweb.asm.*;
import java.lang.reflect.*;
import static java.lang.invoke.MethodHandleStatics.*;
import static java.lang.invoke.MethodHandleNatives.Constants.*;
import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
import sun.invoke.util.ValueConversions;
import sun.invoke.util.VerifyType;
/**
......@@ -51,7 +48,7 @@ import sun.invoke.util.VerifyType;
class InvokerBytecodeGenerator {
/** Define class names for convenience. */
private static final String MH = "java/lang/invoke/MethodHandle";
private static final String BMH = "java/lang/invoke/BoundMethodHandle";
private static final String MHI = "java/lang/invoke/MethodHandleImpl";
private static final String LF = "java/lang/invoke/LambdaForm";
private static final String LFN = "java/lang/invoke/LambdaForm$Name";
private static final String CLS = "java/lang/Class";
......@@ -61,6 +58,7 @@ class InvokerBytecodeGenerator {
private static final String LF_SIG = "L" + LF + ";";
private static final String LFN_SIG = "L" + LFN + ";";
private static final String LL_SIG = "(L" + OBJ + ";)L" + OBJ + ";";
private static final String CLL_SIG = "(L" + CLS + ";L" + OBJ + ";)L" + OBJ + ";";
/** Name of its super class*/
private static final String superName = LF;
......@@ -438,7 +436,7 @@ class InvokerBytecodeGenerator {
mv.visitLdcInsn(constantPlaceholder(pclass));
mv.visitTypeInsn(Opcodes.CHECKCAST, CLS);
mv.visitInsn(Opcodes.SWAP);
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, CLS, "cast", LL_SIG);
mv.visitMethodInsn(Opcodes.INVOKESTATIC, MHI, "castReference", CLL_SIG);
if (pclass.isArray())
mv.visitTypeInsn(Opcodes.CHECKCAST, OBJARY);
}
......@@ -512,17 +510,22 @@ class InvokerBytecodeGenerator {
Name name = lambdaForm.names[i];
MemberName member = name.function.member();
if (isSelectAlternative(member)) {
// selectAlternative idiom
// FIXME: make sure this idiom is really present!
if (isSelectAlternative(i)) {
emitSelectAlternative(name, lambdaForm.names[i + 1]);
i++; // skip MH.invokeBasic of the selectAlternative result
} else if (isGuardWithCatch(i)) {
emitGuardWithCatch(i);
i = i+2; // Jump to the end of GWC idiom
} else if (isStaticallyInvocable(member)) {
emitStaticInvoke(member, name);
} else {
emitInvoke(name);
}
// Update cached form name's info in case an intrinsic spanning multiple names was encountered.
name = lambdaForm.names[i];
member = name.function.member();
// store the result from evaluating to the target name in a local if required
// (if this is the last value, i.e., the one that is going to be returned,
// avoid store/load/return and just return)
......@@ -675,12 +678,66 @@ class InvokerBytecodeGenerator {
}
/**
* Check if MemberName is a call to MethodHandleImpl.selectAlternative.
* Check if MemberName is a call to a method named {@code name} in class {@code declaredClass}.
*/
private boolean isSelectAlternative(MemberName member) {
private boolean memberRefersTo(MemberName member, Class<?> declaringClass, String name) {
return member != null &&
member.getDeclaringClass() == MethodHandleImpl.class &&
member.getName().equals("selectAlternative");
member.getDeclaringClass() == declaringClass &&
member.getName().equals(name);
}
private boolean nameRefersTo(Name name, Class<?> declaringClass, String methodName) {
return name.function != null &&
memberRefersTo(name.function.member(), declaringClass, methodName);
}
/**
* Check if MemberName is a call to MethodHandle.invokeBasic.
*/
private boolean isInvokeBasic(Name name) {
if (name.function == null)
return false;
if (name.arguments.length < 1)
return false; // must have MH argument
MemberName member = name.function.member();
return memberRefersTo(member, MethodHandle.class, "invokeBasic") &&
!member.isPublic() && !member.isStatic();
}
/**
* Check if i-th name is a call to MethodHandleImpl.selectAlternative.
*/
private boolean isSelectAlternative(int pos) {
// selectAlternative idiom:
// t_{n}:L=MethodHandleImpl.selectAlternative(...)
// t_{n+1}:?=MethodHandle.invokeBasic(t_{n}, ...)
if (pos+1 >= lambdaForm.names.length) return false;
Name name0 = lambdaForm.names[pos];
Name name1 = lambdaForm.names[pos+1];
return nameRefersTo(name0, MethodHandleImpl.class, "selectAlternative") &&
isInvokeBasic(name1) &&
name1.lastUseIndex(name0) == 0 && // t_{n+1}:?=MethodHandle.invokeBasic(t_{n}, ...)
lambdaForm.lastUseIndex(name0) == pos+1; // t_{n} is local: used only in t_{n+1}
}
/**
* Check if i-th name is a start of GuardWithCatch idiom.
*/
private boolean isGuardWithCatch(int pos) {
// GuardWithCatch idiom:
// t_{n}:L=MethodHandle.invokeBasic(...)
// t_{n+1}:L=MethodHandleImpl.guardWithCatch(*, *, *, t_{n});
// t_{n+2}:?=MethodHandle.invokeBasic(t_{n+1})
if (pos+2 >= lambdaForm.names.length) return false;
Name name0 = lambdaForm.names[pos];
Name name1 = lambdaForm.names[pos+1];
Name name2 = lambdaForm.names[pos+2];
return nameRefersTo(name1, MethodHandleImpl.class, "guardWithCatch") &&
isInvokeBasic(name0) &&
isInvokeBasic(name2) &&
name1.lastUseIndex(name0) == 3 && // t_{n+1}:L=MethodHandleImpl.guardWithCatch(*, *, *, t_{n});
lambdaForm.lastUseIndex(name0) == pos+1 && // t_{n} is local: used only in t_{n+1}
name2.lastUseIndex(name1) == 1 && // t_{n+2}:?=MethodHandle.invokeBasic(t_{n+1})
lambdaForm.lastUseIndex(name1) == pos+2; // t_{n+1} is local: used only in t_{n+2}
}
/**
......@@ -695,8 +752,6 @@ class InvokerBytecodeGenerator {
* }</pre></blockquote>
*/
private void emitSelectAlternative(Name selectAlternativeName, Name invokeBasicName) {
MethodType type = selectAlternativeName.function.methodType();
Name receiver = (Name) invokeBasicName.arguments[0];
Label L_fallback = new Label();
......@@ -710,7 +765,6 @@ class InvokerBytecodeGenerator {
mv.visitJumpInsn(Opcodes.IF_ICMPNE, L_fallback);
// invoke selectAlternativeName.arguments[1]
MethodHandle target = (MethodHandle) selectAlternativeName.arguments[1];
emitPushArgument(selectAlternativeName, 1); // get 2nd argument of selectAlternative
emitAstoreInsn(receiver.index()); // store the MH in the receiver slot
emitInvoke(invokeBasicName);
......@@ -722,7 +776,6 @@ class InvokerBytecodeGenerator {
mv.visitLabel(L_fallback);
// invoke selectAlternativeName.arguments[2]
MethodHandle fallback = (MethodHandle) selectAlternativeName.arguments[2];
emitPushArgument(selectAlternativeName, 2); // get 3rd argument of selectAlternative
emitAstoreInsn(receiver.index()); // store the MH in the receiver slot
emitInvoke(invokeBasicName);
......@@ -731,6 +784,85 @@ class InvokerBytecodeGenerator {
mv.visitLabel(L_done);
}
/**
* Emit bytecode for the guardWithCatch idiom.
*
* The pattern looks like (Cf. MethodHandleImpl.makeGuardWithCatch):
* <blockquote><pre>{@code
* guardWithCatch=Lambda(a0:L,a1:L,a2:L,a3:L,a4:L,a5:L,a6:L,a7:L)=>{
* t8:L=MethodHandle.invokeBasic(a4:L,a6:L,a7:L);
* t9:L=MethodHandleImpl.guardWithCatch(a1:L,a2:L,a3:L,t8:L);
* t10:I=MethodHandle.invokeBasic(a5:L,t9:L);t10:I}
* }</pre></blockquote>
*
* It is compiled into bytecode equivalent of the following code:
* <blockquote><pre>{@code
* try {
* return a1.invokeBasic(a6, a7);
* } catch (Throwable e) {
* if (!a2.isInstance(e)) throw e;
* return a3.invokeBasic(ex, a6, a7);
* }}
*/
private void emitGuardWithCatch(int pos) {
Name args = lambdaForm.names[pos];
Name invoker = lambdaForm.names[pos+1];
Name result = lambdaForm.names[pos+2];
Label L_startBlock = new Label();
Label L_endBlock = new Label();
Label L_handler = new Label();
Label L_done = new Label();
Class<?> returnType = result.function.resolvedHandle.type().returnType();
MethodType type = args.function.resolvedHandle.type()
.dropParameterTypes(0,1)
.changeReturnType(returnType);
mv.visitTryCatchBlock(L_startBlock, L_endBlock, L_handler, "java/lang/Throwable");
// Normal case
mv.visitLabel(L_startBlock);
// load target
emitPushArgument(invoker, 0);
emitPushArguments(args, 1); // skip 1st argument: method handle
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, MH, "invokeBasic", type.basicType().toMethodDescriptorString(), false);
mv.visitLabel(L_endBlock);
mv.visitJumpInsn(Opcodes.GOTO, L_done);
// Exceptional case
mv.visitLabel(L_handler);
// Check exception's type
mv.visitInsn(Opcodes.DUP);
// load exception class
emitPushArgument(invoker, 1);
mv.visitInsn(Opcodes.SWAP);
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/Class", "isInstance", "(Ljava/lang/Object;)Z", false);
Label L_rethrow = new Label();
mv.visitJumpInsn(Opcodes.IFEQ, L_rethrow);
// Invoke catcher
// load catcher
emitPushArgument(invoker, 2);
mv.visitInsn(Opcodes.SWAP);
emitPushArguments(args, 1); // skip 1st argument: method handle
MethodType catcherType = type.insertParameterTypes(0, Throwable.class);
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, MH, "invokeBasic", catcherType.basicType().toMethodDescriptorString(), false);
mv.visitJumpInsn(Opcodes.GOTO, L_done);
mv.visitLabel(L_rethrow);
mv.visitInsn(Opcodes.ATHROW);
mv.visitLabel(L_done);
}
private void emitPushArguments(Name args, int start) {
for (int i = start; i < args.arguments.length; i++) {
emitPushArgument(args, i);
}
}
private void emitPushArgument(Name name, int paramIndex) {
Object arg = name.arguments[paramIndex];
char ptype = name.function.parameterType(paramIndex);
......
......@@ -1465,6 +1465,33 @@ class LambdaForm {
return false;
}
/** Return the index of the last occurrence of n in the argument array.
* Return -1 if the name is not used.
*/
int lastUseIndex(Name n) {
if (arguments == null) return -1;
for (int i = arguments.length; --i >= 0; ) {
if (arguments[i] == n) return i;
}
return -1;
}
/** Return the number of occurrences of n in the argument array.
* Return 0 if the name is not used.
*/
int useCount(Name n) {
if (arguments == null) return 0;
int count = 0;
for (int i = arguments.length; --i >= 0; ) {
if (arguments[i] == n) ++count;
}
return count;
}
boolean contains(Name n) {
return this == n || lastUseIndex(n) >= 0;
}
public boolean equals(Name that) {
if (this == that) return true;
if (isParam())
......@@ -1488,6 +1515,35 @@ class LambdaForm {
}
}
/** Return the index of the last name which contains n as an argument.
* Return -1 if the name is not used. Return names.length if it is the return value.
*/
int lastUseIndex(Name n) {
int ni = n.index, nmax = names.length;
assert(names[ni] == n);
if (result == ni) return nmax; // live all the way beyond the end
for (int i = nmax; --i > ni; ) {
if (names[i].lastUseIndex(n) >= 0)
return i;
}
return -1;
}
/** Return the number of times n is used as an argument or return value. */
int useCount(Name n) {
int ni = n.index, nmax = names.length;
int end = lastUseIndex(n);
if (end < 0) return 0;
int count = 0;
if (end == nmax) { count++; end--; }
int beg = n.index() + 1;
if (beg < arity) beg = arity;
for (int i = beg; i <= end; i++) {
count += names[i].useCount(n);
}
return count;
}
static Name argument(int which, char type) {
int tn = ALL_TYPES.indexOf(type);
if (tn < 0 || which >= INTERNED_ARGUMENT_LIMIT)
......
......@@ -76,7 +76,8 @@ final class MethodTypeForm {
LF_GEN_INVOKER = 12,
LF_CS_LINKER = 13, // linkToCallSite_CS
LF_MH_LINKER = 14, // linkToCallSite_MH
LF_LIMIT = 15;
LF_GWC = 15,
LF_LIMIT = 16;
public MethodType erasedType() {
return erasedType;
......
......@@ -28,6 +28,7 @@ package java.util;
import java.lang.reflect.Array;
import java.util.concurrent.ForkJoinPool;
import java.util.function.BinaryOperator;
import java.util.function.Consumer;
import java.util.function.DoubleBinaryOperator;
import java.util.function.IntBinaryOperator;
import java.util.function.IntFunction;
......@@ -35,6 +36,7 @@ import java.util.function.IntToDoubleFunction;
import java.util.function.IntToLongFunction;
import java.util.function.IntUnaryOperator;
import java.util.function.LongBinaryOperator;
import java.util.function.UnaryOperator;
import java.util.stream.DoubleStream;
import java.util.stream.IntStream;
import java.util.stream.LongStream;
......@@ -3848,12 +3850,13 @@ public class Arrays {
@Override
public int indexOf(Object o) {
if (o==null) {
for (int i=0; i<a.length; i++)
if (a[i]==null)
E[] a = this.a;
if (o == null) {
for (int i = 0; i < a.length; i++)
if (a[i] == null)
return i;
} else {
for (int i=0; i<a.length; i++)
for (int i = 0; i < a.length; i++)
if (o.equals(a[i]))
return i;
}
......@@ -3869,6 +3872,28 @@ public class Arrays {
public Spliterator<E> spliterator() {
return Spliterators.spliterator(a, Spliterator.ORDERED);
}
@Override
public void forEach(Consumer<? super E> action) {
Objects.requireNonNull(action);
for (E e : a) {
action.accept(e);
}
}
@Override
public void replaceAll(UnaryOperator<E> operator) {
Objects.requireNonNull(operator);
E[] a = this.a;
for (int i = 0; i < a.length; i++) {
a[i] = operator.apply(a[i]);
}
}
@Override
public void sort(Comparator<? super E> c) {
Arrays.sort(a, c);
}
}
/**
......
......@@ -384,7 +384,7 @@ public final class Spliterators {
*/
private static void checkFromToBounds(int arrayLength, int origin, int fence) {
if (origin > fence) {
throw new IllegalArgumentException(
throw new ArrayIndexOutOfBoundsException(
"origin(" + origin + ") > fence(" + fence + ")");
}
if (origin < 0) {
......
......@@ -1415,6 +1415,28 @@ implements ItemSelectable,ListDataListener,ActionListener, Accessible {
super.processKeyEvent(e);
}
/**
* {@inheritDoc}
*/
@Override
protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed) {
if (super.processKeyBinding(ks, e, condition, pressed)) {
return true;
}
if (!isEditable() || condition != WHEN_FOCUSED || getEditor() == null
|| !Boolean.TRUE.equals(getClientProperty("JComboBox.isTableCellEditor"))) {
return false;
}
Component editorComponent = getEditor().getEditorComponent();
if (editorComponent instanceof JComponent) {
JComponent component = (JComponent) editorComponent;
return component.processKeyBinding(ks, e, WHEN_FOCUSED, pressed);
}
return false;
}
/**
* Sets the object that translates a keyboard character into a list
* selection. Typically, the first selection with a matching first
......
......@@ -73,7 +73,7 @@ class EditableView extends ComponentView {
Component c = getComponent();
Container host = getContainer();
if (host != null &&
if (host instanceof JTextComponent &&
isVisible != ((JTextComponent)host).isEditable()) {
isVisible = ((JTextComponent)host).isEditable();
preferenceChanged(null, true, true);
......
......@@ -259,41 +259,68 @@ public class ByteVector {
if (c >= '\001' && c <= '\177') {
data[len++] = (byte) c;
} else {
int byteLength = i;
for (int j = i; j < charLength; ++j) {
c = s.charAt(j);
if (c >= '\001' && c <= '\177') {
byteLength++;
} else if (c > '\u07FF') {
byteLength += 3;
} else {
byteLength += 2;
}
}
if (byteLength > 65535) {
throw new IllegalArgumentException();
}
data[length] = (byte) (byteLength >>> 8);
data[length + 1] = (byte) byteLength;
if (length + 2 + byteLength > data.length) {
length = len;
enlarge(2 + byteLength);
data = this.data;
}
for (int j = i; j < charLength; ++j) {
c = s.charAt(j);
if (c >= '\001' && c <= '\177') {
data[len++] = (byte) c;
} else if (c > '\u07FF') {
data[len++] = (byte) (0xE0 | c >> 12 & 0xF);
data[len++] = (byte) (0x80 | c >> 6 & 0x3F);
data[len++] = (byte) (0x80 | c & 0x3F);
} else {
data[len++] = (byte) (0xC0 | c >> 6 & 0x1F);
data[len++] = (byte) (0x80 | c & 0x3F);
}
}
break;
length = len;
return encodeUTF8(s, i, 65535);
}
}
length = len;
return this;
}
/**
* Puts an UTF8 string into this byte vector. The byte vector is
* automatically enlarged if necessary. The string length is encoded in two
* bytes before the encoded characters, if there is space for that (i.e. if
* this.length - i - 2 >= 0).
*
* @param s
* the String to encode.
* @param i
* the index of the first character to encode. The previous
* characters are supposed to have already been encoded, using
* only one byte per character.
* @param maxByteLength
* the maximum byte length of the encoded string, including the
* already encoded characters.
* @return this byte vector.
*/
ByteVector encodeUTF8(final String s, int i, int maxByteLength) {
int charLength = s.length();
int byteLength = i;
char c;
for (int j = i; j < charLength; ++j) {
c = s.charAt(j);
if (c >= '\001' && c <= '\177') {
byteLength++;
} else if (c > '\u07FF') {
byteLength += 3;
} else {
byteLength += 2;
}
}
if (byteLength > maxByteLength) {
throw new IllegalArgumentException();
}
int start = length - i - 2;
if (start >= 0) {
data[start] = (byte) (byteLength >>> 8);
data[start + 1] = (byte) byteLength;
}
if (length + byteLength - i > data.length) {
enlarge(byteLength - i);
}
int len = length;
for (int j = i; j < charLength; ++j) {
c = s.charAt(j);
if (c >= '\001' && c <= '\177') {
data[len++] = (byte) c;
} else if (c > '\u07FF') {
data[len++] = (byte) (0xE0 | c >> 12 & 0xF);
data[len++] = (byte) (0x80 | c >> 6 & 0x3F);
data[len++] = (byte) (0x80 | c & 0x3F);
} else {
data[len++] = (byte) (0xC0 | c >> 6 & 0x1F);
data[len++] = (byte) (0x80 | c & 0x3F);
}
}
length = len;
......
......@@ -716,7 +716,8 @@ public class ClassWriter extends ClassVisitor {
sourceFile = newUTF8(file);
}
if (debug != null) {
sourceDebug = new ByteVector().putUTF8(debug);
sourceDebug = new ByteVector().encodeUTF8(debug, 0,
Integer.MAX_VALUE);
}
}
......@@ -857,7 +858,7 @@ public class ClassWriter extends ClassVisitor {
}
if (sourceDebug != null) {
++attributeCount;
size += sourceDebug.length + 4;
size += sourceDebug.length + 6;
newUTF8("SourceDebugExtension");
}
if (enclosingMethodOwner != 0) {
......@@ -946,9 +947,9 @@ public class ClassWriter extends ClassVisitor {
out.putShort(newUTF8("SourceFile")).putInt(2).putShort(sourceFile);
}
if (sourceDebug != null) {
int len = sourceDebug.length - 2;
int len = sourceDebug.length;
out.putShort(newUTF8("SourceDebugExtension")).putInt(len);
out.putByteArray(sourceDebug.data, 2, len);
out.putByteArray(sourceDebug.data, 0, len);
}
if (enclosingMethodOwner != 0) {
out.putShort(newUTF8("EnclosingMethod")).putInt(4);
......
......@@ -99,8 +99,8 @@ final class Frame {
* stack types. VALUE depends on KIND. For LOCAL types, it is an index in
* the input local variable types. For STACK types, it is a position
* relatively to the top of input frame stack. For BASE types, it is either
* one of the constants defined in FrameVisitor, or for OBJECT and
* UNINITIALIZED types, a tag and an index in the type table.
* one of the constants defined below, or for OBJECT and UNINITIALIZED
* types, a tag and an index in the type table.
*
* Output frames can contain types of any kind and with a positive or
* negative dimension (and even unassigned types, represented by 0 - which
......@@ -537,7 +537,7 @@ final class Frame {
/**
* The types that are initialized in the basic block. A constructor
* invocation on an UNINITIALIZED or UNINITIALIZED_THIS type must replace
* <i>every occurrence</i> of this type in the local variables and in the
* <i>every occurence</i> of this type in the local variables and in the
* operand stack. This cannot be done during the first phase of the
* algorithm since, during this phase, the local variables and the operand
* stack are not completely computed. It is therefore necessary to store the
......@@ -1446,6 +1446,7 @@ final class Frame {
// if t is the NULL type, merge(u,t)=u, so there is no change
return false;
} else if ((t & (DIM | BASE_KIND)) == (u & (DIM | BASE_KIND))) {
// if t and u have the same dimension and same base kind
if ((u & BASE_KIND) == OBJECT) {
// if t is also a reference type, and if u and t have the
// same dimension merge(u,t) = dim(t) | common parent of the
......@@ -1458,9 +1459,13 @@ final class Frame {
v = OBJECT | cw.addType("java/lang/Object");
}
} else if ((t & BASE_KIND) == OBJECT || (t & DIM) != 0) {
// if t is any other reference or array type,
// merge(u,t)=java/lang/Object
v = OBJECT | cw.addType("java/lang/Object");
// if t is any other reference or array type, the merged type
// is Object, or min(dim(u), dim(t)) | java/lang/Object is u
// and t have different array dimensions
int tdim = t & DIM;
int udim = u & DIM;
v = (udim != tdim ? Math.min(tdim, udim) : 0) | OBJECT
| cw.addType("java/lang/Object");
} else {
// if t is any other type, merge(u,t)=TOP
v = TOP;
......
......@@ -240,6 +240,7 @@ public class AnalyzerAdapter extends MethodVisitor {
locals.add(types[i].getInternalName());
}
}
maxLocals = locals.size();
}
@Override
......@@ -519,12 +520,12 @@ public class AnalyzerAdapter extends MethodVisitor {
// ------------------------------------------------------------------------
private Object get(final int local) {
maxLocals = Math.max(maxLocals, local);
maxLocals = Math.max(maxLocals, local + 1);
return local < locals.size() ? locals.get(local) : Opcodes.TOP;
}
private void set(final int local, final Object type) {
maxLocals = Math.max(maxLocals, local);
maxLocals = Math.max(maxLocals, local + 1);
while (local >= locals.size()) {
locals.add(Opcodes.TOP);
}
......
......@@ -556,6 +556,8 @@ public class InsnList {
AbstractInsnNode prev;
AbstractInsnNode remove;
InsnListIterator(int index) {
if (index == size()) {
next = null;
......@@ -577,12 +579,22 @@ public class InsnList {
AbstractInsnNode result = next;
prev = result;
next = result.next;
remove = result;
return result;
}
public void remove() {
InsnList.this.remove(prev);
prev = prev.prev;
if (remove != null) {
if (remove == next) {
next = next.next;
} else {
prev = prev.prev;
}
InsnList.this.remove(remove);
remove = null;
} else {
throw new IllegalStateException();
}
}
public boolean hasPrevious() {
......@@ -593,6 +605,7 @@ public class InsnList {
AbstractInsnNode result = prev;
next = result;
prev = result.prev;
remove = result;
return result;
}
......@@ -619,6 +632,7 @@ public class InsnList {
public void add(Object o) {
InsnList.this.insertBefore(next, (AbstractInsnNode) o);
prev = (AbstractInsnNode) o;
remove = null;
}
public void set(Object o) {
......
......@@ -404,7 +404,7 @@ public class Analyzer<V extends Value> implements Opcodes {
* instruction of the method. The size of the returned array is
* equal to the number of instructions (and labels) of the method. A
* given frame is <tt>null</tt> if the corresponding instruction
* cannot be reached, or if an error occurred during the analysis of
* cannot be reached, or if an error occured during the analysis of
* the method.
*/
public Frame<V>[] getFrames() {
......
......@@ -111,7 +111,7 @@ public abstract class Interpreter<V extends Value> {
* the bytecode instruction to be interpreted.
* @return the result of the interpretation of the given instruction.
* @throws AnalyzerException
* if an error occurred during the interpretation.
* if an error occured during the interpretation.
*/
public abstract V newOperation(AbstractInsnNode insn)
throws AnalyzerException;
......@@ -130,7 +130,7 @@ public abstract class Interpreter<V extends Value> {
* @return the result of the interpretation of the given instruction. The
* returned value must be <tt>equal</tt> to the given value.
* @throws AnalyzerException
* if an error occurred during the interpretation.
* if an error occured during the interpretation.
*/
public abstract V copyOperation(AbstractInsnNode insn, V value)
throws AnalyzerException;
......@@ -151,7 +151,7 @@ public abstract class Interpreter<V extends Value> {
* the argument of the instruction to be interpreted.
* @return the result of the interpretation of the given instruction.
* @throws AnalyzerException
* if an error occurred during the interpretation.
* if an error occured during the interpretation.
*/
public abstract V unaryOperation(AbstractInsnNode insn, V value)
throws AnalyzerException;
......@@ -175,7 +175,7 @@ public abstract class Interpreter<V extends Value> {
* the second argument of the instruction to be interpreted.
* @return the result of the interpretation of the given instruction.
* @throws AnalyzerException
* if an error occurred during the interpretation.
* if an error occured during the interpretation.
*/
public abstract V binaryOperation(AbstractInsnNode insn, V value1, V value2)
throws AnalyzerException;
......@@ -196,7 +196,7 @@ public abstract class Interpreter<V extends Value> {
* the third argument of the instruction to be interpreted.
* @return the result of the interpretation of the given instruction.
* @throws AnalyzerException
* if an error occurred during the interpretation.
* if an error occured during the interpretation.
*/
public abstract V ternaryOperation(AbstractInsnNode insn, V value1,
V value2, V value3) throws AnalyzerException;
......@@ -214,7 +214,7 @@ public abstract class Interpreter<V extends Value> {
* the arguments of the instruction to be interpreted.
* @return the result of the interpretation of the given instruction.
* @throws AnalyzerException
* if an error occurred during the interpretation.
* if an error occured during the interpretation.
*/
public abstract V naryOperation(AbstractInsnNode insn,
List<? extends V> values) throws AnalyzerException;
......@@ -232,7 +232,7 @@ public abstract class Interpreter<V extends Value> {
* @param expected
* the expected return type of the analyzed method.
* @throws AnalyzerException
* if an error occurred during the interpretation.
* if an error occured during the interpretation.
*/
public abstract void returnOperation(AbstractInsnNode insn, V value,
V expected) throws AnalyzerException;
......
......@@ -99,7 +99,7 @@ public class CheckAnnotationAdapter extends AnnotationVisitor {
}
if (value instanceof Type) {
int sort = ((Type) value).getSort();
if (sort != Type.OBJECT && sort != Type.ARRAY) {
if (sort == Type.METHOD) {
throw new IllegalArgumentException("Invalid annotation value");
}
}
......
......@@ -166,6 +166,11 @@ public class Textifier extends Printer {
*/
protected Map<Label, String> labelNames;
/**
* Class access flags
*/
private int access;
private int valueNumber = 0;
/**
......@@ -245,6 +250,7 @@ public class Textifier extends Printer {
public void visit(final int version, final int access, final String name,
final String signature, final String superName,
final String[] interfaces) {
this.access = access;
int major = version & 0xFFFF;
int minor = version >>> 16;
buf.setLength(0);
......@@ -447,6 +453,11 @@ public class Textifier extends Printer {
if ((access & Opcodes.ACC_BRIDGE) != 0) {
buf.append("bridge ");
}
if ((this.access & Opcodes.ACC_INTERFACE) != 0
&& (access & Opcodes.ACC_ABSTRACT) == 0
&& (access & Opcodes.ACC_STATIC) == 0) {
buf.append("default ");
}
buf.append(name);
appendDescriptor(METHOD_DESCRIPTOR, desc);
......@@ -856,7 +867,6 @@ public class Textifier extends Printer {
appendDescriptor(INTERNAL_NAME, owner);
buf.append('.').append(name).append(' ');
appendDescriptor(METHOD_DESCRIPTOR, desc);
buf.append(' ').append(itf ? "itf" : "");
buf.append('\n');
text.add(buf.toString());
}
......@@ -869,26 +879,35 @@ public class Textifier extends Printer {
buf.append(name);
appendDescriptor(METHOD_DESCRIPTOR, desc);
buf.append(" [");
buf.append('\n');
buf.append(tab3);
appendHandle(bsm);
buf.append('\n');
buf.append(tab3).append("// arguments:");
if (bsmArgs.length == 0) {
buf.append(" none");
} else {
buf.append('\n').append(tab3);
buf.append('\n');
for (int i = 0; i < bsmArgs.length; i++) {
buf.append(tab3);
Object cst = bsmArgs[i];
if (cst instanceof String) {
Printer.appendString(buf, (String) cst);
} else if (cst instanceof Type) {
buf.append(((Type) cst).getDescriptor()).append(".class");
Type type = (Type) cst;
if(type.getSort() == Type.METHOD){
appendDescriptor(METHOD_DESCRIPTOR, type.getDescriptor());
} else {
buf.append(type.getDescriptor()).append(".class");
}
} else if (cst instanceof Handle) {
appendHandle((Handle) cst);
} else {
buf.append(cst);
}
buf.append(", ");
buf.append(", \n");
}
buf.setLength(buf.length() - 2);
buf.setLength(buf.length() - 3);
}
buf.append('\n');
buf.append(tab2).append("]\n");
......@@ -1234,10 +1253,10 @@ public class Textifier extends Printer {
* a handle, non null.
*/
protected void appendHandle(final Handle h) {
buf.append('\n').append(tab3);
int tag = h.getTag();
buf.append("// handle kind 0x").append(Integer.toHexString(tag))
.append(" : ");
boolean isMethodHandle = false;
switch (tag) {
case Opcodes.H_GETFIELD:
buf.append("GETFIELD");
......@@ -1253,18 +1272,23 @@ public class Textifier extends Printer {
break;
case Opcodes.H_INVOKEINTERFACE:
buf.append("INVOKEINTERFACE");
isMethodHandle = true;
break;
case Opcodes.H_INVOKESPECIAL:
buf.append("INVOKESPECIAL");
isMethodHandle = true;
break;
case Opcodes.H_INVOKESTATIC:
buf.append("INVOKESTATIC");
isMethodHandle = true;
break;
case Opcodes.H_INVOKEVIRTUAL:
buf.append("INVOKEVIRTUAL");
isMethodHandle = true;
break;
case Opcodes.H_NEWINVOKESPECIAL:
buf.append("NEWINVOKESPECIAL");
isMethodHandle = true;
break;
}
buf.append('\n');
......@@ -1272,9 +1296,13 @@ public class Textifier extends Printer {
appendDescriptor(INTERNAL_NAME, h.getOwner());
buf.append('.');
buf.append(h.getName());
buf.append('(');
if(!isMethodHandle){
buf.append('(');
}
appendDescriptor(HANDLE_DESCRIPTOR, h.getDesc());
buf.append(')').append('\n');
if(!isMethodHandle){
buf.append(')');
}
}
/**
......
Path: .
Working Copy Root Path: /hudson/jobs/objectweb-pull/workspace/ASM_5_0_BETA
URL: svn://svn.forge.objectweb.org/svnroot/asm/trunk/asm
Repository Root: svn://svn.forge.objectweb.org/svnroot/asm
Working Copy Root Path: /hudson/jobs/objectweb-pull/workspace/asm-svn-2014-03-12
URL: file:///svnroot/asm/trunk/asm
Repository Root: file:///svnroot/asm
Repository UUID: 271bd773-ee82-43a6-9b2b-1890ed8ce7f9
Revision: 1700
Revision: 1721
Node Kind: directory
Schedule: normal
Last Changed Author: ebruneton
Last Changed Rev: 1700
Last Changed Date: 2013-10-29 20:22:52 +0100 (Tue, 29 Oct 2013)
Last Changed Rev: 1721
Last Changed Date: 2014-03-02 17:25:35 +0100 (Sun, 02 Mar 2014)
......@@ -42,11 +42,13 @@ import java.util.Set;
import java.util.HashSet;
import java.beans.PropertyChangeSupport;
import java.beans.PropertyChangeListener;
import java.lang.ref.SoftReference;
import sun.util.logging.PlatformLogger;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Supplier;
/**
* The AppContext is a table referenced by ThreadGroup which stores
......@@ -883,6 +885,23 @@ public final class AppContext {
});
}
public static <T> T getSoftReferenceValue(Object key,
Supplier<T> supplier) {
final AppContext appContext = AppContext.getAppContext();
SoftReference<T> ref = (SoftReference<T>) appContext.get(key);
if (ref != null) {
final T object = ref.get();
if (object != null) {
return object;
}
}
final T object = supplier.get();
ref = new SoftReference<>(object);
appContext.put(key, ref);
return object;
}
}
final class MostRecentKeyValue {
......
/*
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -23,25 +23,28 @@
* questions.
*/
package com.apple.laf;
package sun.awt.image;
import java.awt.*;
import java.lang.ref.*;
import java.util.*;
import java.util.concurrent.locks.*;
import apple.laf.JRSUIConstants;
import apple.laf.JRSUIState;
import com.apple.laf.AquaUtils.RecyclableSingleton;
import sun.awt.AppContext;
/**
* ImageCache - A fixed pixel count sized cache of Images keyed by arbitrary set of arguments. All images are held with
* SoftReferences so they will be dropped by the GC if heap memory gets tight. When our size hits max pixel count least
* recently requested images are removed first.
* ImageCache - A fixed pixel count sized cache of Images keyed by arbitrary
* set of arguments. All images are held with SoftReferences so they will be
* dropped by the GC if heap memory gets tight. When our size hits max pixel
* count least recently requested images are removed first.
*
* The ImageCache must be used from the thread with an AppContext only.
*
*/
final class ImageCache {
final public class ImageCache {
// Ordered Map keyed by args hash, ordered by most recent accessed entry.
private final LinkedHashMap<Integer, PixelCountSoftReference> map = new LinkedHashMap<>(16, 0.75f, true);
private final LinkedHashMap<PixelsKey, ImageSoftReference> map
= new LinkedHashMap<>(16, 0.75f, true);
// Maximum number of pixels to cache, this is used if maxCount
private final int maxPixelCount;
......@@ -53,15 +56,9 @@ final class ImageCache {
// Reference queue for tracking lost softreferences to images in the cache
private final ReferenceQueue<Image> referenceQueue = new ReferenceQueue<>();
// Singleton Instance
private static final RecyclableSingleton<ImageCache> instance = new RecyclableSingleton<ImageCache>() {
@Override
protected ImageCache getInstance() {
return new ImageCache();
}
};
static ImageCache getInstance() {
return instance.get();
public static ImageCache getInstance() {
return AppContext.getSoftReferenceValue(ImageCache.class,
() -> new ImageCache());
}
ImageCache(final int maxPixelCount) {
......@@ -81,186 +78,86 @@ final class ImageCache {
}
}
public Image getImage(final GraphicsConfiguration config, final int w,
final int h, final int scale,
final JRSUIState state) {
final int hash = hash(config, w, h, scale, state);
final PixelCountSoftReference ref;
public Image getImage(final PixelsKey key){
final ImageSoftReference ref;
lock.readLock().lock();
try {
ref = map.get(hash);
ref = map.get(key);
} finally {
lock.readLock().unlock();
}
// check reference has not been lost and the key truly matches,
// in case of false positive hash match
if (ref != null && ref.equals(config, w, h, scale, state)) {
return ref.get();
}
return null;
return ref == null ? null : ref.get();
}
/**
* Sets the cached image for the specified constraints.
*
* @param key The key with which the specified image is to be associated
* @param image The image to store in cache
* @param config The graphics configuration, needed if cached image is a Volatile Image. Used as part of cache key
* @param w The image width, used as part of cache key
* @param h The image height, used as part of cache key
* @param scale The image scale factor, used as part of cache key
* @return true if the image could be cached, false otherwise.
*/
public boolean setImage(final Image image,
final GraphicsConfiguration config, final int w, final int h,
final int scale, final JRSUIState state) {
if (state.is(JRSUIConstants.Animating.YES)) {
return false;
}
final int hash = hash(config, w, h, scale, state);
public void setImage(final PixelsKey key, final Image image) {
lock.writeLock().lock();
try {
PixelCountSoftReference ref = map.get(hash);
// check if currently in map
if (ref != null && ref.get() == image) return true;
ImageSoftReference ref = map.get(key);
// clear out old
// check if currently in map
if (ref != null) {
currentPixelCount -= ref.pixelCount;
map.remove(hash);
}
if (ref.get() != null) {
return;
}
// soft image has been removed
currentPixelCount -= key.getPixelCount();
map.remove(key);
};
// add new image to pixel count
final int newPixelCount = image.getWidth(null) * image.getHeight(null);
final int newPixelCount = key.getPixelCount();
currentPixelCount += newPixelCount;
// clean out lost references if not enough space
if (currentPixelCount > maxPixelCount) {
while ((ref = (PixelCountSoftReference)referenceQueue.poll()) != null) {
while ((ref = (ImageSoftReference)referenceQueue.poll()) != null) {
//reference lost
map.remove(ref.hash);
currentPixelCount -= ref.pixelCount;
map.remove(ref.key);
currentPixelCount -= ref.key.getPixelCount();
}
}
// remove old items till there is enough free space
if (currentPixelCount > maxPixelCount) {
final Iterator<Map.Entry<Integer, PixelCountSoftReference>> mapIter = map.entrySet().iterator();
final Iterator<Map.Entry<PixelsKey, ImageSoftReference>>
mapIter = map.entrySet().iterator();
while ((currentPixelCount > maxPixelCount) && mapIter.hasNext()) {
final Map.Entry<Integer, PixelCountSoftReference> entry = mapIter.next();
final Map.Entry<PixelsKey, ImageSoftReference> entry =
mapIter.next();
mapIter.remove();
final Image img = entry.getValue().get();
if (img != null) img.flush();
currentPixelCount -= entry.getValue().pixelCount;
currentPixelCount -= entry.getValue().key.getPixelCount();
}
}
// finally put new in map
map.put(hash, new PixelCountSoftReference(image, referenceQueue, newPixelCount, hash, config, w, h, scale, state));
return true;
map.put(key, new ImageSoftReference(key, image, referenceQueue));
} finally {
lock.writeLock().unlock();
}
}
private static int hash(final GraphicsConfiguration config, final int w,
final int h, final int scale,
final JRSUIState state) {
int hash = config != null ? config.hashCode() : 0;
hash = 31 * hash + w;
hash = 31 * hash + h;
hash = 31 * hash + scale;
hash = 31 * hash + state.hashCode();
return hash;
}
public interface PixelsKey {
/**
* Extended SoftReference that stores the pixel count even after the image
* is lost.
*/
private static class PixelCountSoftReference extends SoftReference<Image> {
int getPixelCount();
}
// default access, because access to these fields shouldn't be emulated
// by a synthetic accessor.
final int pixelCount;
final int hash;
private static class ImageSoftReference extends SoftReference<Image> {
// key parts
private final GraphicsConfiguration config;
private final int w;
private final int h;
private final int scale;
private final JRSUIState state;
final PixelsKey key;
PixelCountSoftReference(final Image referent,
final ReferenceQueue<? super Image> q, final int pixelCount,
final int hash, final GraphicsConfiguration config, final int w,
final int h, final int scale, final JRSUIState state) {
ImageSoftReference(final PixelsKey key, final Image referent,
final ReferenceQueue<? super Image> q) {
super(referent, q);
this.pixelCount = pixelCount;
this.hash = hash;
this.config = config;
this.w = w;
this.h = h;
this.scale = scale;
this.state = state;
}
boolean equals(final GraphicsConfiguration config, final int w,
final int h, final int scale, final JRSUIState state) {
return config == this.config && w == this.w && h == this.h
&& scale == this.scale && state.equals(this.state);
this.key = key;
}
}
// /** Gets the rendered image for this painter at the requested size, either from cache or create a new one */
// private VolatileImage getImage(GraphicsConfiguration config, JComponent c, int w, int h, Object[] extendedCacheKeys) {
// VolatileImage buffer = (VolatileImage)getImage(config, w, h, this, extendedCacheKeys);
//
// int renderCounter = 0; // to avoid any potential, though unlikely, infinite loop
// do {
// //validate the buffer so we can check for surface loss
// int bufferStatus = VolatileImage.IMAGE_INCOMPATIBLE;
// if (buffer != null) {
// bufferStatus = buffer.validate(config);
// }
//
// //If the buffer status is incompatible or restored, then we need to re-render to the volatile image
// if (bufferStatus == VolatileImage.IMAGE_INCOMPATIBLE || bufferStatus == VolatileImage.IMAGE_RESTORED) {
// // if the buffer isn't the right size, or has lost its contents, then recreate
// if (buffer != null) {
// if (buffer.getWidth() != w || buffer.getHeight() != h || bufferStatus == VolatileImage.IMAGE_INCOMPATIBLE) {
// // clear any resources related to the old back buffer
// buffer.flush();
// buffer = null;
// }
// }
//
// if (buffer == null) {
// // recreate the buffer
// buffer = config.createCompatibleVolatileImage(w, h, Transparency.TRANSLUCENT);
// // put in cache for future
// setImage(buffer, config, w, h, this, extendedCacheKeys);
// }
//
// //create the graphics context with which to paint to the buffer
// Graphics2D bg = buffer.createGraphics();
//
// //clear the background before configuring the graphics
// bg.setComposite(AlphaComposite.Clear);
// bg.fillRect(0, 0, w, h);
// bg.setComposite(AlphaComposite.SrcOver);
// bg.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
//
// // paint the painter into buffer
// paint0(bg, c, w, h, extendedCacheKeys);
// //close buffer graphics
// bg.dispose();
// }
// } while (buffer.contentsLost() && renderCounter++ < 3);
//
// // check if we failed
// if (renderCounter >= 3) return null;
//
// return buffer;
// }
}
......@@ -26,46 +26,152 @@ package sun.awt.image;
import java.awt.Image;
import java.awt.Graphics;
import java.awt.geom.Dimension2D;
import java.awt.image.BufferedImage;
import java.awt.image.ImageObserver;
import java.util.Arrays;
import java.util.List;
import java.util.function.Function;
import java.util.function.BiFunction;
import java.util.stream.Collectors;
public class MultiResolutionBufferedImage extends BufferedImage
implements MultiResolutionImage {
Image[] resolutionVariants;
int baseIndex;
private final BiFunction<Integer, Integer, Image> mapper;
private final Dimension2D[] sizes;
private int availableInfo;
public MultiResolutionBufferedImage(int imageType, int baseIndex, Image... images) {
super(images[baseIndex].getWidth(null), images[baseIndex].getHeight(null),
imageType);
this.baseIndex = baseIndex;
this.resolutionVariants = images;
public MultiResolutionBufferedImage(Image baseImage,
Dimension2D[] sizes, BiFunction<Integer, Integer, Image> mapper) {
super(baseImage.getWidth(null), baseImage.getHeight(null),
BufferedImage.TYPE_INT_ARGB_PRE);
this.sizes = sizes;
this.mapper = mapper;
this.availableInfo = getInfo(baseImage);
Graphics g = getGraphics();
g.drawImage(images[baseIndex], 0, 0, null);
g.drawImage(baseImage, 0, 0, null);
g.dispose();
images[baseIndex] = this;
}
@Override
public Image getResolutionVariant(int width, int height) {
for (Image image : resolutionVariants) {
if (width <= image.getWidth(null) && height <= image.getHeight(null)) {
return image;
}
int baseWidth = getWidth();
int baseHeight = getHeight();
if (baseWidth == width && baseHeight == height) {
return this;
}
return this;
ImageCache cache = ImageCache.getInstance();
ImageCacheKey key = new ImageCacheKey(this, width, height);
Image resolutionVariant = cache.getImage(key);
if (resolutionVariant == null) {
resolutionVariant = mapper.apply(width, height);
cache.setImage(key, resolutionVariant);
preload(resolutionVariant, availableInfo);
}
return resolutionVariant;
}
@Override
public List<Image> getResolutionVariants() {
return Arrays.asList(resolutionVariants);
return Arrays.stream(sizes).map((Function<Dimension2D, Image>) size
-> getResolutionVariant((int) size.getWidth(),
(int) size.getHeight())).collect(Collectors.toList());
}
public MultiResolutionBufferedImage map(Function<Image, Image> mapper) {
return new MultiResolutionBufferedImage(getType(), baseIndex,
Arrays.stream(resolutionVariants).map(mapper)
.toArray(length -> new Image[length]));
return new MultiResolutionBufferedImage(mapper.apply(this), sizes,
(width, height) ->
mapper.apply(getResolutionVariant(width, height)));
}
@Override
public int getWidth(ImageObserver observer) {
availableInfo |= ImageObserver.WIDTH;
return super.getWidth(observer);
}
@Override
public int getHeight(ImageObserver observer) {
availableInfo |= ImageObserver.HEIGHT;
return super.getHeight(observer);
}
@Override
public Object getProperty(String name, ImageObserver observer) {
availableInfo |= ImageObserver.PROPERTIES;
return super.getProperty(name, observer);
}
private static int getInfo(Image image) {
if (image instanceof ToolkitImage) {
return ((ToolkitImage) image).getImageRep().check(
(img, infoflags, x, y, w, h) -> false);
}
return 0;
}
private static void preload(Image image, int availableInfo) {
if (image instanceof ToolkitImage) {
((ToolkitImage) image).preload(new ImageObserver() {
int flags = availableInfo;
@Override
public boolean imageUpdate(Image img, int infoflags,
int x, int y, int width, int height) {
flags &= ~infoflags;
return (flags != 0) && ((infoflags
& (ImageObserver.ERROR | ImageObserver.ABORT)) == 0);
}
});
}
}
private static class ImageCacheKey implements ImageCache.PixelsKey {
private final int pixelCount;
private final int hash;
private final int w;
private final int h;
private final Image baseImage;
ImageCacheKey(final Image baseImage,
final int w, final int h) {
this.baseImage = baseImage;
this.w = w;
this.h = h;
this.pixelCount = w * h;
hash = hash();
}
@Override
public int getPixelCount() {
return pixelCount;
}
private int hash() {
int hash = baseImage.hashCode();
hash = 31 * hash + w;
hash = 31 * hash + h;
return hash;
}
@Override
public int hashCode() {
return hash;
}
@Override
public boolean equals(Object obj) {
if (obj instanceof ImageCacheKey) {
ImageCacheKey key = (ImageCacheKey) obj;
return baseImage == key.baseImage && w == key.w && h == key.h;
}
return false;
}
}
}
}
\ No newline at end of file
......@@ -443,20 +443,6 @@ public class ValueConversions {
return x;
}
/**
* Identity function, with reference cast.
* @param t an arbitrary reference type
* @param x an arbitrary reference value
* @return the same value x
*/
@SuppressWarnings("unchecked")
static <T,U> T castReference(Class<? extends T> t, U x) {
// inlined Class.cast because we can't ForceInline it
if (x != null && !t.isInstance(x))
throw newClassCastException(t, x);
return (T) x;
}
private static ClassCastException newClassCastException(Class<?> t, Object obj) {
return new ClassCastException("Cannot cast " + obj.getClass().getName() + " to " + t.getName());
}
......@@ -466,12 +452,10 @@ public class ValueConversions {
static {
try {
MethodType idType = MethodType.genericMethodType(1);
MethodType castType = idType.insertParameterTypes(0, Class.class);
MethodType ignoreType = idType.changeReturnType(void.class);
MethodType zeroObjectType = MethodType.genericMethodType(0);
IDENTITY = IMPL_LOOKUP.findStatic(THIS_CLASS, "identity", idType);
//CAST_REFERENCE = IMPL_LOOKUP.findVirtual(Class.class, "cast", idType);
CAST_REFERENCE = IMPL_LOOKUP.findStatic(THIS_CLASS, "castReference", castType);
CAST_REFERENCE = IMPL_LOOKUP.findVirtual(Class.class, "cast", idType);
ZERO_OBJECT = IMPL_LOOKUP.findStatic(THIS_CLASS, "zeroObject", zeroObjectType);
IGNORE = IMPL_LOOKUP.findStatic(THIS_CLASS, "ignore", ignoreType);
EMPTY = IMPL_LOOKUP.findStatic(THIS_CLASS, "empty", ignoreType.dropParameterTypes(0, 1));
......@@ -509,6 +493,9 @@ public class ValueConversions {
* and returns it as the given type.
*/
public static MethodHandle cast(Class<?> type) {
return cast(type, CAST_REFERENCE);
}
public static MethodHandle cast(Class<?> type, MethodHandle castReference) {
if (type.isPrimitive()) throw new IllegalArgumentException("cannot cast primitive type "+type);
MethodHandle mh;
Wrapper wrap = null;
......@@ -519,7 +506,7 @@ public class ValueConversions {
mh = cache.get(wrap);
if (mh != null) return mh;
}
mh = MethodHandles.insertArguments(CAST_REFERENCE, 0, type);
mh = MethodHandles.insertArguments(castReference, 0, type);
if (cache != null)
cache.put(wrap, mh);
return mh;
......
......@@ -2430,6 +2430,8 @@ public final class SunGraphics2D
surfaceData = NullSurfaceData.theInstance;
}
invalidatePipe();
// this will recalculate the composite clip
setDevClip(surfaceData.getBounds());
......
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -31,6 +31,7 @@ import java.net.Authenticator.RequestorType;
import java.util.Base64;
import java.util.HashMap;
import sun.net.www.HeaderParser;
import sun.util.logging.PlatformLogger;
import static sun.net.www.protocol.http.AuthScheme.NEGOTIATE;
import static sun.net.www.protocol.http.AuthScheme.KERBEROS;
......@@ -44,6 +45,7 @@ import static sun.net.www.protocol.http.AuthScheme.KERBEROS;
class NegotiateAuthentication extends AuthenticationInfo {
private static final long serialVersionUID = 100L;
private static final PlatformLogger logger = HttpURLConnection.getHttpLogger();
final private HttpCallerInfo hci;
......@@ -78,6 +80,31 @@ class NegotiateAuthentication extends AuthenticationInfo {
return false;
}
/**
* Find out if the HttpCallerInfo supports Negotiate protocol.
* @return true if supported
*/
public static boolean isSupported(HttpCallerInfo hci) {
ClassLoader loader = null;
try {
loader = Thread.currentThread().getContextClassLoader();
} catch (SecurityException se) {
if (logger.isLoggable(PlatformLogger.Level.FINER)) {
logger.finer("NegotiateAuthentication: " +
"Attempt to get the context class loader failed - " + se);
}
}
if (loader != null) {
// Lock on the class loader instance to avoid the deadlock engaging
// the lock in "ClassLoader.loadClass(String, boolean)" method.
synchronized (loader) {
return isSupportedImpl(hci);
}
}
return isSupportedImpl(hci);
}
/**
* Find out if the HttpCallerInfo supports Negotiate protocol. In order to
* find out yes or no, an initialization of a Negotiator object against it
......@@ -89,7 +116,7 @@ class NegotiateAuthentication extends AuthenticationInfo {
*
* @return true if supported
*/
synchronized public static boolean isSupported(HttpCallerInfo hci) {
private static synchronized boolean isSupportedImpl(HttpCallerInfo hci) {
if (supported == null) {
supported = new HashMap <String, Boolean>();
cache = new HashMap <String, Negotiator>();
......
......@@ -549,12 +549,11 @@ public class Config {
previous = line.substring(1).trim();
}
} else {
if (previous == null) {
throw new KrbException(
"Config file must starts with a section");
// Lines before the first section are ignored
if (previous != null) {
v.add(previous);
previous = line;
}
v.add(previous);
previous = line;
}
}
if (previous != null) {
......
......@@ -94,9 +94,6 @@ public final class PKIXCertPathValidator extends CertPathValidatorSpi {
X509Certificate firstCert = certList.get(0);
// check trusted certificate's subject
selector.setSubject(firstCert.getIssuerX500Principal());
// check the validity period
selector.setValidityPeriod(firstCert.getNotBefore(),
firstCert.getNotAfter());
/*
* Facilitate certification path construction with authority
* key identifier and subject key identifier.
......
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -34,29 +34,9 @@ import sun.security.util.*;
/**
* The reasonCode is a non-critical CRL entry extension that identifies
* the reason for the certificate revocation. CAs are strongly
* encouraged to include reason codes in CRL entries; however, the
* reason code CRL entry extension should be absent instead of using the
* unspecified (0) reasonCode value.
* <p>The ASN.1 syntax for this is:
* <pre>
* id-ce-cRLReason OBJECT IDENTIFIER ::= { id-ce 21 }
*
* -- reasonCode ::= { CRLReason }
*
* CRLReason ::= ENUMERATED {
* unspecified (0),
* keyCompromise (1),
* cACompromise (2),
* affiliationChanged (3),
* superseded (4),
* cessationOfOperation (5),
* certificateHold (6),
* removeFromCRL (8),
* privilegeWithdrawn (9),
* aACompromise (10) }
* </pre>
* the reason for the certificate revocation.
* @author Hemma Prafullchandra
* @see java.security.cert.CRLReason
* @see Extension
* @see CertAttrSet
*/
......@@ -64,23 +44,11 @@ public class CRLReasonCodeExtension extends Extension
implements CertAttrSet<String> {
/**
* Attribute name and Reason codes
* Attribute name
*/
public static final String NAME = "CRLReasonCode";
public static final String REASON = "reason";
public static final int UNSPECIFIED = 0;
public static final int KEY_COMPROMISE = 1;
public static final int CA_COMPROMISE = 2;
public static final int AFFLIATION_CHANGED = 3;
public static final int SUPERSEDED = 4;
public static final int CESSATION_OF_OPERATION = 5;
public static final int CERTIFICATE_HOLD = 6;
// note 7 missing in syntax
public static final int REMOVE_FROM_CRL = 8;
public static final int PRIVILEGE_WITHDRAWN = 9;
public static final int AA_COMPROMISE = 10;
private static CRLReason[] values = CRLReason.values();
private int reasonCode = 0;
......@@ -181,7 +149,7 @@ public class CRLReasonCodeExtension extends Extension
* Returns a printable representation of the Reason code.
*/
public String toString() {
return super.toString() + " Reason Code: " + values[reasonCode];
return super.toString() + " Reason Code: " + getReasonCode();
}
/**
......
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -57,10 +57,10 @@ public class FormatData_es_CL extends ParallelListResourceBundle {
},
{ "TimePatterns",
new String[] {
"hh:mm:ss a z", // full time pattern
"hh:mm:ss a z", // long time pattern
"hh:mm:ss a", // medium time pattern
"hh:mm a", // short time pattern
"HH:mm:ss zzzz", // full time pattern
"H:mm:ss z", // long time pattern
"H:mm:ss", // medium time pattern
"H:mm", // short time pattern
}
},
{ "DatePatterns",
......
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -72,10 +72,10 @@ public class FormatData_es_EC extends ParallelListResourceBundle {
},
{ "TimePatterns",
new String[] {
"hh:mm:ss a z", // full time pattern
"hh:mm:ss a z", // long time pattern
"hh:mm:ss a", // medium time pattern
"hh:mm a", // short time pattern
"HH:mm:ss zzzz", // full time pattern
"H:mm:ss z", // long time pattern
"H:mm:ss", // medium time pattern
"H:mm", // short time pattern
}
},
{ "DatePatterns",
......
......@@ -222,10 +222,16 @@ void FontInstanceAdapter::getKerningAdjustment(LEPoint &adjustment) const
jobject pt = env->NewObject(sunFontIDs.pt2DFloatClass,
sunFontIDs.pt2DFloatCtr,
adjustment.fX, adjustment.fY);
if (pt == NULL) {
env->ExceptionClear();
adjustment.fX = 0.0f;
adjustment.fY = 0.0f;
} else {
env->CallObjectMethod(fontStrike, sunFontIDs.adjustPointMID, pt);
adjustment.fX = env->GetFloatField(pt, sunFontIDs.xFID);
adjustment.fY = env->GetFloatField(pt, sunFontIDs.yFID);
}
}
void FontInstanceAdapter::getWideGlyphAdvance(le_uint32 glyph, LEPoint &advance) const
{
......
......@@ -56,50 +56,13 @@ static jfieldID gvdIndicesFID = 0;
JNIEXPORT void JNICALL
Java_sun_font_SunLayoutEngine_initGVIDs
(JNIEnv *env, jclass cls) {
gvdClass = env->FindClass(gvdClassName);
if (!gvdClass) {
JNU_ThrowClassNotFoundException(env, gvdClassName);
return;
}
gvdClass = (jclass)env->NewGlobalRef(gvdClass);
if (!gvdClass) {
JNU_ThrowInternalError(env, "could not create global ref");
return;
}
gvdCountFID = env->GetFieldID(gvdClass, "_count", "I");
if (!gvdCountFID) {
gvdClass = 0;
JNU_ThrowNoSuchFieldException(env, "_count");
return;
}
gvdFlagsFID = env->GetFieldID(gvdClass, "_flags", "I");
if (!gvdFlagsFID) {
gvdClass = 0;
JNU_ThrowNoSuchFieldException(env, "_flags");
return;
}
gvdGlyphsFID = env->GetFieldID(gvdClass, "_glyphs", "[I");
if (!gvdGlyphsFID) {
gvdClass = 0;
JNU_ThrowNoSuchFieldException(env, "_glyphs");
return;
}
gvdPositionsFID = env->GetFieldID(gvdClass, "_positions", "[F");
if (!gvdPositionsFID) {
gvdClass = 0;
JNU_ThrowNoSuchFieldException(env, "_positions");
return;
}
CHECK_NULL(gvdClass = env->FindClass(gvdClassName));
CHECK_NULL(gvdClass = (jclass)env->NewGlobalRef(gvdClass));
CHECK_NULL(gvdCountFID = env->GetFieldID(gvdClass, "_count", "I"));
CHECK_NULL(gvdFlagsFID = env->GetFieldID(gvdClass, "_flags", "I"));
CHECK_NULL(gvdGlyphsFID = env->GetFieldID(gvdClass, "_glyphs", "[I"));
CHECK_NULL(gvdPositionsFID = env->GetFieldID(gvdClass, "_positions", "[F"));
gvdIndicesFID = env->GetFieldID(gvdClass, "_indices", "[I");
if (!gvdIndicesFID) {
gvdClass = 0;
JNU_ThrowNoSuchFieldException(env, "_indices");
return;
}
}
int putGV(JNIEnv* env, jint gmask, jint baseIndex, jobject gvdata, const LayoutEngine* engine, int glyphCount) {
......@@ -195,7 +158,7 @@ JNIEXPORT void JNICALL Java_sun_font_SunLayoutEngine_nativeLayout
jchar* chars = buffer;
if (len > 256) {
size_t size = len * sizeof(jchar);
if (size / sizeof(jchar) != len) {
if (size / sizeof(jchar) != (size_t)len) {
return;
}
chars = (jchar*)malloc(size);
......@@ -220,10 +183,12 @@ JNIEXPORT void JNICALL Java_sun_font_SunLayoutEngine_nativeLayout
env->SetIntField(gvdata, gvdCountFID, -1); // flag failure
} else {
if (putGV(env, gmask, baseIndex, gvdata, engine, glyphCount)) {
if (!(env->ExceptionCheck())) {
// !!! hmmm, could use current value in positions array of GVData...
putFloat(env, pt, x, y);
}
}
}
if (chars != buffer) {
free(chars);
......
......@@ -27,6 +27,7 @@
#include "string.h"
#include "gdefs.h"
#include "jlong.h"
#include "jni_util.h"
#include "sunfontids.h"
#include "fontscalerdefs.h"
#include "sun_font_SunFontManager.h"
......@@ -81,100 +82,106 @@ static void initFontIDs(JNIEnv *env) {
if (initialisedFontIDs) {
return;
}
tmpClass = (*env)->FindClass(env, "sun/font/TrueTypeFont");
sunFontIDs.ttReadBlockMID =
CHECK_NULL(tmpClass = (*env)->FindClass(env, "sun/font/TrueTypeFont"));
CHECK_NULL(sunFontIDs.ttReadBlockMID =
(*env)->GetMethodID(env, tmpClass, "readBlock",
"(Ljava/nio/ByteBuffer;II)I");
sunFontIDs.ttReadBytesMID =
(*env)->GetMethodID(env, tmpClass, "readBytes", "(II)[B");
"(Ljava/nio/ByteBuffer;II)I"));
CHECK_NULL(sunFontIDs.ttReadBytesMID =
(*env)->GetMethodID(env, tmpClass, "readBytes", "(II)[B"));
tmpClass = (*env)->FindClass(env, "sun/font/Type1Font");
sunFontIDs.readFileMID =
CHECK_NULL(tmpClass = (*env)->FindClass(env, "sun/font/Type1Font"));
CHECK_NULL(sunFontIDs.readFileMID =
(*env)->GetMethodID(env, tmpClass,
"readFile", "(Ljava/nio/ByteBuffer;)V");
"readFile", "(Ljava/nio/ByteBuffer;)V"));
tmpClass = (*env)->FindClass(env, "java/awt/geom/Point2D$Float");
CHECK_NULL(tmpClass =
(*env)->FindClass(env, "java/awt/geom/Point2D$Float"));
sunFontIDs.pt2DFloatClass = (jclass)(*env)->NewGlobalRef(env, tmpClass);
sunFontIDs.pt2DFloatCtr =
(*env)->GetMethodID(env, sunFontIDs.pt2DFloatClass, "<init>","(FF)V");
CHECK_NULL(sunFontIDs.pt2DFloatCtr =
(*env)->GetMethodID(env, sunFontIDs.pt2DFloatClass, "<init>","(FF)V"));
sunFontIDs.xFID =
(*env)->GetFieldID(env, sunFontIDs.pt2DFloatClass, "x", "F");
sunFontIDs.yFID =
(*env)->GetFieldID(env, sunFontIDs.pt2DFloatClass, "y", "F");
CHECK_NULL(sunFontIDs.xFID =
(*env)->GetFieldID(env, sunFontIDs.pt2DFloatClass, "x", "F"));
CHECK_NULL(sunFontIDs.yFID =
(*env)->GetFieldID(env, sunFontIDs.pt2DFloatClass, "y", "F"));
tmpClass = (*env)->FindClass(env, "sun/font/StrikeMetrics");
sunFontIDs.strikeMetricsClass=(jclass)(*env)->NewGlobalRef(env, tmpClass);
CHECK_NULL(tmpClass = (*env)->FindClass(env, "sun/font/StrikeMetrics"));
CHECK_NULL(sunFontIDs.strikeMetricsClass =
(jclass)(*env)->NewGlobalRef(env, tmpClass));
sunFontIDs.strikeMetricsCtr =
CHECK_NULL(sunFontIDs.strikeMetricsCtr =
(*env)->GetMethodID(env, sunFontIDs.strikeMetricsClass,
"<init>", "(FFFFFFFFFF)V");
"<init>", "(FFFFFFFFFF)V"));
tmpClass = (*env)->FindClass(env, "java/awt/geom/Rectangle2D$Float");
CHECK_NULL(tmpClass =
(*env)->FindClass(env, "java/awt/geom/Rectangle2D$Float"));
sunFontIDs.rect2DFloatClass = (jclass)(*env)->NewGlobalRef(env, tmpClass);
sunFontIDs.rect2DFloatCtr =
(*env)->GetMethodID(env, sunFontIDs.rect2DFloatClass, "<init>", "()V");
sunFontIDs.rect2DFloatCtr4 =
CHECK_NULL(sunFontIDs.rect2DFloatCtr =
(*env)->GetMethodID(env, sunFontIDs.rect2DFloatClass, "<init>", "()V"));
CHECK_NULL(sunFontIDs.rect2DFloatCtr4 =
(*env)->GetMethodID(env, sunFontIDs.rect2DFloatClass,
"<init>", "(FFFF)V");
sunFontIDs.rectF2DX =
(*env)->GetFieldID(env, sunFontIDs.rect2DFloatClass, "x", "F");
sunFontIDs.rectF2DY =
(*env)->GetFieldID(env, sunFontIDs.rect2DFloatClass, "y", "F");
sunFontIDs.rectF2DWidth =
(*env)->GetFieldID(env, sunFontIDs.rect2DFloatClass, "width", "F");
sunFontIDs.rectF2DHeight =
(*env)->GetFieldID(env, sunFontIDs.rect2DFloatClass, "height", "F");
tmpClass = (*env)->FindClass(env, "java/awt/geom/GeneralPath");
"<init>", "(FFFF)V"));
CHECK_NULL(sunFontIDs.rectF2DX =
(*env)->GetFieldID(env, sunFontIDs.rect2DFloatClass, "x", "F"));
CHECK_NULL(sunFontIDs.rectF2DY =
(*env)->GetFieldID(env, sunFontIDs.rect2DFloatClass, "y", "F"));
CHECK_NULL(sunFontIDs.rectF2DWidth =
(*env)->GetFieldID(env, sunFontIDs.rect2DFloatClass, "width", "F"));
CHECK_NULL(sunFontIDs.rectF2DHeight =
(*env)->GetFieldID(env, sunFontIDs.rect2DFloatClass, "height", "F"));
CHECK_NULL(tmpClass = (*env)->FindClass(env, "java/awt/geom/GeneralPath"));
sunFontIDs.gpClass = (jclass)(*env)->NewGlobalRef(env, tmpClass);
sunFontIDs.gpCtr =
(*env)->GetMethodID(env, sunFontIDs.gpClass, "<init>", "(I[BI[FI)V");
sunFontIDs.gpCtrEmpty =
(*env)->GetMethodID(env, sunFontIDs.gpClass, "<init>", "()V");
tmpClass = (*env)->FindClass(env, "sun/font/Font2D");
sunFontIDs.f2dCharToGlyphMID =
(*env)->GetMethodID(env, tmpClass, "charToGlyph", "(I)I");
sunFontIDs.getMapperMID =
CHECK_NULL(sunFontIDs.gpCtr =
(*env)->GetMethodID(env, sunFontIDs.gpClass, "<init>", "(I[BI[FI)V"));
CHECK_NULL(sunFontIDs.gpCtrEmpty =
(*env)->GetMethodID(env, sunFontIDs.gpClass, "<init>", "()V"));
CHECK_NULL(tmpClass = (*env)->FindClass(env, "sun/font/Font2D"));
CHECK_NULL(sunFontIDs.f2dCharToGlyphMID =
(*env)->GetMethodID(env, tmpClass, "charToGlyph", "(I)I"));
CHECK_NULL(sunFontIDs.getMapperMID =
(*env)->GetMethodID(env, tmpClass, "getMapper",
"()Lsun/font/CharToGlyphMapper;");
sunFontIDs.getTableBytesMID =
(*env)->GetMethodID(env, tmpClass, "getTableBytes", "(I)[B");
sunFontIDs.canDisplayMID =
(*env)->GetMethodID(env, tmpClass, "canDisplay", "(C)Z");
tmpClass = (*env)->FindClass(env, "sun/font/CharToGlyphMapper");
sunFontIDs.charToGlyphMID =
(*env)->GetMethodID(env, tmpClass, "charToGlyph", "(I)I");
tmpClass = (*env)->FindClass(env, "sun/font/PhysicalStrike");
sunFontIDs.getGlyphMetricsMID =
"()Lsun/font/CharToGlyphMapper;"));
CHECK_NULL(sunFontIDs.getTableBytesMID =
(*env)->GetMethodID(env, tmpClass, "getTableBytes", "(I)[B"));
CHECK_NULL(sunFontIDs.canDisplayMID =
(*env)->GetMethodID(env, tmpClass, "canDisplay", "(C)Z"));
CHECK_NULL(tmpClass = (*env)->FindClass(env, "sun/font/CharToGlyphMapper"));
CHECK_NULL(sunFontIDs.charToGlyphMID =
(*env)->GetMethodID(env, tmpClass, "charToGlyph", "(I)I"));
CHECK_NULL(tmpClass = (*env)->FindClass(env, "sun/font/PhysicalStrike"));
CHECK_NULL(sunFontIDs.getGlyphMetricsMID =
(*env)->GetMethodID(env, tmpClass, "getGlyphMetrics",
"(I)Ljava/awt/geom/Point2D$Float;");
sunFontIDs.getGlyphPointMID =
"(I)Ljava/awt/geom/Point2D$Float;"));
CHECK_NULL(sunFontIDs.getGlyphPointMID =
(*env)->GetMethodID(env, tmpClass, "getGlyphPoint",
"(II)Ljava/awt/geom/Point2D$Float;");
sunFontIDs.adjustPointMID =
"(II)Ljava/awt/geom/Point2D$Float;"));
CHECK_NULL(sunFontIDs.adjustPointMID =
(*env)->GetMethodID(env, tmpClass, "adjustPoint",
"(Ljava/awt/geom/Point2D$Float;)V");
sunFontIDs.pScalerContextFID =
(*env)->GetFieldID(env, tmpClass, "pScalerContext", "J");
tmpClass = (*env)->FindClass(env, "sun/font/GlyphList");
sunFontIDs.glyphListX = (*env)->GetFieldID(env, tmpClass, "x", "F");
sunFontIDs.glyphListY = (*env)->GetFieldID(env, tmpClass, "y", "F");
sunFontIDs.glyphListLen = (*env)->GetFieldID(env, tmpClass, "len", "I");
sunFontIDs.glyphImages =
(*env)->GetFieldID(env, tmpClass, "images", "[J");
sunFontIDs.glyphListUsePos =
(*env)->GetFieldID(env, tmpClass, "usePositions", "Z");
sunFontIDs.glyphListPos =
(*env)->GetFieldID(env, tmpClass, "positions", "[F");
sunFontIDs.lcdRGBOrder =
(*env)->GetFieldID(env, tmpClass, "lcdRGBOrder", "Z");
sunFontIDs.lcdSubPixPos =
(*env)->GetFieldID(env, tmpClass, "lcdSubPixPos", "Z");
"(Ljava/awt/geom/Point2D$Float;)V"));
CHECK_NULL(sunFontIDs.pScalerContextFID =
(*env)->GetFieldID(env, tmpClass, "pScalerContext", "J"));
CHECK_NULL(tmpClass = (*env)->FindClass(env, "sun/font/GlyphList"));
CHECK_NULL(sunFontIDs.glyphListX =
(*env)->GetFieldID(env, tmpClass, "x", "F"));
CHECK_NULL(sunFontIDs.glyphListY =
(*env)->GetFieldID(env, tmpClass, "y", "F"));
CHECK_NULL(sunFontIDs.glyphListLen =
(*env)->GetFieldID(env, tmpClass, "len", "I"));
CHECK_NULL(sunFontIDs.glyphImages =
(*env)->GetFieldID(env, tmpClass, "images", "[J"));
CHECK_NULL(sunFontIDs.glyphListUsePos =
(*env)->GetFieldID(env, tmpClass, "usePositions", "Z"));
CHECK_NULL(sunFontIDs.glyphListPos =
(*env)->GetFieldID(env, tmpClass, "positions", "[F"));
CHECK_NULL(sunFontIDs.lcdRGBOrder =
(*env)->GetFieldID(env, tmpClass, "lcdRGBOrder", "Z"));
CHECK_NULL(sunFontIDs.lcdSubPixPos =
(*env)->GetFieldID(env, tmpClass, "lcdSubPixPos", "Z"));
initLCDGammaTables();
......
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -30,20 +30,27 @@
// #define SECMOD_DEBUG
#include "j2secmod.h"
#include "jni_util.h"
JNIEXPORT jboolean JNICALL Java_sun_security_pkcs11_Secmod_nssVersionCheck
(JNIEnv *env, jclass thisClass, jlong jHandle, jstring jVersion)
{
const char *requiredVersion = (*env)->GetStringUTFChars(env, jVersion, NULL);
int res;
FPTR_VersionCheck versionCheck =
(FPTR_VersionCheck)findFunction(env, jHandle, "NSS_VersionCheck");
int res = 0;
FPTR_VersionCheck versionCheck;
const char *requiredVersion;
versionCheck = (FPTR_VersionCheck)findFunction(env, jHandle,
"NSS_VersionCheck");
if (versionCheck == NULL) {
return JNI_FALSE;
}
requiredVersion = (*env)->GetStringUTFChars(env, jVersion, NULL);
if (requiredVersion == NULL) {
return JNI_FALSE;
}
res = versionCheck(requiredVersion);
dprintf2("-version >=%s: %d\n", requiredVersion, res);
(*env)->ReleaseStringUTFChars(env, jVersion, requiredVersion);
......@@ -59,55 +66,73 @@ JNIEXPORT jboolean JNICALL Java_sun_security_pkcs11_Secmod_nssVersionCheck
JNIEXPORT jboolean JNICALL Java_sun_security_pkcs11_Secmod_nssInitialize
(JNIEnv *env, jclass thisClass, jstring jFunctionName, jlong jHandle, jstring jConfigDir, jboolean jNssOptimizeSpace)
{
const char *functionName =
(*env)->GetStringUTFChars(env, jFunctionName, NULL);
const char *configDir = (jConfigDir == NULL)
? NULL : (*env)->GetStringUTFChars(env, jConfigDir, NULL);
int res = 0;
FPTR_Initialize initialize =
(FPTR_Initialize)findFunction(env, jHandle, "NSS_Initialize");
int res = 0;
unsigned int flags = 0x00;
const char *configDir = NULL;
const char *functionName = NULL;
/* If we cannot initialize, exit now */
if (initialize == NULL) {
res = 1;
goto cleanup;
}
functionName = (*env)->GetStringUTFChars(env, jFunctionName, NULL);
if (functionName == NULL) {
res = 1;
goto cleanup;
}
if (jConfigDir != NULL) {
configDir = (*env)->GetStringUTFChars(env, jConfigDir, NULL);
if (!configDir) {
res = 1;
goto cleanup;
}
}
if (jNssOptimizeSpace == JNI_TRUE) {
flags = 0x20; // NSS_INIT_OPTIMIZESPACE flag
}
if (initialize != NULL) {
/*
* If the NSS_Init function is requested then call NSS_Initialize to
* open the Cert, Key and Security Module databases, read only.
*/
if (strcmp("NSS_Init", functionName) == 0) {
flags = flags | 0x01; // NSS_INIT_READONLY flag
res = initialize(configDir, "", "", "secmod.db", flags);
/*
* If the NSS_InitReadWrite function is requested then call
* NSS_Initialize to open the Cert, Key and Security Module databases,
* read/write.
*/
} else if (strcmp("NSS_InitReadWrite", functionName) == 0) {
res = initialize(configDir, "", "", "secmod.db", flags);
/*
* If the NSS_NoDB_Init function is requested then call
* NSS_Initialize without creating Cert, Key or Security Module
* databases.
*/
} else if (strcmp("NSS_NoDB_Init", functionName) == 0) {
flags = flags | 0x02 // NSS_INIT_NOCERTDB flag
| 0x04 // NSS_INIT_NOMODDB flag
| 0x08 // NSS_INIT_FORCEOPEN flag
| 0x10; // NSS_INIT_NOROOTINIT flag
res = initialize("", "", "", "", flags);
/*
* If the NSS_Init function is requested then call NSS_Initialize to
* open the Cert, Key and Security Module databases, read only.
*/
if (strcmp("NSS_Init", functionName) == 0) {
flags = flags | 0x01; // NSS_INIT_READONLY flag
res = initialize(configDir, "", "", "secmod.db", flags);
/*
* If the NSS_InitReadWrite function is requested then call
* NSS_Initialize to open the Cert, Key and Security Module databases,
* read/write.
*/
} else if (strcmp("NSS_InitReadWrite", functionName) == 0) {
res = initialize(configDir, "", "", "secmod.db", flags);
/*
* If the NSS_NoDB_Init function is requested then call
* NSS_Initialize without creating Cert, Key or Security Module
* databases.
*/
} else if (strcmp("NSS_NoDB_Init", functionName) == 0) {
flags = flags | 0x02 // NSS_INIT_NOCERTDB flag
| 0x04 // NSS_INIT_NOMODDB flag
| 0x08 // NSS_INIT_FORCEOPEN flag
| 0x10; // NSS_INIT_NOROOTINIT flag
res = initialize("", "", "", "", flags);
} else {
res = 2;
}
} else {
res = 1;
res = 2;
}
cleanup:
if (functionName != NULL) {
(*env)->ReleaseStringUTFChars(env, jFunctionName, functionName);
}
(*env)->ReleaseStringUTFChars(env, jFunctionName, functionName);
if (configDir != NULL) {
(*env)->ReleaseStringUTFChars(env, jConfigDir, configDir);
}
......@@ -142,13 +167,30 @@ JNIEXPORT jobject JNICALL Java_sun_security_pkcs11_Secmod_nssGetModuleList
}
jListClass = (*env)->FindClass(env, "java/util/ArrayList");
if (jListClass == NULL) {
return NULL;
}
jListConstructor = (*env)->GetMethodID(env, jListClass, "<init>", "()V");
if (jListConstructor == NULL) {
return NULL;
}
jAdd = (*env)->GetMethodID(env, jListClass, "add", "(Ljava/lang/Object;)Z");
if (jAdd == NULL) {
return NULL;
}
jList = (*env)->NewObject(env, jListClass, jListConstructor);
if (jList == NULL) {
return NULL;
}
jModuleClass = (*env)->FindClass(env, "sun/security/pkcs11/Secmod$Module");
if (jModuleClass == NULL) {
return NULL;
}
jModuleConstructor = (*env)->GetMethodID(env, jModuleClass, "<init>",
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZI)V");
if (jModuleConstructor == NULL) {
return NULL;
}
while (list != NULL) {
module = list->module;
......@@ -160,16 +202,28 @@ JNIEXPORT jobject JNICALL Java_sun_security_pkcs11_Secmod_nssGetModuleList
dprintf1("-internal: %d\n", module->internal);
dprintf1("-fips: %d\n", module->isFIPS);
jCommonName = (*env)->NewStringUTF(env, module->commonName);
if (jCommonName == NULL) {
return NULL;
}
if (module->dllName == NULL) {
jDllName = NULL;
} else {
jDllName = (*env)->NewStringUTF(env, module->dllName);
if (jDllName == NULL) {
return NULL;
}
}
jFIPS = module->isFIPS;
for (i = 0; i < module->slotCount; i++ ) {
jModule = (*env)->NewObject(env, jModuleClass, jModuleConstructor,
jLibDir, jDllName, jCommonName, jFIPS, i);
if (jModule == NULL) {
return NULL;
}
(*env)->CallVoidMethod(env, jList, jAdd, jModule);
if ((*env)->ExceptionCheck(env)) {
return NULL;
}
}
list = list->next;
}
......
......@@ -342,47 +342,39 @@ final class UNIXProcess extends Process {
ProcessPipeInputStream(int fd) {
super(new FileInputStream(newFileDescriptor(fd)));
}
private InputStream drainInputStream(InputStream in)
private static byte[] drainInputStream(InputStream in)
throws IOException {
int n = 0;
int j;
byte[] a = null;
synchronized (closeLock) {
if (buf == null) // asynchronous close()?
return null; // discard
j = in.available();
}
while (j > 0) {
while ((j = in.available()) > 0) {
a = (a == null) ? new byte[j] : Arrays.copyOf(a, n + j);
synchronized (closeLock) {
if (buf == null) // asynchronous close()?
return null; // discard
n += in.read(a, n, j);
j = in.available();
}
n += in.read(a, n, j);
}
return (a == null) ?
ProcessBuilder.NullInputStream.INSTANCE :
new ByteArrayInputStream(n == a.length ? a : Arrays.copyOf(a, n));
return (a == null || n == a.length) ? a : Arrays.copyOf(a, n);
}
/** Called by the process reaper thread when the process exits. */
synchronized void processExited() {
try {
InputStream in = this.in;
if (in != null) {
InputStream stragglers = drainInputStream(in);
in.close();
this.in = stragglers;
}
} catch (IOException ignored) { }
synchronized (closeLock) {
try {
InputStream in = this.in;
// this stream is closed if and only if: in == null
if (in != null) {
byte[] stragglers = drainInputStream(in);
in.close();
this.in = (stragglers == null) ?
ProcessBuilder.NullInputStream.INSTANCE :
new ByteArrayInputStream(stragglers);
}
} catch (IOException ignored) {}
}
}
@Override
public void close() throws IOException {
// BufferedInputStream#close() is not synchronized unlike most other methods.
// Synchronizing helps avoid racing with drainInputStream().
// Synchronizing helps avoid race with processExited().
synchronized (closeLock) {
super.close();
}
......
......@@ -344,47 +344,39 @@ final class UNIXProcess extends Process {
ProcessPipeInputStream(int fd) {
super(new FileInputStream(newFileDescriptor(fd)));
}
private InputStream drainInputStream(InputStream in)
private static byte[] drainInputStream(InputStream in)
throws IOException {
int n = 0;
int j;
byte[] a = null;
synchronized (closeLock) {
if (buf == null) // asynchronous close()?
return null; // discard
j = in.available();
}
while (j > 0) {
while ((j = in.available()) > 0) {
a = (a == null) ? new byte[j] : Arrays.copyOf(a, n + j);
synchronized (closeLock) {
if (buf == null) // asynchronous close()?
return null; // discard
n += in.read(a, n, j);
j = in.available();
}
n += in.read(a, n, j);
}
return (a == null) ?
ProcessBuilder.NullInputStream.INSTANCE :
new ByteArrayInputStream(n == a.length ? a : Arrays.copyOf(a, n));
return (a == null || n == a.length) ? a : Arrays.copyOf(a, n);
}
/** Called by the process reaper thread when the process exits. */
synchronized void processExited() {
try {
InputStream in = this.in;
if (in != null) {
InputStream stragglers = drainInputStream(in);
in.close();
this.in = stragglers;
}
} catch (IOException ignored) { }
synchronized (closeLock) {
try {
InputStream in = this.in;
// this stream is closed if and only if: in == null
if (in != null) {
byte[] stragglers = drainInputStream(in);
in.close();
this.in = (stragglers == null) ?
ProcessBuilder.NullInputStream.INSTANCE :
new ByteArrayInputStream(stragglers);
}
} catch (IOException ignored) {}
}
}
@Override
public void close() throws IOException {
// BufferedInputStream#close() is not synchronized unlike most other methods.
// Synchronizing helps avoid racing with drainInputStream().
// Synchronizing helps avoid race with processExited().
synchronized (closeLock) {
super.close();
}
......
......@@ -38,8 +38,7 @@
#include "sun_nio_ch_sctp_ResultContainer.h"
#include "sun_nio_ch_sctp_PeerAddrChange.h"
/* sizeof(union sctp_notification */
#define NOTIFICATION_BUFFER_SIZE 280
static int SCTP_NOTIFICATION_SIZE = sizeof(union sctp_notification);
#define MESSAGE_IMPL_CLASS "sun/nio/ch/sctp/MessageInfoImpl"
#define RESULT_CONTAINER_CLASS "sun/nio/ch/sctp/ResultContainer"
......@@ -460,20 +459,47 @@ JNIEXPORT jint JNICALL Java_sun_nio_ch_sctp_SctpChannelImpl_receive0
if (msg->msg_flags & MSG_NOTIFICATION) {
char *bufp = (char*)addr;
union sctp_notification *snp;
jboolean allocated = JNI_FALSE;
if (!(msg->msg_flags & MSG_EOR) && length < NOTIFICATION_BUFFER_SIZE) {
char buf[NOTIFICATION_BUFFER_SIZE];
if (rv > SCTP_NOTIFICATION_SIZE) {
JNU_ThrowInternalError(env, "should not reach here");
return -1;
}
if (!(msg->msg_flags & MSG_EOR) && length < SCTP_NOTIFICATION_SIZE) {
char* newBuf;
int rvSAVE = rv;
memcpy(buf, addr, rv);
iov->iov_base = buf + rv;
iov->iov_len = NOTIFICATION_BUFFER_SIZE - rv;
if ((newBuf = malloc(SCTP_NOTIFICATION_SIZE)) == NULL) {
JNU_ThrowOutOfMemoryError(env, "Out of native heap space.");
return -1;
}
allocated = JNI_TRUE;
memcpy(newBuf, addr, rv);
iov->iov_base = newBuf + rv;
iov->iov_len = SCTP_NOTIFICATION_SIZE - rv;
if ((rv = recvmsg(fd, msg, flags)) < 0) {
handleSocketError(env, errno);
return 0;
}
bufp = buf;
bufp = newBuf;
rv += rvSAVE;
}
#ifdef __sparc
else if ((intptr_t)addr & 0x3) {
/* the given buffer is not 4 byte aligned */
char* newBuf;
if ((newBuf = malloc(SCTP_NOTIFICATION_SIZE)) == NULL) {
JNU_ThrowOutOfMemoryError(env, "Out of native heap space.");
return -1;
}
allocated = JNI_TRUE;
memcpy(newBuf, addr, rv);
bufp = newBuf;
}
#endif
snp = (union sctp_notification *) bufp;
if (handleNotification(env, fd, resultContainerObj, snp, rv,
(msg->msg_flags & MSG_EOR),
......@@ -481,9 +507,16 @@ JNIEXPORT jint JNICALL Java_sun_nio_ch_sctp_SctpChannelImpl_receive0
/* We have received a notification that is of interest to
to the Java API. The appropriate notification will be
set in the result container. */
if (allocated == JNI_TRUE) {
free(bufp);
}
return 0;
}
if (allocated == JNI_TRUE) {
free(bufp);
}
// set iov back to addr, and reset msg_controllen
iov->iov_base = addr;
iov->iov_len = length;
......
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -49,6 +49,10 @@ JNIEXPORT jlong JNICALL Java_sun_security_pkcs11_Secmod_nssGetLibraryHandle
(JNIEnv *env, jclass thisClass, jstring jLibName)
{
const char *libName = (*env)->GetStringUTFChars(env, jLibName, NULL);
if (libName == NULL) {
return 0L;
}
// look up existing handle only, do not load
#if defined(AIX)
void *hModule = dlopen(libName, RTLD_LAZY);
......@@ -65,6 +69,9 @@ JNIEXPORT jlong JNICALL Java_sun_security_pkcs11_Secmod_nssLoadLibrary
{
void *hModule;
const char *libName = (*env)->GetStringUTFChars(env, jLibName, NULL);
if (libName == NULL) {
return 0L;
}
dprintf1("-lib %s\n", libName);
hModule = dlopen(libName, RTLD_LAZY);
......
/*
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
*/
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
......@@ -88,6 +88,9 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_connect
const char *getFunctionListStr;
const char *libraryNameStr = (*env)->GetStringUTFChars(env, jPkcs11ModulePath, 0);
if (libraryNameStr == NULL) {
return;
}
TRACE1("DEBUG: connect to PKCS#11 module: %s ... ", libraryNameStr);
......@@ -123,6 +126,9 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_connect
// with the old JAR file jGetFunctionList is null, temporarily check for that
if (jGetFunctionList != NULL) {
getFunctionListStr = (*env)->GetStringUTFChars(env, jGetFunctionList, 0);
if (getFunctionListStr == NULL) {
return;
}
C_GetFunctionList = (CK_C_GetFunctionList) dlsym(hModule, getFunctionListStr);
(*env)->ReleaseStringUTFChars(env, jGetFunctionList, getFunctionListStr);
}
......
/*
* Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -95,7 +95,9 @@ Java_sun_awt_DefaultMouseInfoPeer_fillPointWithCoords(JNIEnv *env, jclass cls, j
env->DeleteLocalRef(pointClassLocal);
}
xID = env->GetFieldID(pointClass, "x", "I");
CHECK_NULL_RETURN(xID, (jint)0);
yID = env->GetFieldID(pointClass, "y", "I");
CHECK_NULL_RETURN(yID, (jint)0);
env->SetIntField(point, xID, pt.x);
env->SetIntField(point, yID, pt.y);
......
......@@ -49,6 +49,7 @@ typedef AwtObject* PDATA;
#define JNI_CHECK_NULL_GOTO(obj, msg, where) { \
if (obj == NULL) { \
env->ExceptionClear(); \
JNU_ThrowNullPointerException(env, msg); \
goto where; \
} \
......@@ -65,6 +66,7 @@ typedef AwtObject* PDATA;
#define JNI_CHECK_NULL_RETURN(obj, msg) { \
if (obj == NULL) { \
env->ExceptionClear(); \
JNU_ThrowNullPointerException(env, msg); \
return; \
} \
......@@ -91,6 +93,7 @@ typedef AwtObject* PDATA;
#define JNI_CHECK_NULL_RETURN_NULL(obj, msg) { \
if (obj == NULL) { \
env->ExceptionClear(); \
JNU_ThrowNullPointerException(env, msg); \
return 0; \
} \
......@@ -98,6 +101,7 @@ typedef AwtObject* PDATA;
#define JNI_CHECK_NULL_RETURN_VAL(obj, msg, val) { \
if (obj == NULL) { \
env->ExceptionClear(); \
JNU_ThrowNullPointerException(env, msg); \
return val; \
} \
......@@ -124,6 +128,7 @@ typedef AwtObject* PDATA;
#define THROW_NULL_PDATA_IF_NOT_DESTROYED(peer) { \
jboolean destroyed = JNI_GET_DESTROYED(peer); \
if (destroyed != JNI_TRUE) { \
env->ExceptionClear(); \
JNU_ThrowNullPointerException(env, "null pData"); \
} \
}
......
......@@ -71,12 +71,16 @@ Java_java_awt_AWTEvent_initIDs(JNIEnv *env, jclass cls)
TRY;
AwtAWTEvent::bdataID = env->GetFieldID(cls, "bdata", "[B");
AwtAWTEvent::idID = env->GetFieldID(cls, "id", "I");
AwtAWTEvent::consumedID = env->GetFieldID(cls, "consumed", "Z");
DASSERT(AwtAWTEvent::bdataID != NULL);
CHECK_NULL(AwtAWTEvent::bdataID);
AwtAWTEvent::idID = env->GetFieldID(cls, "id", "I");
DASSERT(AwtAWTEvent::idID != NULL);
CHECK_NULL(AwtAWTEvent::idID);
AwtAWTEvent::consumedID = env->GetFieldID(cls, "consumed", "Z");
DASSERT(AwtAWTEvent::consumedID != NULL);
CHECK_NULL(AwtAWTEvent::consumedID);
CATCH_BAD_ALLOC;
}
......
......@@ -274,6 +274,9 @@ Java_sun_awt_windows_WDataTransferer_dragQueryFile
jclass str_clazz = env->FindClass("java/lang/String");
DASSERT(str_clazz != NULL);
if (str_clazz == NULL) {
throw std::bad_alloc();
}
jobjectArray filenames = env->NewObjectArray(nFilenames, str_clazz,
NULL);
if (filenames == NULL) {
......@@ -827,6 +830,7 @@ Java_sun_awt_windows_WDataTransferer_registerClipboardFormat(JNIEnv *env,
TRY;
LPCTSTR cStr = JNU_GetStringPlatformChars(env, str, NULL);
CHECK_NULL_RETURN(cStr, 0);
jlong value = ::RegisterClipboardFormat(cStr);
JNU_ReleaseStringPlatformChars(env, str, cStr);
......
/*
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -83,13 +83,19 @@ void AwtDesktopProperties::GetSystemProperties() {
HDC dc = CreateDC(TEXT("DISPLAY"), NULL, NULL, NULL);
if (dc != NULL) {
SetFontProperty(dc, ANSI_FIXED_FONT, TEXT("win.ansiFixed.font"));
SetFontProperty(dc, ANSI_VAR_FONT, TEXT("win.ansiVar.font"));
SetFontProperty(dc, DEVICE_DEFAULT_FONT, TEXT("win.deviceDefault.font"));
SetFontProperty(dc, DEFAULT_GUI_FONT, TEXT("win.defaultGUI.font"));
SetFontProperty(dc, OEM_FIXED_FONT, TEXT("win.oemFixed.font"));
SetFontProperty(dc, SYSTEM_FONT, TEXT("win.system.font"));
SetFontProperty(dc, SYSTEM_FIXED_FONT, TEXT("win.systemFixed.font"));
try {
SetFontProperty(dc, ANSI_FIXED_FONT, TEXT("win.ansiFixed.font"));
SetFontProperty(dc, ANSI_VAR_FONT, TEXT("win.ansiVar.font"));
SetFontProperty(dc, DEVICE_DEFAULT_FONT, TEXT("win.deviceDefault.font"));
SetFontProperty(dc, DEFAULT_GUI_FONT, TEXT("win.defaultGUI.font"));
SetFontProperty(dc, OEM_FIXED_FONT, TEXT("win.oemFixed.font"));
SetFontProperty(dc, SYSTEM_FONT, TEXT("win.system.font"));
SetFontProperty(dc, SYSTEM_FIXED_FONT, TEXT("win.systemFixed.font"));
}
catch (std::bad_alloc&) {
DeleteDC(dc);
throw;
}
DeleteDC(dc);
}
}
......@@ -206,24 +212,35 @@ void AwtDesktopProperties::GetXPStyleProperties() {
LPTSTR value;
value = getXPStylePropFromReg(TEXT("ThemeActive"));
SetBooleanProperty(TEXT("win.xpstyle.themeActive"), (value != NULL && *value == _T('1')));
if (value != NULL) {
free(value);
}
value = getXPStylePropFromReg(TEXT("DllName"));
if (value != NULL) {
SetStringProperty(TEXT("win.xpstyle.dllName"), value);
free(value);
}
value = getXPStylePropFromReg(TEXT("SizeName"));
if (value != NULL) {
SetStringProperty(TEXT("win.xpstyle.sizeName"), value);
free(value);
try {
SetBooleanProperty(TEXT("win.xpstyle.themeActive"), (value != NULL && *value == _T('1')));
if (value != NULL) {
free(value);
value = NULL;
}
value = getXPStylePropFromReg(TEXT("DllName"));
if (value != NULL) {
SetStringProperty(TEXT("win.xpstyle.dllName"), value);
free(value);
value = NULL;
}
value = getXPStylePropFromReg(TEXT("SizeName"));
if (value != NULL) {
SetStringProperty(TEXT("win.xpstyle.sizeName"), value);
free(value);
value = NULL;
}
value = getXPStylePropFromReg(TEXT("ColorName"));
if (value != NULL) {
SetStringProperty(TEXT("win.xpstyle.colorName"), value);
free(value);
}
}
value = getXPStylePropFromReg(TEXT("ColorName"));
if (value != NULL) {
SetStringProperty(TEXT("win.xpstyle.colorName"), value);
free(value);
catch (std::bad_alloc&) {
if (value != NULL) {
free(value);
}
throw;
}
}
......@@ -564,27 +581,37 @@ void AwtDesktopProperties::GetOtherParameters() {
// Shell Icon BPP - only honored on platforms before XP
value = getWindowsPropFromReg(TEXT("Control Panel\\Desktop\\WindowMetrics"),
TEXT("Shell Icon BPP"), &valueType);
if (value != NULL) {
if (valueType == REG_SZ) {
SetStringProperty(TEXT("win.icon.shellIconBPP"), value);
try {
if (value != NULL) {
if (valueType == REG_SZ) {
SetStringProperty(TEXT("win.icon.shellIconBPP"), value);
}
free(value);
value = NULL;
}
free(value);
}
// The following registry settings control the file chooser places bar
// under the Windows L&F. These settings are not present by default, but
// can be enabled using the TweakUI tool from Microsoft. For more info,
// see http://msdn.microsoft.com/msdnmag/issues/1100/Registry/
// The following registry settings control the file chooser places bar
// under the Windows L&F. These settings are not present by default, but
// can be enabled using the TweakUI tool from Microsoft. For more info,
// see http://msdn.microsoft.com/msdnmag/issues/1100/Registry/
// NoPlacesBar is a REG_DWORD, with values 0 or 1
value = getWindowsPropFromReg(TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\comdlg32"),
TEXT("NoPlacesBar"), &valueType);
if (value != NULL) {
if (valueType == REG_DWORD) {
SetBooleanProperty(TEXT("win.comdlg.noPlacesBar"), (BOOL)((int)*value != 0));
// NoPlacesBar is a REG_DWORD, with values 0 or 1
value = getWindowsPropFromReg(TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\comdlg32"),
TEXT("NoPlacesBar"), &valueType);
if (value != NULL) {
if (valueType == REG_DWORD) {
SetBooleanProperty(TEXT("win.comdlg.noPlacesBar"), (BOOL)((int)*value != 0));
}
free(value);
}
free(value);
}
catch (std::bad_alloc&) {
if (value != NULL) {
free(value);
}
throw;
}
LPTSTR valueName = TEXT("PlaceN");
......@@ -592,7 +619,15 @@ void AwtDesktopProperties::GetOtherParameters() {
lstrcpy(valueNameBuf, valueName);
LPTSTR propKey = TEXT("win.comdlg.placesBarPlaceN");
LPTSTR propKeyBuf = (LPTSTR)SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, (lstrlen(propKey) + 1), sizeof(TCHAR));
LPTSTR propKeyBuf;
try {
propKeyBuf = (LPTSTR)SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, (lstrlen(propKey) + 1), sizeof(TCHAR));
}
catch (std::bad_alloc&) {
free(valueNameBuf);
throw;
}
lstrcpy(propKeyBuf, propKey);
int i = 0;
......@@ -601,20 +636,31 @@ void AwtDesktopProperties::GetOtherParameters() {
propKeyBuf[25] = valueNameBuf[5];
LPTSTR key = TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\comdlg32\\PlacesBar");
if ((value = getWindowsPropFromReg(key, valueNameBuf, &valueType)) != NULL) {
if (valueType == REG_DWORD) {
// Value is a CSIDL
SetIntegerProperty(propKeyBuf, (int)*value);
} else {
// Value is a path
SetStringProperty(propKeyBuf, value);
try {
value = NULL;
if ((value = getWindowsPropFromReg(key, valueNameBuf, &valueType)) != NULL) {
if (valueType == REG_DWORD) {
// Value is a CSIDL
SetIntegerProperty(propKeyBuf, (int)*value);
} else {
// Value is a path
SetStringProperty(propKeyBuf, value);
}
free(value);
}
free(value);
}
catch (std::bad_alloc&) {
if (value != NULL) {
free(value);
}
free(propKeyBuf);
free(valueNameBuf);
throw;
}
} while (value != NULL);
free(valueNameBuf);
free(propKeyBuf);
free(valueNameBuf);
}
void AwtDesktopProperties::GetSoundEvents() {
......@@ -656,14 +702,26 @@ UINT AwtDesktopProperties::GetIntegerParameter(UINT spi) {
void AwtDesktopProperties::SetStringProperty(LPCTSTR propName, LPTSTR value) {
jstring key = JNU_NewStringPlatform(GetEnv(), propName);
if (key == NULL) {
throw std::bad_alloc();
}
jstring jValue = JNU_NewStringPlatform(GetEnv(), value);
if (jValue == NULL) {
GetEnv()->DeleteLocalRef(key);
throw std::bad_alloc();
}
GetEnv()->CallVoidMethod(self,
AwtDesktopProperties::setStringPropertyID,
key, JNU_NewStringPlatform(GetEnv(), value));
key, jValue);
GetEnv()->DeleteLocalRef(jValue);
GetEnv()->DeleteLocalRef(key);
}
void AwtDesktopProperties::SetIntegerProperty(LPCTSTR propName, int value) {
jstring key = JNU_NewStringPlatform(GetEnv(), propName);
if (key == NULL) {
throw std::bad_alloc();
}
GetEnv()->CallVoidMethod(self,
AwtDesktopProperties::setIntegerPropertyID,
key, (jint)value);
......@@ -672,6 +730,9 @@ void AwtDesktopProperties::SetIntegerProperty(LPCTSTR propName, int value) {
void AwtDesktopProperties::SetBooleanProperty(LPCTSTR propName, BOOL value) {
jstring key = JNU_NewStringPlatform(GetEnv(), propName);
if (key == NULL) {
throw std::bad_alloc();
}
GetEnv()->CallVoidMethod(self,
AwtDesktopProperties::setBooleanPropertyID,
key, value ? JNI_TRUE : JNI_FALSE);
......@@ -680,6 +741,9 @@ void AwtDesktopProperties::SetBooleanProperty(LPCTSTR propName, BOOL value) {
void AwtDesktopProperties::SetColorProperty(LPCTSTR propName, DWORD value) {
jstring key = JNU_NewStringPlatform(GetEnv(), propName);
if (key == NULL) {
throw std::bad_alloc();
}
GetEnv()->CallVoidMethod(self,
AwtDesktopProperties::setColorPropertyID,
key, GetRValue(value), GetGValue(value),
......@@ -720,6 +784,11 @@ void AwtDesktopProperties::SetFontProperty(HDC dc, int fontID,
else {
fontName = JNU_NewStringPlatform(GetEnv(), face);
}
if (fontName == NULL) {
delete[] face;
throw std::bad_alloc();
}
jint pointSize = metrics.tmHeight -
metrics.tmInternalLeading;
jint style = java_awt_Font_PLAIN;
......@@ -732,11 +801,16 @@ void AwtDesktopProperties::SetFontProperty(HDC dc, int fontID,
}
jstring key = JNU_NewStringPlatform(GetEnv(), propName);
if (key == NULL) {
GetEnv()->DeleteLocalRef(fontName);
delete[] face;
throw std::bad_alloc();
}
GetEnv()->CallVoidMethod(self,
AwtDesktopProperties::setFontPropertyID,
key, fontName, style, pointSize);
GetEnv()->DeleteLocalRef(fontName);
GetEnv()->DeleteLocalRef(key);
GetEnv()->DeleteLocalRef(fontName);
}
}
delete[] face;
......@@ -750,7 +824,9 @@ void AwtDesktopProperties::SetFontProperty(LPCTSTR propName, const LOGFONT & fon
jint style;
fontName = JNU_NewStringPlatform(GetEnv(), font.lfFaceName);
if (fontName == NULL) {
throw std::bad_alloc();
}
#if 0
HDC hdc;
int pixelsPerInch = GetDeviceCaps(hdc, LOGPIXELSY);
......@@ -773,22 +849,31 @@ void AwtDesktopProperties::SetFontProperty(LPCTSTR propName, const LOGFONT & fon
}
jstring key = JNU_NewStringPlatform(GetEnv(), propName);
if (key == NULL) {
GetEnv()->DeleteLocalRef(fontName);
throw std::bad_alloc();
}
GetEnv()->CallVoidMethod(self, AwtDesktopProperties::setFontPropertyID,
key, fontName, style, pointSize);
GetEnv()->DeleteLocalRef(fontName);
GetEnv()->DeleteLocalRef(key);
GetEnv()->DeleteLocalRef(fontName);
}
void AwtDesktopProperties::SetSoundProperty(LPCTSTR propName, LPCTSTR winEventName) {
jstring key = JNU_NewStringPlatform(GetEnv(), propName);
if (key == NULL) {
throw std::bad_alloc();
}
jstring event = JNU_NewStringPlatform(GetEnv(), winEventName);
if (event == NULL) {
GetEnv()->DeleteLocalRef(key);
throw std::bad_alloc();
}
GetEnv()->CallVoidMethod(self,
AwtDesktopProperties::setSoundPropertyID,
key, event);
GetEnv()->DeleteLocalRef(key);
GetEnv()->DeleteLocalRef(event);
GetEnv()->DeleteLocalRef(key);
}
void AwtDesktopProperties::PlayWindowsSound(LPCTSTR event) {
......@@ -814,24 +899,37 @@ Java_sun_awt_windows_WDesktopProperties_initIDs(JNIEnv *env, jclass cls) {
AwtDesktopProperties::pDataID = env->GetFieldID(cls, "pData", "J");
DASSERT(AwtDesktopProperties::pDataID != 0);
CHECK_NULL(AwtDesktopProperties::pDataID);
AwtDesktopProperties::setBooleanPropertyID = env->GetMethodID(cls, "setBooleanProperty", "(Ljava/lang/String;Z)V");
AwtDesktopProperties::setBooleanPropertyID =
env->GetMethodID(cls, "setBooleanProperty", "(Ljava/lang/String;Z)V");
DASSERT(AwtDesktopProperties::setBooleanPropertyID != 0);
CHECK_NULL(AwtDesktopProperties::setBooleanPropertyID);
AwtDesktopProperties::setIntegerPropertyID = env->GetMethodID(cls, "setIntegerProperty", "(Ljava/lang/String;I)V");
AwtDesktopProperties::setIntegerPropertyID =
env->GetMethodID(cls, "setIntegerProperty", "(Ljava/lang/String;I)V");
DASSERT(AwtDesktopProperties::setIntegerPropertyID != 0);
CHECK_NULL(AwtDesktopProperties::setIntegerPropertyID);
AwtDesktopProperties::setStringPropertyID = env->GetMethodID(cls, "setStringProperty", "(Ljava/lang/String;Ljava/lang/String;)V");
AwtDesktopProperties::setStringPropertyID =
env->GetMethodID(cls, "setStringProperty", "(Ljava/lang/String;Ljava/lang/String;)V");
DASSERT(AwtDesktopProperties::setStringPropertyID != 0);
CHECK_NULL(AwtDesktopProperties::setStringPropertyID);
AwtDesktopProperties::setColorPropertyID = env->GetMethodID(cls, "setColorProperty", "(Ljava/lang/String;III)V");
AwtDesktopProperties::setColorPropertyID =
env->GetMethodID(cls, "setColorProperty", "(Ljava/lang/String;III)V");
DASSERT(AwtDesktopProperties::setColorPropertyID != 0);
CHECK_NULL(AwtDesktopProperties::setColorPropertyID);
AwtDesktopProperties::setFontPropertyID = env->GetMethodID(cls, "setFontProperty", "(Ljava/lang/String;Ljava/lang/String;II)V");
AwtDesktopProperties::setFontPropertyID =
env->GetMethodID(cls, "setFontProperty", "(Ljava/lang/String;Ljava/lang/String;II)V");
DASSERT(AwtDesktopProperties::setFontPropertyID != 0);
CHECK_NULL(AwtDesktopProperties::setFontPropertyID);
AwtDesktopProperties::setSoundPropertyID = env->GetMethodID(cls, "setSoundProperty", "(Ljava/lang/String;Ljava/lang/String;)V");
AwtDesktopProperties::setSoundPropertyID =
env->GetMethodID(cls, "setSoundProperty", "(Ljava/lang/String;Ljava/lang/String;)V");
DASSERT(AwtDesktopProperties::setSoundPropertyID != 0);
CHECK_NULL(AwtDesktopProperties::setSoundPropertyID);
CATCH_BAD_ALLOC;
}
......
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -643,6 +643,7 @@ HRESULT __stdcall AwtDragSource::QueryContinueDrag(BOOL fEscapeKeyPressed, DWOR
m_lastmods == modifiers) {//cannot move before cursor change
call_dSCmouseMoved(env, m_peer,
m_actions, modifiers, dragPoint.x, dragPoint.y);
JNU_CHECK_EXCEPTION_RETURN(env, E_UNEXPECTED);
m_dragPoint = dragPoint;
}
......@@ -977,6 +978,10 @@ HRESULT __stdcall AwtDragSource::GetDataHere(FORMATETC __RPC_FAR *pFormatEtc,
if ((matchedFormatEtc.tymed & TYMED_ISTREAM) != 0) {
jboolean isCopy;
jbyte *bBytes = env->GetByteArrayElements(bytes, &isCopy);
if (bBytes == NULL) {
env->PopLocalFrame(NULL);
return E_UNEXPECTED;
}
ULONG act;
HRESULT res = pmedium->pstm->Write((const void *)bBytes, (ULONG)nBytes,
......
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -603,6 +603,10 @@ jobject AwtDropTarget::ConvertNativeData(JNIEnv* env, jlong fmt, STGMEDIUM *pmed
jobject local = JNU_NewStringPlatform(
env,
pmedium->lpszFileName);
if (env->ExceptionCheck()) {
hr = E_OUTOFMEMORY;
break;
}
jstring fileName = (jstring)env->NewGlobalRef(local);
env->DeleteLocalRef(local);
......@@ -1220,8 +1224,6 @@ AwtDropTarget::call_dTCgetis(JNIEnv* env, jlong istream) {
/*****************************************************************************/
jclass WDTCPIStreamWrapper::javaIOExceptionClazz = (jclass)NULL;
/**
* construct a wrapper
*/
......@@ -1233,16 +1235,6 @@ WDTCPIStreamWrapper::WDTCPIStreamWrapper(STGMEDIUM* stgmedium) {
m_istream = stgmedium->pstm;
m_istream->AddRef();
m_mutex = ::CreateMutex(NULL, FALSE, NULL);
if (javaIOExceptionClazz == (jclass)NULL) {
javaIOExceptionClazz = env->FindClass("java/io/IOException");
if (JNU_IsNull(env, javaIOExceptionClazz)) {
env->ThrowNew(env->FindClass("java/lang/ClassNotFoundException"),
"Cant find java/io/IOException"
);
}
}
}
/**
......@@ -1291,12 +1283,12 @@ jint WDTCPIStreamWrapper::Available() {
JNIEnv* env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
if (m_istream->Stat(&m_statstg, STATFLAG_NONAME) != S_OK) {
env->ThrowNew(javaIOExceptionClazz, "IStream::Stat() failed");
JNU_ThrowIOException(env, "IStream::Stat() failed");
return 0;
}
if (m_statstg.cbSize.QuadPart > 0x7ffffffL) {
env->ThrowNew(javaIOExceptionClazz, "IStream::Stat() cbSize > 0x7ffffff");
JNU_ThrowIOException(env, "IStream::Stat() cbSize > 0x7ffffff");
return 0;
}
......@@ -1349,7 +1341,7 @@ jint WDTCPIStreamWrapper::Read() {
return (jint)(actual == 0 ? -1 : b);
default:
env->ThrowNew(javaIOExceptionClazz, "IStream::Read failed");
JNU_ThrowIOException(env, "IStream::Read failed");
}
return (jint)-1;
}
......@@ -1394,6 +1386,7 @@ jint WDTCPIStreamWrapper::ReadBytes(jbyteArray buf, jint off, jint len) {
ULONG actual = 0;
jbyte* local = env->GetByteArrayElements(buf, &isCopy);
HRESULT res;
CHECK_NULL_RETURN(local, (jint)-1);
switch (res = m_istream->Read((void *)(local + off), (ULONG)len, &actual)) {
case S_FALSE:
......@@ -1406,7 +1399,7 @@ jint WDTCPIStreamWrapper::ReadBytes(jbyteArray buf, jint off, jint len) {
default:
env->ReleaseByteArrayElements(buf, local, JNI_ABORT);
env->ThrowNew(javaIOExceptionClazz, "IStream::Read failed");
JNU_ThrowIOException(env, "IStream::Read failed");
}
return (jint)-1;
......
/*
* Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -45,12 +45,16 @@ Java_java_awt_Event_initIDs(JNIEnv *env, jclass cls) {
TRY;
AwtEvent::targetID = env->GetFieldID(cls, "target", "Ljava/lang/Object;");
AwtEvent::xID = env->GetFieldID(cls, "x", "I");
AwtEvent::yID = env->GetFieldID(cls, "y", "I");
DASSERT(AwtEvent::targetID != NULL);
CHECK_NULL(AwtEvent::targetID);
AwtEvent::xID = env->GetFieldID(cls, "x", "I");
DASSERT(AwtEvent::xID != NULL);
CHECK_NULL(AwtEvent::xID);
AwtEvent::yID = env->GetFieldID(cls, "y", "I");
DASSERT(AwtEvent::yID != NULL);
CHECK_NULL(AwtEvent::yID);
CATCH_BAD_ALLOC;
}
......
......@@ -342,6 +342,8 @@ LRESULT AwtFrame::ProxyWindowProc(UINT message, WPARAM wParam, LPARAM lParam, Ms
case WM_IME_STARTCOMPOSITION:
case WM_IME_ENDCOMPOSITION:
case WM_IME_COMPOSITION:
case WM_IME_SETCONTEXT:
case WM_IME_NOTIFY:
case WM_IME_CONTROL:
case WM_IME_COMPOSITIONFULL:
case WM_IME_SELECT:
......
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -132,6 +132,7 @@ AwtInputTextInfor::GetContextData(HIMC hIMC, const LPARAM flags) {
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
if (m_cStrW > 0) {
m_jtext = MakeJavaString(env, m_lpStrW, m_cStrW);
JNU_CHECK_EXCEPTION_RETURN(env, -1);
}
// Merge the string if necessary
......@@ -251,6 +252,13 @@ int AwtInputTextInfor::GetClauseInfor(int*& lpBndClauseW, jstring*& lpReadingCla
} else {
readingClauseW[cls] = MakeJavaString(env, lpHWStrW, cHWStrW);
}
if (env->ExceptionCheck()) {
lpBndClauseW = NULL;
lpReadingClauseW = NULL;
delete [] bndClauseW;
delete [] readingClauseW;
return 0;
}
}
else {
readingClauseW[cls] = NULL;
......
......@@ -46,14 +46,20 @@ Java_java_awt_Insets_initIDs(JNIEnv *env, jclass cls) {
TRY;
AwtInsets::leftID = env->GetFieldID(cls, "left", "I");
AwtInsets::rightID = env->GetFieldID(cls, "right", "I");
AwtInsets::topID = env->GetFieldID(cls, "top", "I");
AwtInsets::bottomID = env->GetFieldID(cls, "bottom", "I");
DASSERT(AwtInsets::leftID != NULL);
CHECK_NULL(AwtInsets::leftID);
AwtInsets::rightID = env->GetFieldID(cls, "right", "I");
DASSERT(AwtInsets::rightID != NULL);
CHECK_NULL(AwtInsets::rightID);
AwtInsets::topID = env->GetFieldID(cls, "top", "I");
DASSERT(AwtInsets::topID != NULL);
CHECK_NULL(AwtInsets::topID);
AwtInsets::bottomID = env->GetFieldID(cls, "bottom", "I");
DASSERT(AwtInsets::bottomID != NULL);
CHECK_NULL(AwtInsets::bottomID);
CATCH_BAD_ALLOC;
}
......
/*
* Copyright (c) 1998, 2001, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -45,12 +45,16 @@ Java_java_awt_event_MouseEvent_initIDs(JNIEnv *env, jclass cls) {
TRY;
AwtMouseEvent::xID = env->GetFieldID(cls, "x", "I");
AwtMouseEvent::yID = env->GetFieldID(cls, "y", "I");
AwtMouseEvent::buttonID = env->GetFieldID(cls, "button", "I");
DASSERT(AwtMouseEvent::xID != NULL);
CHECK_NULL(AwtMouseEvent::xID);
AwtMouseEvent::yID = env->GetFieldID(cls, "y", "I");
DASSERT(AwtMouseEvent::yID != NULL);
CHECK_NULL(AwtMouseEvent::yID);
AwtMouseEvent::buttonID = env->GetFieldID(cls, "button", "I");
DASSERT(AwtMouseEvent::buttonID != NULL);
CHECK_NULL(AwtMouseEvent::buttonID);
CATCH_BAD_ALLOC;
}
......
......@@ -46,14 +46,20 @@ Java_java_awt_Rectangle_initIDs(JNIEnv *env, jclass cls) {
TRY;
AwtRectangle::xID = env->GetFieldID(cls, "x", "I");
AwtRectangle::yID = env->GetFieldID(cls, "y", "I");
AwtRectangle::widthID = env->GetFieldID(cls, "width", "I");
AwtRectangle::heightID = env->GetFieldID(cls, "height", "I");
DASSERT(AwtRectangle::xID != NULL);
CHECK_NULL(AwtRectangle::xID);
AwtRectangle::yID = env->GetFieldID(cls, "y", "I");
DASSERT(AwtRectangle::yID != NULL);
CHECK_NULL(AwtRectangle::yID);
AwtRectangle::widthID = env->GetFieldID(cls, "width", "I");
DASSERT(AwtRectangle::widthID != NULL);
CHECK_NULL(AwtRectangle::widthID);
AwtRectangle::heightID = env->GetFieldID(cls, "height", "I");
DASSERT(AwtRectangle::heightID != NULL);
CHECK_NULL(AwtRectangle::heightID);
CATCH_BAD_ALLOC;
}
......
......@@ -852,9 +852,10 @@ Java_sun_awt_windows_WTextComponentPeer_initIDs(JNIEnv *env, jclass cls)
TRY;
jclass textComponentClassID = env->FindClass("java/awt/TextComponent");
CHECK_NULL(textComponentClassID);
AwtTextComponent::canAccessClipboardMID =
env->GetMethodID(textComponentClassID,
"canAccessClipboard", "()Z");
env->GetMethodID(textComponentClassID, "canAccessClipboard", "()Z");
env->DeleteLocalRef(textComponentClassID);
DASSERT(AwtTextComponent::canAccessClipboardMID != NULL);
......
/*
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -172,35 +172,22 @@ void AwtToolkit::SetBusy(BOOL busy) {
if (awtAutoShutdownClass == NULL) {
jclass awtAutoShutdownClassLocal = env->FindClass("sun/awt/AWTAutoShutdown");
if (!JNU_IsNull(env, safe_ExceptionOccurred(env))) {
env->ExceptionDescribe();
env->ExceptionClear();
}
DASSERT(awtAutoShutdownClassLocal != NULL);
if (awtAutoShutdownClassLocal == NULL) {
return;
}
if (!awtAutoShutdownClassLocal) throw std::bad_alloc();
awtAutoShutdownClass = (jclass)env->NewGlobalRef(awtAutoShutdownClassLocal);
env->DeleteLocalRef(awtAutoShutdownClassLocal);
if (!awtAutoShutdownClass) throw std::bad_alloc();
notifyBusyMethodID = env->GetStaticMethodID(awtAutoShutdownClass,
"notifyToolkitThreadBusy", "()V");
if (!JNU_IsNull(env, safe_ExceptionOccurred(env))) {
env->ExceptionDescribe();
env->ExceptionClear();
}
DASSERT(notifyBusyMethodID != NULL);
if (!notifyBusyMethodID) throw std::bad_alloc();
notifyFreeMethodID = env->GetStaticMethodID(awtAutoShutdownClass,
"notifyToolkitThreadFree", "()V");
if (!JNU_IsNull(env, safe_ExceptionOccurred(env))) {
env->ExceptionDescribe();
env->ExceptionClear();
}
DASSERT(notifyBusyMethodID != NULL);
DASSERT(notifyFreeMethodID != NULL);
if (notifyBusyMethodID == NULL || notifyFreeMethodID == NULL) {
return;
}
if (!notifyFreeMethodID) throw std::bad_alloc();
} /* awtAutoShutdownClass == NULL*/
if (busy) {
......@@ -779,9 +766,11 @@ LRESULT CALLBACK AwtToolkit::WndProc(HWND hWnd, UINT message,
jclass systemColorClass = env->FindClass("java/awt/SystemColor");
DASSERT(systemColorClass);
if (!systemColorClass) throw std::bad_alloc();
jmethodID mid = env->GetStaticMethodID(systemColorClass, "updateSystemColors", "()V");
DASSERT(mid);
if (!mid) throw std::bad_alloc();
env->CallStaticVoidMethod(systemColorClass, mid);
......@@ -1041,6 +1030,8 @@ LRESULT CALLBACK AwtToolkit::WndProc(HWND hWnd, UINT message,
// Notify Java side - call WToolkit.displayChanged()
jclass clazz = env->FindClass("sun/awt/windows/WToolkit");
DASSERT(clazz != NULL);
if (!clazz) throw std::bad_alloc();
env->CallStaticVoidMethod(clazz, AwtToolkit::displayChangeMID);
GetInstance().m_displayChanged = TRUE;
......@@ -2053,15 +2044,20 @@ Java_java_awt_Toolkit_initIDs(JNIEnv *env, jclass cls) {
AwtToolkit::getDefaultToolkitMID =
env->GetStaticMethodID(cls,"getDefaultToolkit","()Ljava/awt/Toolkit;");
AwtToolkit::getFontMetricsMID =
env->GetMethodID(cls, "getFontMetrics",
"(Ljava/awt/Font;)Ljava/awt/FontMetrics;");
AwtToolkit::insetsMID =
env->GetMethodID(env->FindClass("java/awt/Insets"), "<init>", "(IIII)V");
DASSERT(AwtToolkit::getDefaultToolkitMID != NULL);
CHECK_NULL(AwtToolkit::getDefaultToolkitMID);
AwtToolkit::getFontMetricsMID =
env->GetMethodID(cls, "getFontMetrics", "(Ljava/awt/Font;)Ljava/awt/FontMetrics;");
DASSERT(AwtToolkit::getFontMetricsMID != NULL);
DASSERT(AwtToolkit::insetsMID != NULL);
CHECK_NULL(AwtToolkit::getFontMetricsMID);
jclass insetsClass = env->FindClass("java/awt/Insets");
DASSERT(insetsClass != NULL);
CHECK_NULL(insetsClass);
AwtToolkit::insetsMID = env->GetMethodID(insetsClass, "<init>", "(IIII)V");
DASSERT(AwtToolkit::insetsMID != NULL);
CHECK_NULL(AwtToolkit::insetsMID);
CATCH_BAD_ALLOC;
}
......@@ -2088,10 +2084,12 @@ Java_sun_awt_windows_WToolkit_initIDs(JNIEnv *env, jclass cls)
AwtToolkit::windowsSettingChangeMID =
env->GetMethodID(cls, "windowsSettingChange", "()V");
DASSERT(AwtToolkit::windowsSettingChangeMID != 0);
CHECK_NULL(AwtToolkit::windowsSettingChangeMID);
AwtToolkit::displayChangeMID =
env->GetStaticMethodID(cls, "displayChanged", "()V");
DASSERT(AwtToolkit::displayChangeMID != 0);
CHECK_NULL(AwtToolkit::displayChangeMID);
// Set various global IDs needed by JAWT code. Note: these
// variables cannot be set by JAWT code directly due to
......@@ -2102,24 +2100,37 @@ Java_sun_awt_windows_WToolkit_initIDs(JNIEnv *env, jclass cls)
// negligible penalty.
jclass sDataClassLocal = env->FindClass("sun/java2d/SurfaceData");
DASSERT(sDataClassLocal != 0);
CHECK_NULL(sDataClassLocal);
jclass vImgClassLocal = env->FindClass("sun/awt/image/SunVolatileImage");
DASSERT(vImgClassLocal != 0);
CHECK_NULL(vImgClassLocal);
jclass vSMgrClassLocal =
env->FindClass("sun/awt/image/VolatileSurfaceManager");
DASSERT(vSMgrClassLocal != 0);
CHECK_NULL(vSMgrClassLocal);
jclass componentClassLocal = env->FindClass("java/awt/Component");
DASSERT(componentClassLocal != 0);
CHECK_NULL(componentClassLocal);
jawtSMgrID = env->GetFieldID(vImgClassLocal, "volSurfaceManager",
"Lsun/awt/image/VolatileSurfaceManager;");
DASSERT(jawtSMgrID != 0);
CHECK_NULL(jawtSMgrID);
jawtSDataID = env->GetFieldID(vSMgrClassLocal, "sdCurrent",
"Lsun/java2d/SurfaceData;");
DASSERT(jawtSDataID != 0);
CHECK_NULL(jawtSDataID);
jawtPDataID = env->GetFieldID(sDataClassLocal, "pData", "J");
DASSERT(jawtPDataID != 0);
CHECK_NULL(jawtPDataID);
// Save these classes in global references for later use
jawtVImgClass = (jclass)env->NewGlobalRef(vImgClassLocal);
CHECK_NULL(jawtVImgClass);
jawtComponentClass = (jclass)env->NewGlobalRef(componentClassLocal);
CATCH_BAD_ALLOC;
......@@ -2380,7 +2391,11 @@ Java_sun_awt_windows_WToolkit_getScreenInsets(JNIEnv *env,
TRY;
if (AwtToolkit::GetScreenInsets(screen, &rect)) {
insets = env->NewObject(env->FindClass("java/awt/Insets"),
jclass insetsClass = env->FindClass("java/awt/Insets");
DASSERT(insetsClass != NULL);
CHECK_NULL_RETURN(insetsClass, NULL);
insets = env->NewObject(insetsClass,
AwtToolkit::insetsMID,
rect.top,
rect.left,
......
/*
* Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -80,7 +80,7 @@ class JNILocalFrame {
int result = m_env->PushLocalFrame(size);
if (result < 0) {
DASSERT(FALSE);
JNU_ThrowOutOfMemoryError(m_env, "Can't allocate localRefs");
throw std::bad_alloc();
}
}
INLINE ~JNILocalFrame() { m_env->PopLocalFrame(NULL); }
......
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -503,6 +503,7 @@ void AwtTrayIcon::SendMouseEvent(jint id, jlong when, jint x, jint y,
env->GetMethodID(mouseEventCls, "<init>",
"(Ljava/awt/Component;IJIIIIIIZI)V");
DASSERT(mouseEventConst);
CHECK_NULL(mouseEventConst);
}
if (env->EnsureLocalCapacity(2) < 0) {
return;
......@@ -556,6 +557,7 @@ void AwtTrayIcon::SendActionEvent(jint id, jlong when, jint modifiers, MSG *pMsg
env->GetMethodID(actionEventCls, "<init>",
"(Ljava/lang/Object;ILjava/lang/String;JI)V");
DASSERT(actionEventConst);
CHECK_NULL(actionEventConst);
}
if (env->EnsureLocalCapacity(2) < 0) {
return;
......@@ -736,6 +738,7 @@ void AwtTrayIcon::_SetToolTip(void *param)
}
tooltipStr = JNU_GetStringPlatformChars(env, jtooltip, (jboolean *)NULL);
if (env->ExceptionCheck()) goto ret;
trayIcon->SetToolTip(tooltipStr);
JNU_ReleaseStringPlatformChars(env, jtooltip, tooltipStr);
ret:
......@@ -855,9 +858,18 @@ void AwtTrayIcon::_DisplayMessage(void *param)
trayIcon = (AwtTrayIcon *)pData;
captionStr = JNU_GetStringPlatformChars(env, jcaption, (jboolean *)NULL);
if (env->ExceptionCheck()) goto ret;
textStr = JNU_GetStringPlatformChars(env, jtext, (jboolean *)NULL);
if (env->ExceptionCheck()) {
JNU_ReleaseStringPlatformChars(env, jcaption, captionStr);
goto ret;
}
msgTypeStr = JNU_GetStringPlatformChars(env, jmsgType, (jboolean *)NULL);
if (env->ExceptionCheck()) {
JNU_ReleaseStringPlatformChars(env, jcaption, captionStr);
JNU_ReleaseStringPlatformChars(env, jtext, textStr);
goto ret;
}
trayIcon->DisplayMessage(captionStr, textStr, msgTypeStr);
JNU_ReleaseStringPlatformChars(env, jcaption, captionStr);
......@@ -889,10 +901,12 @@ Java_java_awt_TrayIcon_initIDs(JNIEnv *env, jclass cls)
/* init field ids */
AwtTrayIcon::idID = env->GetFieldID(cls, "id", "I");
AwtTrayIcon::actionCommandID = env->GetFieldID(cls, "actionCommand", "Ljava/lang/String;");
DASSERT(AwtTrayIcon::idID != NULL);
CHECK_NULL(AwtTrayIcon::idID);
AwtTrayIcon::actionCommandID = env->GetFieldID(cls, "actionCommand", "Ljava/lang/String;");
DASSERT(AwtTrayIcon::actionCommandID != NULL);
CHECK_NULL( AwtTrayIcon::actionCommandID);
CATCH_BAD_ALLOC;
}
......@@ -981,8 +995,11 @@ Java_sun_awt_windows_WTrayIconPeer_setNativeIcon(JNIEnv *env, jobject self,
jint *intRasterDataPtr = NULL;
HBITMAP hColor = NULL;
try {
intRasterDataPtr =
(jint *)env->GetPrimitiveArrayCritical(intRasterData, 0);
intRasterDataPtr = (jint *)env->GetPrimitiveArrayCritical(intRasterData, 0);
if (intRasterDataPtr == NULL) {
::DeleteObject(hMask);
return;
}
hColor = AwtTrayIcon::CreateBMP(NULL, (int *)intRasterDataPtr, nSS, nW, nH);
} catch (...) {
if (intRasterDataPtr != NULL) {
......
/*
* Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -91,6 +91,7 @@ JNIEXPORT jobject JNICALL
jobject bounds = NULL;
clazz = env->FindClass("java/awt/Rectangle");
CHECK_NULL_RETURN(clazz, NULL);
mid = env->GetMethodID(clazz, "<init>", "(IIII)V");
if (mid != 0) {
RECT rRW = {0, 0, 0, 0};
......
......@@ -163,18 +163,13 @@ jthrowable
safe_ExceptionOccurred(JNIEnv *env) throw (std::bad_alloc) {
jthrowable xcp = env->ExceptionOccurred();
if (xcp != NULL) {
env->ExceptionClear(); // if we don't do this, FindClass will fail
jclass outofmem = env->FindClass("java/lang/OutOfMemoryError");
DASSERT(outofmem != NULL);
jboolean isOutofmem = env->IsInstanceOf(xcp, outofmem);
env->DeleteLocalRef(outofmem);
if (isOutofmem) {
env->ExceptionClear(); // if we don't do this, isInstanceOf will fail
jint isOutofmem = JNU_IsInstanceOfByName(env, xcp, "java/lang/OutOfMemoryError");
if (isOutofmem > 0) {
env->DeleteLocalRef(xcp);
throw std::bad_alloc();
} else {
env->ExceptionClear();
// rethrow exception
env->Throw(xcp);
return xcp;
......
......@@ -234,15 +234,6 @@ sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java solaris-all
java/security/KeyPairGenerator/SolarisShortDSA.java solaris-all
sun/security/tools/keytool/standard.sh solaris-all
# 8000439: NPG: REGRESSION : sun/security/krb5/auto/MaxRetries.java fails with timeout
sun/security/krb5/auto/MaxRetries.java solaris-sparcv9
# 8006690: sun/security/krb5/auto/BadKdc1.java fails intermittently
sun/security/krb5/auto/BadKdc1.java solaris-sparcv9
sun/security/krb5/auto/BadKdc2.java solaris-sparcv9
sun/security/krb5/auto/BadKdc3.java solaris-sparcv9
sun/security/krb5/auto/BadKdc4.java solaris-sparcv9
############################################################################
# jdk_sound
......
/*
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -23,7 +23,7 @@
/*
test
@bug 6998877
@bug 6998877 8022531
@summary After double-click on the folder names, FileNameOverrideTest FAILED
@author Sergey.Bylokhov@oracle.com area=awt.filedialog
@library ../../regtesthelpers
......@@ -59,7 +59,8 @@ public class SaveFileNameOverrideTest extends Applet implements ActionListener {
String[] instructions = {
"1) Click on 'Show File Dialog' button. A file dialog will come up.",
"2) Double-click on '" + clickDirName + "' and click OK.",
"2) Double-click on '" + clickDirName + "' and click a confirmation",
" button, it can be 'OK', 'Save' or any other platform-dependent name.",
"3) See result of the test below"
};
......
......@@ -23,7 +23,7 @@
/*
* @test
* @bug 7024749
* @bug 7024749 8019990
* @summary JDK7 b131---a crash in: Java_sun_awt_windows_ThemeReader_isGetThemeTransitionDurationDefined+0x75
* @library ../../regtesthelpers
* @build Util
......
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -22,7 +22,7 @@
*/
/* @test
* @bug 8024864
* @bug 8024864 8031422
* @summary [macosx] Problems with rendering of controls
* @author Petr Pchelko
* @library ../regtesthelpers
......@@ -65,7 +65,7 @@ public class bug8024864
Util.waitForIdle(r);
Dimension frameSize = frame.getSize();
Point loc = new Point(frameSize.width - 5, frameSize.height - 5);
Point loc = new Point(frameSize.width - 15, frameSize.height - 15);
SwingUtilities.convertPointToScreen(loc, frame);
Color c = r.getPixelColor(loc.x, loc.y);
......
/*
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -23,7 +23,7 @@
/*
@test
@bug 7154072
@bug 7154072 7161320
@summary Tests that key events with modifiers are not swallowed.
@author anton.tarasov: area=awt.focus
@library ../../../regtesthelpers
......@@ -49,6 +49,11 @@ public class SwallowKeyEvents {
static Robot r;
public static void main(String[] args) {
if (sun.awt.OSInfo.getOSType() == sun.awt.OSInfo.OSType.WINDOWS) {
System.out.println("Skipped. Test not for MS Windows.");
return;
}
f.add(t);
f.pack();
f.setVisible(true);
......
......@@ -81,7 +81,7 @@ public class ProcessCommunicator {
public static ProcessResults executeChildProcess(final Class classToExecute,
final String [] args)
{
return executeChildProcess(classToExecute, " ", args);
return executeChildProcess(classToExecute, System.getProperty("java.class.path"), args);
}
/**
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册