提交 a058a641 编写于 作者: A asaha

Merge

......@@ -36,3 +36,5 @@ d5a1223e961891564de25c39fba6f2442d0fb045 jdk7-b57
2a5a1b269e89f27ebe419ef4cf6e66a3face0df1 jdk7-b59
0c3ef2d612a47667829eb17a192decef23f1c536 jdk7-b60
f72c0dc047b9b2e797beee68ae0b50decb1f020d jdk7-b61
12e11fab9a839a9666a996a8f9a02fd8fa03aab6 jdk7-b62
2ed6ed6b5bfc7dd724925b90dbb31223df59c25d jdk7-b63
......@@ -76,6 +76,10 @@ FILES_java = \
sun/text/Normalizer.java \
sun/text/SupplementaryCharacterData.java \
sun/text/UCompactIntArray.java \
sun/text/bidi/BidiBase.java \
sun/text/bidi/BidiLine.java \
sun/text/bidi/BidiRun.java \
\
sun/text/normalizer/CharTrie.java \
sun/text/normalizer/CharacterIteratorWrapper.java \
sun/text/normalizer/ICUBinary.java \
......
......@@ -24,10 +24,6 @@
#
FILES_c_shared = \
jbidi.c \
ubidi.c \
ubidiln.c \
uchardir.c \
DrawGlyphList.c \
sunFont.c
......
......@@ -145,7 +145,6 @@ include $(BUILDDIR)/common/Library.gmk
# Add to the ambient vpath to pick up files in subdirectories
#
vpath %.c $(PLATFORM_SRC)/native/$(PKGDIR)
vpath %.c $(SHARE_SRC)/native/$(PKGDIR)/bidi
vpath %.cpp $(SHARE_SRC)/native/$(PKGDIR)/layout
vpath %.cpp $(SHARE_SRC)/native/$(PKGDIR)
......@@ -187,7 +186,6 @@ endif # PLATFORM
CPPFLAGS += -I$(SHARE_SRC)/native/$(PKGDIR) \
-I$(SHARE_SRC)/native/$(PKGDIR)/layout \
-I$(SHARE_SRC)/native/$(PKGDIR)/bidi \
-I$(SHARE_SRC)/native/sun/awt/image/cvutils \
-I$(PLATFORM_SRC)/native/sun/awt \
-I$(SHARE_SRC)/native/sun/awt/debug \
......
......@@ -31,8 +31,6 @@ SUNWprivate_1.1 {
newLayoutTableCache;
freeLayoutTableCache;
isNullScalerContext;
Java_java_text_Bidi_nativeBidiChars;
Java_java_text_Bidi_nativeGetDirectionCode;
Java_sun_font_NullFontScaler_getNullScalerContext;
Java_sun_font_NullFontScaler_getGlyphImage;
Java_sun_font_FontManager_getPlatformFontVar;
......
......@@ -33,8 +33,6 @@ SUNWprivate_1.1 {
newLayoutTableCache;
freeLayoutTableCache;
isNullScalerContext;
Java_java_text_Bidi_nativeBidiChars;
Java_java_text_Bidi_nativeGetDirectionCode;
Java_sun_font_NullFontScaler_getNullScalerContext;
Java_sun_font_NullFontScaler_getGlyphImage;
Java_sun_font_FontManager_getPlatformFontVar;
......
......@@ -506,6 +506,19 @@ public class BMPImageWriter extends ImageWriter implements BMPConstants {
writeFileHeader(fileSize, offset);
/* According to MSDN description, the top-down image layout
* is allowed only if compression type is BI_RGB or BI_BITFIELDS.
* Images with any other compression type must be wrote in the
* bottom-up layout.
*/
if (compressionType == BMPConstants.BI_RGB ||
compressionType == BMPConstants.BI_BITFIELDS)
{
isTopDown = bmpParam.isTopDown();
} else {
isTopDown = false;
}
writeInfoHeader(headerSize, bitsPerPixel);
// compression
......@@ -588,8 +601,6 @@ public class BMPImageWriter extends ImageWriter implements BMPConstants {
return;
}
isTopDown = bmpParam.isTopDown();
int maxBandOffset = bandOffsets[0];
for (int i = 1; i < bandOffsets.length; i++)
if (bandOffsets[i] > maxBandOffset)
......@@ -1299,7 +1310,7 @@ public class BMPImageWriter extends ImageWriter implements BMPConstants {
stream.writeInt(w);
// height
stream.writeInt(h);
stream.writeInt(isTopDown ? -h : h);
// number of planes
stream.writeShort(1);
......
......@@ -27,6 +27,8 @@ package com.sun.imageio.plugins.common;
import java.awt.Point;
import java.awt.Rectangle;
import java.io.IOException;
import javax.imageio.stream.ImageInputStream;
/**
* This class contains utility methods that may be useful to ImageReader
......@@ -198,4 +200,17 @@ public class ReaderUtil {
vals, 1);
return vals;
}
public static int readMultiByteInteger(ImageInputStream iis)
throws IOException
{
int value = iis.readByte();
int result = value & 0x7f;
while((value & 0x80) == 0x80) {
result <<= 7;
value = iis.readByte();
result |= (value & 0x7f);
}
return result;
}
}
......@@ -215,17 +215,21 @@ public class JPEG {
public static class JCS {
public static final ColorSpace sRGB =
ColorSpace.getInstance(ColorSpace.CS_sRGB);
public static final ColorSpace YCC;
static {
ColorSpace cs = null;
try {
cs = ColorSpace.getInstance(ColorSpace.CS_PYCC);
} catch (IllegalArgumentException e) {
// PYCC.pf may not always be installed
} finally {
YCC = cs;
private static ColorSpace YCC = null;
private static boolean yccInited = false;
public static ColorSpace getYCC() {
if (!yccInited) {
try {
YCC = ColorSpace.getInstance(ColorSpace.CS_PYCC);
} catch (IllegalArgumentException e) {
// PYCC.pf may not always be installed
} finally {
yccInited = true;
}
}
return YCC;
}
}
......
......@@ -41,6 +41,7 @@ import java.awt.Rectangle;
import java.awt.color.ColorSpace;
import java.awt.color.ICC_Profile;
import java.awt.color.ICC_ColorSpace;
import java.awt.color.CMMException;
import java.awt.image.BufferedImage;
import java.awt.image.Raster;
import java.awt.image.WritableRaster;
......@@ -53,6 +54,7 @@ import java.io.IOException;
import java.util.List;
import java.util.Iterator;
import java.util.ArrayList;
import java.util.NoSuchElementException;
import sun.java2d.Disposer;
import sun.java2d.DisposerRecord;
......@@ -215,51 +217,6 @@ public class JPEGImageReader extends ImageReader {
/** The DisposerRecord that handles the actual disposal of this reader. */
private DisposerRecord disposerRecord;
/**
* Maintain an array of the default image types corresponding to the
* various supported IJG colorspace codes.
*/
private static final ImageTypeSpecifier [] defaultTypes =
new ImageTypeSpecifier [JPEG.NUM_JCS_CODES];
static {
defaultTypes[JPEG.JCS_GRAYSCALE] =
ImageTypeSpecifier.createFromBufferedImageType
(BufferedImage.TYPE_BYTE_GRAY);
defaultTypes[JPEG.JCS_RGB] =
ImageTypeSpecifier.createInterleaved
(JPEG.JCS.sRGB,
JPEG.bOffsRGB,
DataBuffer.TYPE_BYTE,
false,
false);
defaultTypes[JPEG.JCS_RGBA] =
ImageTypeSpecifier.createPacked
(JPEG.JCS.sRGB,
0xff000000,
0x00ff0000,
0x0000ff00,
0x000000ff,
DataBuffer.TYPE_INT,
false);
if (JPEG.JCS.YCC != null) {
defaultTypes[JPEG.JCS_YCC] =
ImageTypeSpecifier.createInterleaved
(JPEG.JCS.YCC,
JPEG.bandOffsets[2],
DataBuffer.TYPE_BYTE,
false,
false);
defaultTypes[JPEG.JCS_YCCA] =
ImageTypeSpecifier.createInterleaved
(JPEG.JCS.YCC,
JPEG.bandOffsets[3],
DataBuffer.TYPE_BYTE,
true,
false);
}
}
/** Sets up static C structures. */
private static native void initReaderIDs(Class iisClass,
Class qTableClass,
......@@ -673,6 +630,17 @@ public class JPEGImageReader extends ImageReader {
!java.util.Arrays.equals(oldData, newData))
{
iccCS = new ICC_ColorSpace(newProfile);
// verify new color space
try {
float[] colors = iccCS.fromRGB(new float[] {1f, 0f, 0f});
} catch (CMMException e) {
/*
* Embedded profile seems to be corrupted.
* Ignore this profile.
*/
iccCS = null;
warningOccurred(WARNING_IGNORE_INVALID_ICC);
}
}
}
......@@ -706,11 +674,11 @@ public class JPEGImageReader extends ImageReader {
* Return an ImageTypeSpecifier corresponding to the given
* color space code, or null if the color space is unsupported.
*/
private ImageTypeSpecifier getImageType(int code) {
ImageTypeSpecifier ret = null;
private ImageTypeProducer getImageType(int code) {
ImageTypeProducer ret = null;
if ((code > 0) && (code < JPEG.NUM_JCS_CODES)) {
ret = defaultTypes[code];
ret = ImageTypeProducer.getTypeProducer(code);
}
return ret;
}
......@@ -724,7 +692,7 @@ public class JPEGImageReader extends ImageReader {
}
// Returns null if it can't be represented
return getImageType(colorSpaceCode);
return getImageType(colorSpaceCode).getType();
} finally {
clearThreadLock();
}
......@@ -758,13 +726,13 @@ public class JPEGImageReader extends ImageReader {
// Get the raw ITS, if there is one. Note that this
// won't always be the same as the default.
ImageTypeSpecifier raw = getImageType(colorSpaceCode);
ImageTypeProducer raw = getImageType(colorSpaceCode);
// Given the encoded colorspace, build a list of ITS's
// representing outputs you could handle starting
// with the default.
ArrayList list = new ArrayList(1);
ArrayList<ImageTypeProducer> list = new ArrayList<ImageTypeProducer>(1);
switch (colorSpaceCode) {
case JPEG.JCS_GRAYSCALE:
......@@ -774,9 +742,7 @@ public class JPEGImageReader extends ImageReader {
case JPEG.JCS_RGB:
list.add(raw);
list.add(getImageType(JPEG.JCS_GRAYSCALE));
if (JPEG.JCS.YCC != null) {
list.add(getImageType(JPEG.JCS_YCC));
}
list.add(getImageType(JPEG.JCS_YCC));
break;
case JPEG.JCS_RGBA:
list.add(raw);
......@@ -801,19 +767,21 @@ public class JPEGImageReader extends ImageReader {
list.add(getImageType(JPEG.JCS_RGB));
if (iccCS != null) {
list.add(ImageTypeSpecifier.createInterleaved
list.add(new ImageTypeProducer() {
protected ImageTypeSpecifier produce() {
return ImageTypeSpecifier.createInterleaved
(iccCS,
JPEG.bOffsRGB, // Assume it's for RGB
DataBuffer.TYPE_BYTE,
false,
false));
false);
}
});
}
list.add(getImageType(JPEG.JCS_GRAYSCALE));
if (JPEG.JCS.YCC != null) { // Might be null if PYCC.pf not installed
list.add(getImageType(JPEG.JCS_YCC));
}
list.add(getImageType(JPEG.JCS_YCC));
break;
case JPEG.JCS_YCbCrA: // Default is to convert to RGBA
// As there is no YCbCr ColorSpace, we can't support
......@@ -822,7 +790,7 @@ public class JPEGImageReader extends ImageReader {
break;
}
return list.iterator();
return new ImageTypeIterator(list.iterator());
}
/**
......@@ -872,6 +840,10 @@ public class JPEGImageReader extends ImageReader {
if (csType == ColorSpace.TYPE_RGB) { // We want RGB
// IJG can do this for us more efficiently
setOutColorSpace(structPointer, JPEG.JCS_RGB);
// Update java state according to changes
// in the native part of decoder.
outColorSpaceCode = JPEG.JCS_RGB;
numComponents = 3;
} else if (csType != ColorSpace.TYPE_GRAY) {
throw new IIOException("Incompatible color conversion");
}
......@@ -881,6 +853,10 @@ public class JPEGImageReader extends ImageReader {
if (colorSpaceCode == JPEG.JCS_YCbCr) {
// If the jpeg space is YCbCr, IJG can do it
setOutColorSpace(structPointer, JPEG.JCS_GRAYSCALE);
// Update java state according to changes
// in the native part of decoder.
outColorSpaceCode = JPEG.JCS_GRAYSCALE;
numComponents = 1;
}
} else if ((iccCS != null) &&
(cm.getNumComponents() == numComponents) &&
......@@ -906,20 +882,26 @@ public class JPEGImageReader extends ImageReader {
}
break;
case JPEG.JCS_YCC:
if (JPEG.JCS.YCC == null) { // We can't do YCC at all
throw new IIOException("Incompatible color conversion");
}
if ((cs != JPEG.JCS.YCC) &&
(cm.getNumComponents() == numComponents)) {
convert = new ColorConvertOp(JPEG.JCS.YCC, cs, null);
{
ColorSpace YCC = JPEG.JCS.getYCC();
if (YCC == null) { // We can't do YCC at all
throw new IIOException("Incompatible color conversion");
}
if ((cs != YCC) &&
(cm.getNumComponents() == numComponents)) {
convert = new ColorConvertOp(YCC, cs, null);
}
}
break;
case JPEG.JCS_YCCA:
// No conversions available; image must be YCCA
if ((JPEG.JCS.YCC == null) || // We can't do YCC at all
(cs != JPEG.JCS.YCC) ||
(cm.getNumComponents() != numComponents)) {
throw new IIOException("Incompatible color conversion");
{
ColorSpace YCC = JPEG.JCS.getYCC();
// No conversions available; image must be YCCA
if ((YCC == null) || // We can't do YCC at all
(cs != YCC) ||
(cm.getNumComponents() != numComponents)) {
throw new IIOException("Incompatible color conversion");
}
}
break;
default:
......@@ -1554,3 +1536,140 @@ public class JPEGImageReader extends ImageReader {
}
}
}
/**
* An internal helper class that wraps producer's iterator
* and extracts specifier instances on demand.
*/
class ImageTypeIterator implements Iterator<ImageTypeSpecifier> {
private Iterator<ImageTypeProducer> producers;
private ImageTypeSpecifier theNext = null;
public ImageTypeIterator(Iterator<ImageTypeProducer> producers) {
this.producers = producers;
}
public boolean hasNext() {
if (theNext != null) {
return true;
}
if (!producers.hasNext()) {
return false;
}
do {
theNext = producers.next().getType();
} while (theNext == null && producers.hasNext());
return (theNext != null);
}
public ImageTypeSpecifier next() {
if (theNext != null || hasNext()) {
ImageTypeSpecifier t = theNext;
theNext = null;
return t;
} else {
throw new NoSuchElementException();
}
}
public void remove() {
producers.remove();
}
}
/**
* An internal helper class that provides means for deferred creation
* of ImageTypeSpecifier instance required to describe available
* destination types.
*
* This implementation only supports standard
* jpeg color spaces (defined by corresponding JCS color space code).
*
* To support other color spaces one can override produce() method to
* return custom instance of ImageTypeSpecifier.
*/
class ImageTypeProducer {
private ImageTypeSpecifier type = null;
boolean failed = false;
private int csCode;
public ImageTypeProducer(int csCode) {
this.csCode = csCode;
}
public ImageTypeProducer() {
csCode = -1; // undefined
}
public synchronized ImageTypeSpecifier getType() {
if (!failed && type == null) {
try {
type = produce();
} catch (Throwable e) {
failed = true;
}
}
return type;
}
private static final ImageTypeProducer [] defaultTypes =
new ImageTypeProducer [JPEG.NUM_JCS_CODES];
public synchronized static ImageTypeProducer getTypeProducer(int csCode) {
if (csCode < 0 || csCode >= JPEG.NUM_JCS_CODES) {
return null;
}
if (defaultTypes[csCode] == null) {
defaultTypes[csCode] = new ImageTypeProducer(csCode);
}
return defaultTypes[csCode];
}
protected ImageTypeSpecifier produce() {
switch (csCode) {
case JPEG.JCS_GRAYSCALE:
return ImageTypeSpecifier.createFromBufferedImageType
(BufferedImage.TYPE_BYTE_GRAY);
case JPEG.JCS_RGB:
return ImageTypeSpecifier.createInterleaved(JPEG.JCS.sRGB,
JPEG.bOffsRGB,
DataBuffer.TYPE_BYTE,
false,
false);
case JPEG.JCS_RGBA:
return ImageTypeSpecifier.createPacked(JPEG.JCS.sRGB,
0xff000000,
0x00ff0000,
0x0000ff00,
0x000000ff,
DataBuffer.TYPE_INT,
false);
case JPEG.JCS_YCC:
if (JPEG.JCS.getYCC() != null) {
return ImageTypeSpecifier.createInterleaved(
JPEG.JCS.getYCC(),
JPEG.bandOffsets[2],
DataBuffer.TYPE_BYTE,
false,
false);
} else {
return null;
}
case JPEG.JCS_YCCA:
if (JPEG.JCS.getYCC() != null) {
return ImageTypeSpecifier.createInterleaved(
JPEG.JCS.getYCC(),
JPEG.bandOffsets[3],
DataBuffer.TYPE_BYTE,
true,
false);
} else {
return null;
}
default:
return null;
}
}
}
......@@ -812,7 +812,7 @@ public class JPEGImageWriter extends ImageWriter {
}
break;
case ColorSpace.TYPE_3CLR:
if (cs == JPEG.JCS.YCC) {
if (cs == JPEG.JCS.getYCC()) {
if (!alpha) {
if (jfif != null) {
convertTosRGB = true;
......@@ -1494,7 +1494,7 @@ public class JPEGImageWriter extends ImageWriter {
}
break;
case ColorSpace.TYPE_3CLR:
if (cs == JPEG.JCS.YCC) {
if (cs == JPEG.JCS.getYCC()) {
if (alpha) {
retval = JPEG.JCS_YCCA;
} else {
......@@ -1533,7 +1533,7 @@ public class JPEGImageWriter extends ImageWriter {
}
break;
case ColorSpace.TYPE_3CLR:
if (cs == JPEG.JCS.YCC) {
if (cs == JPEG.JCS.getYCC()) {
if (alpha) {
retval = JPEG.JCS_YCCA;
} else {
......@@ -1579,7 +1579,7 @@ public class JPEGImageWriter extends ImageWriter {
}
break;
case ColorSpace.TYPE_3CLR:
if (cs == JPEG.JCS.YCC) {
if (cs == JPEG.JCS.getYCC()) {
if (alpha) {
retval = JPEG.JCS_YCCA;
} else {
......
......@@ -490,7 +490,7 @@ public class JPEGMetadata extends IIOMetadata implements Cloneable {
}
break;
case ColorSpace.TYPE_3CLR:
if (cs == JPEG.JCS.YCC) {
if (cs == JPEG.JCS.getYCC()) {
wantJFIF = false;
componentIDs[0] = (byte) 'Y';
componentIDs[1] = (byte) 'C';
......
......@@ -45,6 +45,7 @@ import java.util.ArrayList;
import java.util.Iterator;
import com.sun.imageio.plugins.common.I18N;
import com.sun.imageio.plugins.common.ReaderUtil;
/** This class is the Java Image IO plugin reader for WBMP images.
* It may subsample the image, clip the image,
......@@ -141,11 +142,11 @@ public class WBMPImageReader extends ImageReader {
metadata.wbmpType = wbmpType;
// Read image width
width = readMultiByteInteger();
width = ReaderUtil.readMultiByteInteger(iis);
metadata.width = width;
// Read image height
height = readMultiByteInteger();
height = ReaderUtil.readMultiByteInteger(iis);
metadata.height = height;
gotHeader = true;
......@@ -311,17 +312,6 @@ public class WBMPImageReader extends ImageReader {
gotHeader = false;
}
private int readMultiByteInteger() throws IOException {
int value = iis.readByte();
int result = value & 0x7f;
while((value & 0x80) == 0x80) {
result <<= 7;
value = iis.readByte();
result |= (value & 0x7f);
}
return result;
}
/*
* This method verifies that given byte is valid wbmp type marker.
* At the moment only 0x0 marker is described by wbmp spec.
......
......@@ -33,9 +33,13 @@ import javax.imageio.spi.ServiceRegistry;
import java.io.IOException;
import javax.imageio.ImageReader;
import javax.imageio.IIOException;
import com.sun.imageio.plugins.common.ReaderUtil;
public class WBMPImageReaderSpi extends ImageReaderSpi {
private static final int MAX_WBMP_WIDTH = 1024;
private static final int MAX_WBMP_HEIGHT = 768;
private static String [] writerSpiNames =
{"com.sun.imageio.plugins.wbmp.WBMPImageWriterSpi"};
private static String[] formatNames = {"wbmp", "WBMP"};
......@@ -79,16 +83,44 @@ public class WBMPImageReaderSpi extends ImageReaderSpi {
}
ImageInputStream stream = (ImageInputStream)source;
byte[] b = new byte[3];
stream.mark();
stream.readFully(b);
int type = stream.readByte(); // TypeField
int fixHeaderField = stream.readByte();
// check WBMP "header"
if (type != 0 || fixHeaderField != 0) {
// while WBMP reader does not support ext WBMP headers
stream.reset();
return false;
}
int width = ReaderUtil.readMultiByteInteger(stream);
int height = ReaderUtil.readMultiByteInteger(stream);
// check image dimension
if (width <= 0 || height <= 0) {
stream.reset();
return false;
}
long dataLength = stream.length();
if (dataLength == -1) {
// We can't verify that amount of data in the stream
// corresponds to image dimension because we do not know
// the length of the data stream.
// Assuming that wbmp image are used for mobile devices,
// let's introduce an upper limit for image dimension.
// In case if exact amount of raster data is unknown,
// let's reject images with dimension above the limit.
stream.reset();
return (width < MAX_WBMP_WIDTH) && (height < MAX_WBMP_HEIGHT);
}
dataLength -= stream.getStreamPosition();
stream.reset();
return ((b[0] == (byte)0) && // TypeField == 0
b[1] == 0 && // FixHeaderField == 0xxx00000; not support ext header
((b[2] & 0x8f) != 0 || (b[2] & 0x7f) != 0)); // First width byte
//XXX: b[2] & 0x8f) != 0 for the bug in Sony Ericsson encoder.
long scanSize = (width / 8) + ((width % 8) == 0 ? 0 : 1);
return (dataLength == scanSize * height);
}
public ImageReader createReaderInstance(Object extension)
......
......@@ -445,18 +445,19 @@ public class Font implements java.io.Serializable
*/
private AttributeValues getAttributeValues() {
if (values == null) {
values = new AttributeValues();
values.setFamily(name);
values.setSize(pointSize); // expects the float value.
AttributeValues valuesTmp = new AttributeValues();
valuesTmp.setFamily(name);
valuesTmp.setSize(pointSize); // expects the float value.
if ((style & BOLD) != 0) {
values.setWeight(2); // WEIGHT_BOLD
valuesTmp.setWeight(2); // WEIGHT_BOLD
}
if ((style & ITALIC) != 0) {
values.setPosture(.2f); // POSTURE_OBLIQUE
valuesTmp.setPosture(.2f); // POSTURE_OBLIQUE
}
values.defineAll(PRIMARY_MASK); // for streaming compatibility
valuesTmp.defineAll(PRIMARY_MASK); // for streaming compatibility
values = valuesTmp;
}
return values;
......
......@@ -79,8 +79,9 @@ public abstract class GraphicsEnvironment {
try {
// long t0 = System.currentTimeMillis();
localEnv =
(GraphicsEnvironment) Class.forName(nm).newInstance();
ClassLoader cl = ClassLoader.getSystemClassLoader();
Class geCls = Class.forName(nm, true, cl);
localEnv = (GraphicsEnvironment)geCls.newInstance();
// long t1 = System.currentTimeMillis();
// System.out.println("GE creation took " + (t1-t0)+ "ms.");
if (isHeadless()) {
......
......@@ -863,11 +863,16 @@ public class ICC_Profile implements Serializable {
case ColorSpace.CS_PYCC:
synchronized(ICC_Profile.class) {
if (PYCCprofile == null) {
ProfileDeferralInfo pInfo =
new ProfileDeferralInfo("PYCC.pf",
ColorSpace.TYPE_3CLR, 3,
CLASS_DISPLAY);
PYCCprofile = getDeferredInstance(pInfo);
if (getProfileFile("PYCC.pf") != null) {
ProfileDeferralInfo pInfo =
new ProfileDeferralInfo("PYCC.pf",
ColorSpace.TYPE_3CLR, 3,
CLASS_DISPLAY);
PYCCprofile = getDeferredInstance(pInfo);
} else {
throw new IllegalArgumentException(
"Can't load standard profile: PYCC.pf");
}
}
thisProfile = PYCCprofile;
}
......@@ -1783,17 +1788,33 @@ public class ICC_Profile implements Serializable {
return (FileInputStream)java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() {
public Object run() {
return privilegedOpenProfile(fileName);
File f = privilegedGetProfileFile(fileName);
if (f != null) {
try {
return new FileInputStream(f);
} catch (FileNotFoundException e) {
}
}
return null;
}
});
}
private static File getProfileFile(final String fileName) {
return (File)java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() {
public Object run() {
return privilegedGetProfileFile(fileName);
}
});
}
/*
* this version is called from doPrivileged in privilegedOpenProfile.
* the whole method is privileged!
* this version is called from doPrivileged in openProfile
* or getProfileFile, so the whole method is privileged!
*/
private static FileInputStream privilegedOpenProfile(String fileName) {
FileInputStream fis = null;
private static File privilegedGetProfileFile(String fileName) {
String path, dir, fullPath;
File f = new File(fileName); /* try absolute file name */
......@@ -1830,12 +1851,9 @@ public class ICC_Profile implements Serializable {
}
if (f.isFile()) {
try {
fis = new FileInputStream(f);
} catch (FileNotFoundException e) {
}
return f;
}
return fis;
return null;
}
......
......@@ -46,7 +46,7 @@ import java.security.BasicPermission;
* known as creating a link, or hard link. </td>
* <td> Extreme care should be taken when granting this permission. It allows
* linking to any file or directory in the file system thus allowing the
* attacker to access to all files. </td>
* attacker access to all files. </td>
* </tr>
* <tr>
* <td>symbolic</td>
......
......@@ -27,7 +27,7 @@ package java.nio.file;
/**
* Checked exception thrown when a file system operation fails because a file
* is not a link.
* is not a symbolic link.
*
* @since 1.7
*/
......
......@@ -91,8 +91,8 @@ import java.util.Set;
* iterate over the entries in the directory. </p></li>
* <li><p> Files can be {@link #copyTo(Path,CopyOption[]) copied} or
* {@link #moveTo(Path,CopyOption[]) moved}. </p></li>
* <li><p> Symbolic-links may be {@link #createSymbolicLink created}, or the
* target of a link may be {@link #readSymbolicLink read}. </p></li>
* <li><p> Symbolic links may be {@link #createSymbolicLink created}, or the
* target of a symbolic link may be {@link #readSymbolicLink read}. </p></li>
* <li><p> The {@link #toRealPath real} path of an existing file may be
* obtained. </li></p>
* </ul>
......@@ -403,12 +403,12 @@ public abstract class Path
* <i>p</i><tt>.relativize(</tt><i>p</i><tt>.resolve(</tt><i>q</i><tt>)).equals(</tt><i>q</i><tt>)</tt>
* </blockquote>
*
* <p> When symbolic-links are supported, then whether the resulting path,
* <p> When symbolic links are supported, then whether the resulting path,
* when resolved against this path, yields a path that can be used to locate
* the {@link #isSameFile same} file as {@code other} is implementation
* dependent. For example, if this path is {@code "/a/b"} and the given
* path is {@code "/a/x"} then the resulting relative path may be {@code
* "../x"}. If {@code "b"} is a symbolic-link then is implementation
* "../x"}. If {@code "b"} is a symbolic link then is implementation
* dependent if {@code "a/b/../x"} would locate the same file as {@code "/a/x"}.
*
* @param other
......@@ -430,8 +430,8 @@ public abstract class Path
*
* <p> An implementation may require to examine the file to determine if the
* file is a directory. Consequently this method may not be atomic with respect
* to other file system operations. If the file is a symbolic-link then the
* link is deleted and not the final target of the link.
* to other file system operations. If the file is a symbolic link then the
* symbolic link itself, not the final target of the link, is deleted.
*
* <p> If the file is a directory then the directory must be empty. In some
* implementations a directory has entries for special files or links that
......@@ -459,11 +459,11 @@ public abstract class Path
/**
* Deletes the file located by this path, if it exists.
*
* <p> As with the {@link #delete delete()} method, an implementation
* may require to examine the file to determine if the file is a directory.
* <p> As with the {@link #delete delete()} method, an implementation may
* need to examine the file to determine if the file is a directory.
* Consequently this method may not be atomic with respect to other file
* system operations. If the file is a symbolic-link then the link is
* deleted and not the final target of the link.
* system operations. If the file is a symbolic link, then the symbolic
* link itself, not the final target of the link, is deleted.
*
* <p> If the file is a directory then the directory must be empty. In some
* implementations a directory has entries for special files or links that
......@@ -507,7 +507,7 @@ public abstract class Path
* create symbolic links, in which case this method may throw {@code IOException}.
*
* @param target
* the target of the link
* the target of the symbolic link
* @param attrs
* the array of attributes to set atomically when creating the
* symbolic link
......@@ -573,9 +573,9 @@ public abstract class Path
* Reads the target of a symbolic link <i>(optional operation)</i>.
*
* <p> If the file system supports <a href="package-summary.html#links">symbolic
* links</a> then this method is used read the target of the link, failing
* if the file is not a link. The target of the link need not exist. The
* returned {@code Path} object will be associated with the same file
* links</a> then this method is used to read the target of the link, failing
* if the file is not a symbolic link. The target of the link need not exist.
* The returned {@code Path} object will be associated with the same file
* system as this {@code Path}.
*
* @return a {@code Path} object representing the target of the link
......@@ -584,7 +584,7 @@ public abstract class Path
* if the implementation does not support symbolic links
* @throws NotLinkException
* if the target could otherwise not be read because the file
* is not a link <i>(optional specific exception)</i>
* is not a symbolic link <i>(optional specific exception)</i>
* @throws IOException
* if an I/O error occurs
* @throws SecurityException
......@@ -724,8 +724,8 @@ public abstract class Path
* exists, except if the source and target are the {@link #isSameFile same}
* file, in which case this method has no effect. File attributes are not
* required to be copied to the target file. If symbolic links are supported,
* and the file is a link, then the final target of the link is copied. If
* the file is a directory then it creates an empty directory in the target
* and the file is a symbolic link, then the final target of the link is copied.
* If the file is a directory then it creates an empty directory in the target
* location (entries in the directory are not copied). This method can be
* used with the {@link Files#walkFileTree Files.walkFileTree} utility
* method to copy a directory and all entries in the directory, or an entire
......@@ -740,8 +740,8 @@ public abstract class Path
* <td> {@link StandardCopyOption#REPLACE_EXISTING REPLACE_EXISTING} </td>
* <td> If the target file exists, then the target file is replaced if it
* is not a non-empty directory. If the target file exists and is a
* symbolic-link then the symbolic-link is replaced (not the target of
* the link. </td>
* symbolic link, then the symbolic link itself, not the target of
* the link, is replaced. </td>
* </tr>
* <tr>
* <td> {@link StandardCopyOption#COPY_ATTRIBUTES COPY_ATTRIBUTES} </td>
......@@ -755,11 +755,11 @@ public abstract class Path
* </tr>
* <tr>
* <td> {@link LinkOption#NOFOLLOW_LINKS NOFOLLOW_LINKS} </td>
* <td> Symbolic-links are not followed. If the file, located by this path,
* is a symbolic-link then the link is copied rather than the target of
* the link. It is implementation specific if file attributes can be
* copied to the new link. In other words, the {@code COPY_ATTRIBUTES}
* option may be ignored when copying a link. </td>
* <td> Symbolic links are not followed. If the file, located by this path,
* is a symbolic link, then the symbolic link itself, not the target of
* the link, is copied. It is implementation specific if file attributes
* can be copied to the new link. In other words, the {@code
* COPY_ATTRIBUTES} option may be ignored when copying a symbolic link. </td>
* </tr>
* </table>
*
......@@ -807,18 +807,19 @@ public abstract class Path
* <p> By default, this method attempts to move the file to the target
* location, failing if the target file exists except if the source and
* target are the {@link #isSameFile same} file, in which case this method
* has no effect. If the file is a symbolic link then the link is moved and
* not the target of the link. This method may be invoked to move an empty
* directory. In some implementations a directory has entries for special
* files or links that are created when the directory is created. In such
* implementations a directory is considered empty when only the special
* entries exist. When invoked to move a directory that is not empty then the
* directory is moved if it does not require moving the entries in the directory.
* For example, renaming a directory on the same {@link FileStore} will usually
* not require moving the entries in the directory. When moving a directory
* requires that its entries be moved then this method fails (by throwing
* an {@code IOException}). To move a <i>file tree</i> may involve copying
* rather than moving directories and this can be done using the {@link
* has no effect. If the file is a symbolic link then the symbolic link
* itself, not the target of the link, is moved. This method may be
* invoked to move an empty directory. In some implementations a directory
* has entries for special files or links that are created when the
* directory is created. In such implementations a directory is considered
* empty when only the special entries exist. When invoked to move a
* directory that is not empty then the directory is moved if it does not
* require moving the entries in the directory. For example, renaming a
* directory on the same {@link FileStore} will usually not require moving
* the entries in the directory. When moving a directory requires that its
* entries be moved then this method fails (by throwing an {@code
* IOException}). To move a <i>file tree</i> may involve copying rather
* than moving directories and this can be done using the {@link
* #copyTo copyTo} method in conjunction with the {@link
* Files#walkFileTree Files.walkFileTree} utility method.
*
......@@ -831,8 +832,8 @@ public abstract class Path
* <td> {@link StandardCopyOption#REPLACE_EXISTING REPLACE_EXISTING} </td>
* <td> If the target file exists, then the target file is replaced if it
* is not a non-empty directory. If the target file exists and is a
* symbolic-link then the symbolic-link is replaced and not the target of
* the link. </td>
* symbolic link, then the symbolic link itself, not the target of
* the link, is replaced. </td>
* </tr>
* <tr>
* <td> {@link StandardCopyOption#ATOMIC_MOVE ATOMIC_MOVE} </td>
......@@ -1495,7 +1496,7 @@ public abstract class Path
*
* <p> Where a file is registered with a watch service by means of a symbolic
* link then it is implementation specific if the watch continues to depend
* on the existence of the link after it is registered.
* on the existence of the symbolic link after it is registered.
*
* @param watcher
* the watch service to which this object is to be registered
......
......@@ -166,12 +166,13 @@ public abstract class SecureDirectoryStream<T>
/**
* Deletes a file.
*
* <p> Unlike the {@link Path#delete delete()} method, this method
* does not first examine the file to determine if the file is a directory.
* <p> Unlike the {@link Path#delete delete()} method, this method does
* not first examine the file to determine if the file is a directory.
* Whether a directory is deleted by this method is system dependent and
* therefore not specified. If the file is a symbolic-link then the link is
* deleted (not the final target of the link). When the parameter is a
* relative path then the file to delete is relative to this open directory.
* therefore not specified. If the file is a symbolic link, then the link
* itself, not the final target of the link, is deleted. When the
* parameter is a relative path then the file to delete is relative to
* this open directory.
*
* @param path
* the path of the file to delete
......
......@@ -48,9 +48,9 @@ public final class Attributes {
* symbolic links are followed and the file attributes of the final target
* of the link are read. If the option {@link LinkOption#NOFOLLOW_LINKS
* NOFOLLOW_LINKS} is present then symbolic links are not followed and so
* the method returns the file attributes of the symbolic link. This option
* should be used where there is a need to determine if a file is a
* symbolic link:
* the method returns the file attributes of the symbolic link itself.
* This option should be used where there is a need to determine if a
* file is a symbolic link:
* <pre>
* boolean isSymbolicLink = Attributes.readBasicFileAttributes(file, NOFOLLOW_LINKS).isSymbolicLink();
* </pre>
......@@ -98,7 +98,7 @@ public final class Attributes {
* symbolic links are followed and the file attributes of the final target
* of the link are read. If the option {@link LinkOption#NOFOLLOW_LINKS
* NOFOLLOW_LINKS} is present then symbolic links are not followed and so
* the method returns the file attributes of the symbolic link.
* the method returns the file attributes of the symbolic link itself.
*
* @param file
* A file reference that locates the file
......@@ -145,7 +145,7 @@ public final class Attributes {
* symbolic links are followed and the file attributes of the final target
* of the link are read. If the option {@link LinkOption#NOFOLLOW_LINKS
* NOFOLLOW_LINKS} is present then symbolic links are not followed and so
* the method returns the file attributes of the symbolic link.
* the method returns the file attributes of the symbolic link itself.
*
* @param file
* A file reference that locates the file
......
......@@ -81,13 +81,13 @@ public interface BasicFileAttributes {
boolean isDirectory();
/**
* Tells whether the file is a symbolic-link.
* Tells whether the file is a symbolic link.
*/
boolean isSymbolicLink();
/**
* Tells whether the file is something other than a regular file, directory,
* or link.
* or symbolic link.
*/
boolean isOther();
......
/*
* Copyright 2000-2003 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2000-2009 Sun Microsystems, Inc. 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
......@@ -35,10 +35,7 @@
package java.text;
import java.awt.Toolkit;
import java.awt.font.TextAttribute;
import java.awt.font.NumericShaper;
import sun.text.CodePointIterator;
import sun.text.bidi.BidiBase;
/**
* This class implements the Unicode Bidirectional Algorithm.
......@@ -62,15 +59,6 @@ import sun.text.CodePointIterator;
* @since 1.4
*/
public final class Bidi {
byte dir;
byte baselevel;
int length;
int[] runs;
int[] cws;
static {
sun.font.FontManagerNativeLibrary.load();
}
/** Constant indicating base direction is left-to-right. */
public static final int DIRECTION_LEFT_TO_RIGHT = 0;
......@@ -94,7 +82,7 @@ public final class Bidi {
*/
public static final int DIRECTION_DEFAULT_RIGHT_TO_LEFT = -1;
private static final int DIR_MIXED = 2;
private BidiBase bidiBase;
/**
* Create Bidi from the given paragraph of text and base direction.
......@@ -109,7 +97,7 @@ public final class Bidi {
throw new IllegalArgumentException("paragraph is null");
}
nativeBidiChars(this, paragraph.toCharArray(), 0, null, 0, paragraph.length(), flags);
bidiBase = new BidiBase(paragraph.toCharArray(), 0, null, 0, paragraph.length(), flags);
}
/**
......@@ -142,67 +130,8 @@ public final class Bidi {
throw new IllegalArgumentException("paragraph is null");
}
int flags = DIRECTION_DEFAULT_LEFT_TO_RIGHT;
byte[] embeddings = null;
int start = paragraph.getBeginIndex();
int limit = paragraph.getEndIndex();
int length = limit - start;
int n = 0;
char[] text = new char[length];
for (char c = paragraph.first(); c != paragraph.DONE; c = paragraph.next()) {
text[n++] = c;
}
paragraph.first();
try {
Boolean runDirection = (Boolean)paragraph.getAttribute(TextAttribute.RUN_DIRECTION);
if (runDirection != null) {
if (TextAttribute.RUN_DIRECTION_LTR.equals(runDirection)) {
flags = DIRECTION_LEFT_TO_RIGHT; // clears default setting
} else {
flags = DIRECTION_RIGHT_TO_LEFT;
}
}
}
catch (ClassCastException e) {
}
try {
NumericShaper shaper = (NumericShaper)paragraph.getAttribute(TextAttribute.NUMERIC_SHAPING);
if (shaper != null) {
shaper.shape(text, 0, text.length);
}
}
catch (ClassCastException e) {
}
int pos = start;
do {
paragraph.setIndex(pos);
Object embeddingLevel = paragraph.getAttribute(TextAttribute.BIDI_EMBEDDING);
int newpos = paragraph.getRunLimit(TextAttribute.BIDI_EMBEDDING);
if (embeddingLevel != null) {
try {
int intLevel = ((Integer)embeddingLevel).intValue();
if (intLevel >= -61 && intLevel < 61) {
byte level = (byte)(intLevel < 0 ? (-intLevel | 0x80) : intLevel);
if (embeddings == null) {
embeddings = new byte[length];
}
for (int i = pos - start; i < newpos - start; ++i) {
embeddings[i] = level;
}
}
}
catch (ClassCastException e) {
}
}
pos = newpos;
} while (pos < limit);
nativeBidiChars(this, text, 0, embeddings, 0, text.length, flags);
bidiBase = new BidiBase(0, 0);
bidiBase.setPara(paragraph);
}
/**
......@@ -240,46 +169,7 @@ public final class Bidi {
" for embeddings of length: " + text.length);
}
if (embeddings != null) {
// native uses high bit to indicate override, not negative value, sigh
for (int i = embStart, embLimit = embStart + paragraphLength; i < embLimit; ++i) {
if (embeddings[i] < 0) {
byte[] temp = new byte[paragraphLength];
System.arraycopy(embeddings, embStart, temp, 0, paragraphLength);
for (i -= embStart; i < paragraphLength; ++i) {
if (temp[i] < 0) {
temp[i] = (byte)(-temp[i] | 0x80);
}
}
embeddings = temp;
embStart = 0;
break;
}
}
}
nativeBidiChars(this, text, textStart, embeddings, embStart, paragraphLength, flags);
}
/**
* Private constructor used by line bidi.
*/
private Bidi(int dir, int baseLevel, int length, int[] data, int[] cws) {
reset(dir, baseLevel, length, data, cws);
}
/**
* Private mutator used by native code.
*/
private void reset(int dir, int baselevel, int length, int[] data, int[] cws) {
this.dir = (byte)dir;
this.baselevel = (byte)baselevel;
this.length = length;
this.runs = data;
this.cws = cws;
bidiBase = new BidiBase(text, textStart, embeddings, embStart, paragraphLength, flags);
}
/**
......@@ -290,96 +180,10 @@ public final class Bidi {
* @param lineLimit the offset from the start of the paragraph to the limit of the line.
*/
public Bidi createLineBidi(int lineStart, int lineLimit) {
if (lineStart == 0 && lineLimit == length) {
return this;
}
int lineLength = lineLimit - lineStart;
if (lineStart < 0 ||
lineLimit < lineStart ||
lineLimit > length) {
throw new IllegalArgumentException("range " + lineStart +
" to " + lineLimit +
" is invalid for paragraph of length " + length);
}
AttributedString astr = new AttributedString("");
Bidi newBidi = new Bidi(astr.getIterator());
if (runs == null) {
return new Bidi(dir, baselevel, lineLength, null, null);
} else {
int cwspos = -1;
int[] ncws = null;
if (cws != null) {
int cwss = 0;
int cwsl = cws.length;
while (cwss < cwsl) {
if (cws[cwss] >= lineStart) {
cwsl = cwss;
while (cwsl < cws.length && cws[cwsl] < lineLimit) {
cwsl++;
}
int ll = lineLimit-1;
while (cwsl > cwss && cws[cwsl-1] == ll) {
cwspos = ll; // record start of counter-directional whitespace
--cwsl;
--ll;
}
if (cwspos == lineStart) { // entire line is cws, so ignore
return new Bidi(dir, baselevel, lineLength, null, null);
}
int ncwslen = cwsl - cwss;
if (ncwslen > 0) {
ncws = new int[ncwslen];
for (int i = 0; i < ncwslen; ++i) {
ncws[i] = cws[cwss+i] - lineStart;
}
}
break;
}
++cwss;
}
}
int[] nruns = null;
int nlevel = baselevel;
int limit = cwspos == -1 ? lineLimit : cwspos;
int rs = 0;
int rl = runs.length;
int ndir = dir;
for (; rs < runs.length; rs += 2) {
if (runs[rs] > lineStart) {
rl = rs;
while (rl < runs.length && runs[rl] < limit) {
rl += 2;
}
if ((rl > rs) || (runs[rs+1] != baselevel)) {
rl += 2;
if (cwspos != -1 && rl > rs && runs[rl-1] != baselevel) { // add level for cws
nruns = new int[rl - rs + 2];
nruns[rl - rs] = lineLength;
nruns[rl - rs + 1] = baselevel;
} else {
limit = lineLimit;
nruns = new int[rl - rs];
}
int n = 0;
for (int i = rs; i < rl; i += 2) {
nruns[n++] = runs[i] - lineStart;
nruns[n++] = runs[i+1];
}
nruns[n-2] = limit - lineStart;
} else {
ndir = (runs[rs+1] & 0x1) == 0 ? DIRECTION_LEFT_TO_RIGHT : DIRECTION_RIGHT_TO_LEFT;
}
break;
}
}
return new Bidi(ndir, baselevel, lineLength, nruns, ncws);
}
return bidiBase.setLine(this, bidiBase, newBidi, newBidi.bidiBase,lineStart, lineLimit);
}
/**
......@@ -388,7 +192,7 @@ public final class Bidi {
* @return true if the line is not left-to-right or right-to-left.
*/
public boolean isMixed() {
return dir == DIR_MIXED;
return bidiBase.isMixed();
}
/**
......@@ -396,7 +200,7 @@ public final class Bidi {
* @return true if the line is all left-to-right text and the base direction is left-to-right
*/
public boolean isLeftToRight() {
return dir == DIRECTION_LEFT_TO_RIGHT;
return bidiBase.isLeftToRight();
}
/**
......@@ -404,7 +208,7 @@ public final class Bidi {
* @return true if the line is all right-to-left text, and the base direction is right-to-left
*/
public boolean isRightToLeft() {
return dir == DIRECTION_RIGHT_TO_LEFT;
return bidiBase.isRightToLeft();
}
/**
......@@ -412,7 +216,7 @@ public final class Bidi {
* @return the length of text in the line
*/
public int getLength() {
return length;
return bidiBase.getLength();
}
/**
......@@ -420,7 +224,7 @@ public final class Bidi {
* @return true if the base direction is left-to-right
*/
public boolean baseIsLeftToRight() {
return (baselevel & 0x1) == 0;
return bidiBase.baseIsLeftToRight();
}
/**
......@@ -428,7 +232,7 @@ public final class Bidi {
* @return the base level
*/
public int getBaseLevel() {
return baselevel;
return bidiBase.getParaLevel();
}
/**
......@@ -438,17 +242,7 @@ public final class Bidi {
* @return the resolved level of the character at offset
*/
public int getLevelAt(int offset) {
if (runs == null || offset < 0 || offset >= length) {
return baselevel;
} else {
int i = 0;
do {
if (offset < runs[i]) {
return runs[i+1];
}
i += 2;
} while (true);
}
return bidiBase.getLevelAt(offset);
}
/**
......@@ -456,7 +250,7 @@ public final class Bidi {
* @return the number of level runs
*/
public int getRunCount() {
return runs == null ? 1 : runs.length / 2;
return bidiBase.countRuns();
}
/**
......@@ -465,7 +259,7 @@ public final class Bidi {
* @return the level of the run
*/
public int getRunLevel(int run) {
return runs == null ? baselevel : runs[run * 2 + 1];
return bidiBase.getRunLevel(run);
}
/**
......@@ -475,7 +269,7 @@ public final class Bidi {
* @return the start of the run
*/
public int getRunStart(int run) {
return (runs == null || run == 0) ? 0 : runs[run * 2 - 2];
return bidiBase.getRunStart(run);
}
/**
......@@ -486,7 +280,7 @@ public final class Bidi {
* @return limit the limit of the run
*/
public int getRunLimit(int run) {
return runs == null ? length : runs[run * 2];
return bidiBase.getRunLimit(run);
}
/**
......@@ -501,16 +295,7 @@ public final class Bidi {
* @return true if the range of characters requires bidi analysis
*/
public static boolean requiresBidi(char[] text, int start, int limit) {
CodePointIterator cpi = CodePointIterator.create(text, start, limit);
for (int cp = cpi.next(); cp != CodePointIterator.DONE; cp = cpi.next()) {
if (cp > 0x0590) {
int dc = nativeGetDirectionCode(cp);
if ((RMASK & (1 << dc)) != 0) {
return true;
}
}
}
return false;
return BidiBase.requiresBidi(text, start, limit);
}
/**
......@@ -530,124 +315,14 @@ public final class Bidi {
* @param count the number of objects to reorder
*/
public static void reorderVisually(byte[] levels, int levelStart, Object[] objects, int objectStart, int count) {
if (count < 0) {
throw new IllegalArgumentException("count " + count + " must be >= 0");
}
if (levelStart < 0 || levelStart + count > levels.length) {
throw new IllegalArgumentException("levelStart " + levelStart + " and count " + count +
" out of range [0, " + levels.length + "]");
}
if (objectStart < 0 || objectStart + count > objects.length) {
throw new IllegalArgumentException("objectStart " + objectStart + " and count " + count +
" out of range [0, " + objects.length + "]");
}
byte lowestOddLevel = (byte)(NUMLEVELS + 1);
byte highestLevel = 0;
// initialize mapping and levels
int levelLimit = levelStart + count;
for (int i = levelStart; i < levelLimit; i++) {
byte level = levels[i];
if (level > highestLevel) {
highestLevel = level;
}
if ((level & 0x01) != 0 && level < lowestOddLevel) {
lowestOddLevel = level;
}
}
int delta = objectStart - levelStart;
while (highestLevel >= lowestOddLevel) {
int i = levelStart;
for (;;) {
while (i < levelLimit && levels[i] < highestLevel) {
i++;
}
int begin = i++;
if (begin == levelLimit) {
break; // no more runs at this level
}
while (i < levelLimit && levels[i] >= highestLevel) {
i++;
}
int end = i - 1;
begin += delta;
end += delta;
while (begin < end) {
Object temp = objects[begin];
objects[begin] = objects[end];
objects[end] = temp;
++begin;
--end;
}
}
--highestLevel;
}
BidiBase.reorderVisually(levels, levelStart, objects, objectStart, count);
}
private static final char NUMLEVELS = 62;
private static final int RMASK =
(1 << 1 /* U_RIGHT_TO_LEFT */) |
(1 << 5 /* U_ARABIC_NUMBER */) |
(1 << 13 /* U_RIGHT_TO_LEFT_ARABIC */) |
(1 << 14 /* U_RIGHT_TO_LEFT_EMBEDDING */) |
(1 << 15 /* U_RIGHT_TO_LEFT_OVERRIDE */);
/** Access native bidi implementation. */
private static native int nativeGetDirectionCode(int cp);
/** Access native bidi implementation. */
private static synchronized native void nativeBidiChars(Bidi bidi, char[] text, int textStart,
byte[] embeddings, int embeddingStart,
int length, int flags);
/**
* Display the bidi internal state, used in debugging.
*/
public String toString() {
StringBuffer buf = new StringBuffer(super.toString());
buf.append("[dir: " + dir);
buf.append(" baselevel: " + baselevel);
buf.append(" length: " + length);
if (runs == null) {
buf.append(" runs: null");
} else {
buf.append(" runs: [");
for (int i = 0; i < runs.length; i += 2) {
if (i != 0) {
buf.append(' ');
}
buf.append(runs[i]); // limit
buf.append('/');
buf.append(runs[i+1]); // level
}
buf.append(']');
}
if (cws == null) {
buf.append(" cws: null");
} else {
buf.append(" cws: [");
for (int i = 0; i < cws.length; ++i) {
if (i != 0) {
buf.append(' ');
}
buf.append(Integer.toHexString(cws[i]));
}
buf.append(']');
}
buf.append(']');
return buf.toString();
return bidiBase.toString();
}
}
......@@ -28,6 +28,7 @@ package javax.imageio;
import java.awt.image.BufferedImage;
import java.awt.image.RenderedImage;
import java.io.File;
import java.io.FilePermission;
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
......@@ -195,13 +196,22 @@ public final class ImageIO {
} else {
cachepath = getTempDir();
if (cachepath == null) {
if (cachepath == null || cachepath.isEmpty()) {
getCacheInfo().setHasPermission(Boolean.FALSE);
return false;
}
}
security.checkWrite(cachepath);
// we have to check whether we can read, write,
// and delete cache files.
// So, compose cache file path and check it.
String filepath = cachepath;
if (!filepath.endsWith(File.separator)) {
filepath += File.separator;
}
filepath += "*";
security.checkPermission(new FilePermission(filepath, "read, write, delete"));
}
} catch (SecurityException e) {
getCacheInfo().setHasPermission(Boolean.FALSE);
......
......@@ -160,6 +160,13 @@ public class TrueTypeFont extends FileFont {
private boolean supportsJA;
private boolean supportsCJK;
/* These are for faster access to the name of the font as
* typically exposed via API to applications.
*/
private Locale nameLocale;
private String localeFamilyName;
private String localeFullName;
/**
* - does basic verification of the file
* - reads the header table for this font (within a collection)
......@@ -1092,6 +1099,10 @@ public class TrueTypeFont extends FileFont {
* greater than 32767, so read and store those as ints
*/
int stringPtr = sbuffer.get() & 0xffff;
nameLocale = sun.awt.SunToolkit.getStartupLocale();
short nameLocaleID = FontManager.getLCIDFromLocale(nameLocale);
for (int i=0; i<numRecords; i++) {
short platformID = sbuffer.get();
if (platformID != MS_PLATFORM_ID) {
......@@ -1103,15 +1114,24 @@ public class TrueTypeFont extends FileFont {
short nameID = sbuffer.get();
int nameLen = ((int) sbuffer.get()) & 0xffff;
int namePtr = (((int) sbuffer.get()) & 0xffff) + stringPtr;
String tmpName = null;
switch (nameID) {
case FAMILY_NAME_ID:
if (familyName == null || langID == ENGLISH_LOCALE_ID) {
if (familyName == null || langID == ENGLISH_LOCALE_ID ||
langID == nameLocaleID)
{
buffer.position(namePtr);
buffer.get(name, 0, nameLen);
familyName = makeString(name, nameLen, encodingID);
tmpName = makeString(name, nameLen, encodingID);
if (familyName == null || langID == ENGLISH_LOCALE_ID){
familyName = tmpName;
}
if (langID == nameLocaleID) {
localeFamilyName = tmpName;
}
}
/*
for (int ii=0;ii<nameLen;ii++) {
......@@ -1129,15 +1149,29 @@ public class TrueTypeFont extends FileFont {
case FULL_NAME_ID:
if (fullName == null || langID == ENGLISH_LOCALE_ID) {
if (fullName == null || langID == ENGLISH_LOCALE_ID ||
langID == nameLocaleID)
{
buffer.position(namePtr);
buffer.get(name, 0, nameLen);
fullName = makeString(name, nameLen, encodingID);
tmpName = makeString(name, nameLen, encodingID);
if (fullName == null || langID == ENGLISH_LOCALE_ID) {
fullName = tmpName;
}
if (langID == nameLocaleID) {
localeFullName = tmpName;
}
}
break;
}
}
if (localeFamilyName == null) {
localeFamilyName = familyName;
}
if (localeFullName == null) {
localeFullName = fullName;
}
}
}
......@@ -1220,6 +1254,8 @@ public class TrueTypeFont extends FileFont {
public String getFontName(Locale locale) {
if (locale == null) {
return fullName;
} else if (locale.equals(nameLocale) && localeFullName != null) {
return localeFullName;
} else {
short localeID = FontManager.getLCIDFromLocale(locale);
String name = lookupName(localeID, FULL_NAME_ID);
......@@ -1234,11 +1270,13 @@ public class TrueTypeFont extends FileFont {
public String getFamilyName(Locale locale) {
if (locale == null) {
return familyName;
} else if (locale.equals(nameLocale) && localeFamilyName != null) {
return localeFamilyName;
} else {
short localeID = FontManager.getLCIDFromLocale(locale);
String name = lookupName(localeID, FAMILY_NAME_ID);
if (name == null) {
return familyName;
return familyName;
} else {
return name;
}
......
......@@ -96,7 +96,7 @@ public final class PiscesCache {
bboxX1 = x1+1;
} else {
if (bboxX0 > x0) bboxX0 = x0;
if (bboxX1 < x1) bboxX1 = x1;
if (bboxX1 < x1 + 1) bboxX1 = x1 + 1;
while (bboxY1++ < y) {
reallocRowInfo(alphaRows+1);
minTouched[alphaRows] = 0;
......
......@@ -25,6 +25,8 @@
package sun.net.www.http;
import java.io.*;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
......@@ -60,6 +62,76 @@ public class HttpCapture {
private static boolean initialized = false;
private static volatile ArrayList<Pattern> patterns = null;
private static volatile ArrayList<String> capFiles = null;
/* Logging is done in an ugly way so that it does not require the presence
* the java.util.logging package. If the Logger class is not available, then
* logging is turned off. This is for helping the modularization effort.
*/
private static Object logger = null;
private static boolean logging = false;
static {
Class cl;
try {
cl = Class.forName("java.util.logging.Logger");
} catch (ClassNotFoundException ex) {
cl = null;
}
if (cl != null) {
try {
Method m = cl.getMethod("getLogger", String.class);
logger = m.invoke(null, "sun.net.www.protocol.http.HttpURLConnection");
logging = true;
} catch (NoSuchMethodException noSuchMethodException) {
} catch (SecurityException securityException) {
} catch (IllegalAccessException illegalAccessException) {
} catch (IllegalArgumentException illegalArgumentException) {
} catch (InvocationTargetException invocationTargetException) {
}
}
}
public static void fine(String s) {
if (logging) {
((Logger)logger).fine(s);
}
}
public static void finer(String s) {
if (logging) {
((Logger)logger).finer(s);
}
}
public static void finest(String s) {
if (logging) {
((Logger)logger).finest(s);
}
}
public static void severe(String s) {
if (logging) {
((Logger)logger).finest(s);
}
}
public static void info(String s) {
if (logging) {
((Logger)logger).info(s);
}
}
public static void warning(String s) {
if (logging) {
((Logger)logger).warning(s);
}
}
public static boolean isLoggable(String level) {
if (!logging) {
return false;
}
return ((Logger)logger).isLoggable(Level.parse(level));
}
private static synchronized void init() {
initialized = true;
......
......@@ -28,8 +28,6 @@ package sun.net.www.http;
import java.io.*;
import java.net.*;
import java.util.Locale;
import java.util.logging.Level;
import java.util.logging.Logger;
import sun.net.NetworkClient;
import sun.net.ProgressSource;
import sun.net.www.MessageHeader;
......@@ -66,10 +64,6 @@ public class HttpClient extends NetworkClient {
/** Default port number for http daemons. REMIND: make these private */
static final int httpPortNumber = 80;
// Use same logger as HttpURLConnection since we want to combine both event
// streams into one single HTTP log
private static Logger logger = Logger.getLogger("sun.net.www.protocol.http.HttpURLConnection");
/** return default port number (subclasses may override) */
protected int getDefaultPort () { return httpPortNumber; }
......@@ -810,8 +804,8 @@ public class HttpClient extends NetworkClient {
if (isKeepingAlive()) {
// Wrap KeepAliveStream if keep alive is enabled.
if (logger.isLoggable(Level.FINEST)) {
logger.finest("KeepAlive stream used: " + url);
if (HttpCapture.isLoggable("FINEST")) {
HttpCapture.finest("KeepAlive stream used: " + url);
}
serverInput = new KeepAliveStream(serverInput, pi, cl, this);
failedOnce = false;
......
......@@ -49,8 +49,7 @@ public class HttpLogFormatter extends java.util.logging.SimpleFormatter {
@Override
public String format(LogRecord record) {
if (!"sun.net.www.protocol.http.HttpURLConnection".equalsIgnoreCase(record.getSourceClassName())
&& !"sun.net.www.http.HttpClient".equalsIgnoreCase(record.getSourceClassName())) {
if (!"sun.net.www.http.HttpCapture".equalsIgnoreCase(record.getSourceClassName())) {
// Don't change format for stuff that doesn't concern us
return super.format(record);
}
......
......@@ -51,14 +51,13 @@ import java.util.List;
import java.util.Locale;
import java.util.StringTokenizer;
import java.util.Iterator;
import java.util.logging.Level;
import java.util.logging.Logger;
import sun.net.*;
import sun.net.www.*;
import sun.net.www.http.HttpClient;
import sun.net.www.http.PosterOutputStream;
import sun.net.www.http.ChunkedInputStream;
import sun.net.www.http.ChunkedOutputStream;
import sun.net.www.http.HttpCapture;
import java.text.SimpleDateFormat;
import java.util.TimeZone;
import java.net.MalformedURLException;
......@@ -71,8 +70,6 @@ import java.nio.ByteBuffer;
public class HttpURLConnection extends java.net.HttpURLConnection {
private static Logger logger = Logger.getLogger("sun.net.www.protocol.http.HttpURLConnection");
static String HTTP_CONNECT = "CONNECT";
static final String version;
......@@ -304,14 +301,14 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
return java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<PasswordAuthentication>() {
public PasswordAuthentication run() {
if (logger.isLoggable(Level.FINEST)) {
logger.finest("Requesting Authentication: host =" + host + " url = " + url);
if (HttpCapture.isLoggable("FINEST")) {
HttpCapture.finest("Requesting Authentication: host =" + host + " url = " + url);
}
PasswordAuthentication pass = Authenticator.requestPasswordAuthentication(
host, addr, port, protocol,
prompt, scheme, url, authType);
if (pass != null && logger.isLoggable(Level.FINEST)) {
logger.finest("Authentication returned: " + pass.toString());
if (HttpCapture.isLoggable("FINEST")) {
HttpCapture.finest("Authentication returned: " + (pass != null ? pass.toString() : "null"));
}
return pass;
}
......@@ -466,8 +463,8 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
setRequests=true;
}
if (logger.isLoggable(Level.FINE)) {
logger.fine(requests.toString());
if (HttpCapture.isLoggable("FINE")) {
HttpCapture.fine(requests.toString());
}
http.writeRequests(requests, poster);
if (ps.checkError()) {
......@@ -731,11 +728,9 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
&& !(cachedResponse instanceof SecureCacheResponse)) {
cachedResponse = null;
}
if (logger.isLoggable(Level.FINEST)) {
logger.finest("Cache Request for " + uri + " / " + getRequestMethod());
if (cachedResponse != null) {
logger.finest("From cache: "+cachedResponse.toString());
}
if (HttpCapture.isLoggable("FINEST")) {
HttpCapture.finest("Cache Request for " + uri + " / " + getRequestMethod());
HttpCapture.finest("From cache: " + (cachedResponse != null ? cachedResponse.toString() : "null"));
}
if (cachedResponse != null) {
cachedHeaders = mapToMessageHeader(cachedResponse.getHeaders());
......@@ -774,8 +769,8 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
});
if (sel != null) {
URI uri = sun.net.www.ParseUtil.toURI(url);
if (logger.isLoggable(Level.FINEST)) {
logger.finest("ProxySelector Request for " + uri);
if (HttpCapture.isLoggable("FINEST")) {
HttpCapture.finest("ProxySelector Request for " + uri);
}
Iterator<Proxy> it = sel.select(uri).iterator();
Proxy p;
......@@ -791,9 +786,9 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
http = getNewHttpClient(url, p, connectTimeout, false);
http.setReadTimeout(readTimeout);
}
if (logger.isLoggable(Level.FINEST)) {
if (HttpCapture.isLoggable("FINEST")) {
if (p != null) {
logger.finest("Proxy used: " + p.toString());
HttpCapture.finest("Proxy used: " + p.toString());
}
}
break;
......@@ -1023,15 +1018,15 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
URI uri = ParseUtil.toURI(url);
if (uri != null) {
if (logger.isLoggable(Level.FINEST)) {
logger.finest("CookieHandler request for " + uri);
if (HttpCapture.isLoggable("FINEST")) {
HttpCapture.finest("CookieHandler request for " + uri);
}
Map<String, List<String>> cookies
= cookieHandler.get(
uri, requests.getHeaders(EXCLUDE_HEADERS));
if (!cookies.isEmpty()) {
if (logger.isLoggable(Level.FINEST)) {
logger.finest("Cookies retrieved: " + cookies.toString());
if (HttpCapture.isLoggable("FINEST")) {
HttpCapture.finest("Cookies retrieved: " + cookies.toString());
}
for (Map.Entry<String, List<String>> entry :
cookies.entrySet()) {
......@@ -1162,8 +1157,8 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
writeRequests();
}
http.parseHTTP(responses, pi, this);
if (logger.isLoggable(Level.FINE)) {
logger.fine(responses.toString());
if (HttpCapture.isLoggable("FINE")) {
HttpCapture.fine(responses.toString());
}
inputStream = http.getInputStream();
......@@ -1607,8 +1602,8 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
http.parseHTTP(responses, null, this);
/* Log the response to the CONNECT */
if (logger.isLoggable(Level.FINE)) {
logger.fine(responses.toString());
if (HttpCapture.isLoggable("FINE")) {
HttpCapture.fine(responses.toString());
}
statusLine = responses.getValue(0);
......@@ -1735,8 +1730,8 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
setPreemptiveProxyAuthentication(requests);
/* Log the CONNECT request */
if (logger.isLoggable(Level.FINE)) {
logger.fine(requests.toString());
if (HttpCapture.isLoggable("FINE")) {
HttpCapture.fine(requests.toString());
}
http.writeRequests(requests, null);
......@@ -1880,8 +1875,8 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
}
}
}
if (logger.isLoggable(Level.FINER)) {
logger.finer("Proxy Authentication for " + authhdr.toString() +" returned " + ret.toString());
if (HttpCapture.isLoggable("FINER")) {
HttpCapture.finer("Proxy Authentication for " + authhdr.toString() +" returned " + (ret != null ? ret.toString() : "null"));
}
return ret;
}
......@@ -2010,8 +2005,8 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
}
}
}
if (logger.isLoggable(Level.FINER)) {
logger.finer("Server Authentication for " + authhdr.toString() +" returned " + ret.toString());
if (HttpCapture.isLoggable("FINER")) {
HttpCapture.finer("Server Authentication for " + authhdr.toString() +" returned " + (ret != null ? ret.toString() : "null"));
}
return ret;
}
......@@ -2086,8 +2081,8 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
if (streaming()) {
throw new HttpRetryException (RETRY_MSG3, stat, loc);
}
if (logger.isLoggable(Level.FINE)) {
logger.fine("Redirected from " + url + " to " + locUrl);
if (HttpCapture.isLoggable("FINE")) {
HttpCapture.fine("Redirected from " + url + " to " + locUrl);
}
// clear out old response headers!!!!
......
/*
* Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2003-2009 Sun Microsystems, Inc. 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
......@@ -351,18 +351,27 @@ class OCSPChecker extends PKIXCertPathChecker {
}
in = con.getInputStream();
byte[] response = null;
int total = 0;
int contentLength = con.getContentLength();
if (contentLength == -1) {
if (contentLength != -1) {
response = new byte[contentLength];
} else {
response = new byte[2048];
contentLength = Integer.MAX_VALUE;
}
byte[] response = new byte[contentLength];
int total = 0;
int count = 0;
while (count != -1 && total < contentLength) {
count = in.read(response, total, response.length - total);
while (total < contentLength) {
int count = in.read(response, total, response.length - total);
if (count < 0)
break;
total += count;
if (total >= response.length && total < contentLength) {
response = Arrays.copyOf(response, total * 2);
}
}
response = Arrays.copyOf(response, total);
OCSPResponse ocspResponse = new OCSPResponse(response, pkixParams,
responderCert);
......
/*
* Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -32,6 +32,7 @@ import java.net.URL;
import java.net.HttpURLConnection;
import java.util.Iterator;
import java.util.Set;
import java.util.Arrays;
import sun.security.pkcs.*;
......@@ -137,23 +138,33 @@ public class HttpTimestamper implements Timestamper {
}
System.out.println();
}
verifyMimeType(connection.getContentType());
int total = 0;
int contentLength = connection.getContentLength();
if (contentLength == -1) {
if (contentLength != -1) {
replyBuffer = new byte[contentLength];
} else {
replyBuffer = new byte[2048];
contentLength = Integer.MAX_VALUE;
}
verifyMimeType(connection.getContentType());
replyBuffer = new byte[contentLength];
int total = 0;
int count = 0;
while (count != -1 && total < contentLength) {
count = input.read(replyBuffer, total,
while (total < contentLength) {
int count = input.read(replyBuffer, total,
replyBuffer.length - total);
if (count < 0)
break;
total += count;
if (total >= replyBuffer.length && total < contentLength) {
replyBuffer = Arrays.copyOf(replyBuffer, total * 2);
}
}
replyBuffer = Arrays.copyOf(replyBuffer, total);
if (DEBUG) {
System.out.println("received timestamp response (length=" +
replyBuffer.length + ")");
total + ")");
}
} finally {
if (input != null) {
......
此差异已折叠。
此差异已折叠。
/*
* Portions Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
*******************************************************************************
* (C) Copyright IBM Corp. and others, 1996-2009 - All Rights Reserved *
* *
* The original version of this source code and documentation is copyrighted *
* and owned by IBM, These materials are provided under terms of a License *
* Agreement between IBM and Sun. This technology is protected by multiple *
* US and International patents. This notice and attribution to IBM may not *
* to removed. *
*******************************************************************************
*/
/* Written by Simon Montagu, Matitiahu Allouche
* (ported from C code written by Markus W. Scherer)
*/
package sun.text.bidi;
/**
* A BidiRun represents a sequence of characters at the same embedding level.
* The Bidi algorithm decomposes a piece of text into sequences of characters
* at the same embedding level, each such sequence is called a <quote>run</quote>.
*
* <p>A BidiRun represents such a run by storing its essential properties,
* but does not duplicate the characters which form the run.
*
* <p>The &quot;limit&quot; of the run is the position just after the
* last character, i.e., one more than that position.
*
* <p>This class has no public constructor, and its members cannot be
* modified by users.
*
* @see com.ibm.icu.text.Bidi
*/
public class BidiRun {
int start; /* first logical position of the run */
int limit; /* last visual position of the run +1 */
int insertRemove; /* if >0, flags for inserting LRM/RLM before/after run,
if <0, count of bidi controls within run */
byte level;
/*
* Default constructor
*
* Note that members start and limit of a run instance have different
* meanings depending whether the run is part of the runs array of a Bidi
* object, or if it is a reference returned by getVisualRun() or
* getLogicalRun().
* For a member of the runs array of a Bidi object,
* - start is the first logical position of the run in the source text.
* - limit is one after the last visual position of the run.
* For a reference returned by getLogicalRun() or getVisualRun(),
* - start is the first logical position of the run in the source text.
* - limit is one after the last logical position of the run.
*/
BidiRun()
{
this(0, 0, (byte)0);
}
/*
* Constructor
*/
BidiRun(int start, int limit, byte embeddingLevel)
{
this.start = start;
this.limit = limit;
this.level = embeddingLevel;
}
/*
* Copy the content of a BidiRun instance
*/
void copyFrom(BidiRun run)
{
this.start = run.start;
this.limit = run.limit;
this.level = run.level;
this.insertRemove = run.insertRemove;
}
/**
* Get level of run
*/
public byte getEmbeddingLevel()
{
return level;
}
/**
* Check if run level is even
* @return true if the embedding level of this run is even, i.e. it is a
* left-to-right run.
*/
boolean isEvenRun()
{
return (level & 1) == 0;
}
}
/*
* Portions Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved.
* Portions Copyright 2009 Sun Microsystems, Inc. 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
......@@ -355,7 +355,7 @@ public final class UCharacter
private static int getEuropeanDigit(int ch) {
if ((ch > 0x7a && ch < 0xff21)
|| ch < 0x41 || (ch > 0x5a && ch < 0x61)
|| ch > 0xff5a || (ch > 0xff31 && ch < 0xff41)) {
|| ch > 0xff5a || (ch > 0xff3a && ch < 0xff41)) {
return -1;
}
if (ch <= 0x7a) {
......
......@@ -1783,7 +1783,7 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImage
struct jpeg_source_mgr *src;
JSAMPROW scanLinePtr;
JSAMPROW scanLinePtr = NULL;
jint bands[MAX_BANDS];
int i, j;
jint *body;
......@@ -1819,7 +1819,7 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImage
cinfo = (j_decompress_ptr) data->jpegObj;
if ((numBands < 1) || (numBands > cinfo->num_components) ||
if ((numBands < 1) ||
(sourceXStart < 0) || (sourceXStart >= (jint)cinfo->image_width) ||
(sourceYStart < 0) || (sourceYStart >= (jint)cinfo->image_height) ||
(sourceWidth < 1) || (sourceWidth > (jint)cinfo->image_width) ||
......@@ -1877,16 +1877,6 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImage
return data->abortFlag; // We already threw an out of memory exception
}
// Allocate a 1-scanline buffer
scanLinePtr = (JSAMPROW)malloc(cinfo->image_width*cinfo->num_components);
if (scanLinePtr == NULL) {
RELEASE_ARRAYS(env, data, src->next_input_byte);
JNU_ThrowByName( env,
"java/lang/OutOfMemoryError",
"Reading JPEG Stream");
return data->abortFlag;
}
/* Establish the setjmp return context for sun_jpeg_error_exit to use. */
jerr = (sun_jpeg_error_ptr) cinfo->err;
......@@ -1900,7 +1890,10 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImage
buffer);
JNU_ThrowByName(env, "javax/imageio/IIOException", buffer);
}
free(scanLinePtr);
if (scanLinePtr != NULL) {
free(scanLinePtr);
scanLinePtr = NULL;
}
return data->abortFlag;
}
......@@ -1938,6 +1931,23 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImage
jpeg_start_decompress(cinfo);
if (numBands != cinfo->output_components) {
JNU_ThrowByName(env, "javax/imageio/IIOException",
"Invalid argument to native readImage");
return data->abortFlag;
}
// Allocate a 1-scanline buffer
scanLinePtr = (JSAMPROW)malloc(cinfo->image_width*cinfo->output_components);
if (scanLinePtr == NULL) {
RELEASE_ARRAYS(env, data, src->next_input_byte);
JNU_ThrowByName( env,
"java/lang/OutOfMemoryError",
"Reading JPEG Stream");
return data->abortFlag;
}
// loop over progressive passes
done = FALSE;
while (!done) {
......@@ -1965,9 +1975,9 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImage
scanlineLimit = sourceYStart+sourceHeight;
pixelLimit = scanLinePtr
+(sourceXStart+sourceWidth)*cinfo->num_components;
+(sourceXStart+sourceWidth)*cinfo->output_components;
pixelStride = stepX*cinfo->num_components;
pixelStride = stepX*cinfo->output_components;
targetLine = 0;
while ((data->abortFlag == JNI_FALSE)
......@@ -1982,12 +1992,12 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImage
// Optimization: The component bands are ordered sequentially,
// so we can simply use memcpy() to copy the intermediate
// scanline buffer into the raster.
in = scanLinePtr + (sourceXStart * cinfo->num_components);
in = scanLinePtr + (sourceXStart * cinfo->output_components);
if (pixelLimit > in) {
memcpy(out, in, pixelLimit - in);
}
} else {
for (in = scanLinePtr+sourceXStart*cinfo->num_components;
for (in = scanLinePtr+sourceXStart*cinfo->output_components;
in < pixelLimit;
in += pixelStride) {
for (i = 0; i < numBands; i++) {
......
/*
* Portions Copyright 2000-2003 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* (C) Copyright IBM Corp. 2000 - 2003 - All Rights Reserved
*
* The original version of this source code and documentation is
* copyrighted and owned by IBM. These materials are provided
* under terms of a License Agreement between IBM and Sun.
* This technology is protected by multiple US and International
* patents. This notice and attribution to IBM may not be removed.
*/
// jni interface to native bidi from java
#include <stdlib.h>
#include "jbidi.h"
#define U_COMMON_IMPLEMENTATION
#include "ubidi.h"
#include "ubidiimp.h"
#include "uchardir.h"
static jclass g_bidi_class = 0;
static jmethodID g_bidi_reset = 0;
static void resetBidi(JNIEnv *env, jclass cls, jobject bidi, jint dir, jint level, jint len, jintArray runs, jintArray cws) {
if (!g_bidi_class) {
g_bidi_class = (*env)->NewGlobalRef(env, cls);
g_bidi_reset = (*env)->GetMethodID(env, g_bidi_class, "reset", "(III[I[I)V");
}
(*env)->CallVoidMethod(env, bidi, g_bidi_reset, dir, level, len, runs, cws);
}
JNIEXPORT jint JNICALL Java_java_text_Bidi_nativeGetDirectionCode
(JNIEnv *env, jclass cls, jint cp)
{
return (jint)u_getDirection((uint32_t)cp);
}
JNIEXPORT void JNICALL Java_java_text_Bidi_nativeBidiChars
(JNIEnv *env, jclass cls, jobject jbidi, jcharArray text, jint tStart, jbyteArray embs, jint eStart, jint length, jint dir)
{
UErrorCode err = U_ZERO_ERROR;
UBiDi* bidi = ubidi_openSized(length, length, &err);
if (!U_FAILURE(err)) {
jchar *cText = (jchar*)(*env)->GetPrimitiveArrayCritical(env, text, NULL);
if (cText) {
UBiDiLevel baseLevel = (UBiDiLevel)dir;
jbyte *cEmbs = 0;
uint8_t *cEmbsAdj = 0;
if (embs != NULL) {
cEmbs = (jbyte*)(*env)->GetPrimitiveArrayCritical(env, embs, NULL);
if (cEmbs) {
cEmbsAdj = (uint8_t*)(cEmbs + eStart);
}
}
ubidi_setPara(bidi, cText + tStart, length, baseLevel, cEmbsAdj, &err);
if (cEmbs) {
(*env)->ReleasePrimitiveArrayCritical(env, embs, cEmbs, JNI_ABORT);
}
(*env)->ReleasePrimitiveArrayCritical(env, text, cText, JNI_ABORT);
if (!U_FAILURE(err)) {
jint resDir = (jint)ubidi_getDirection(bidi);
jint resLevel = (jint)ubidi_getParaLevel(bidi);
jint resRunCount = 0;
jintArray resRuns = 0;
jintArray resCWS = 0;
if (resDir == UBIDI_MIXED) {
resRunCount = (jint)ubidi_countRuns(bidi, &err);
if (!U_FAILURE(err)) {
if (resRunCount) {
jint* cResRuns = (jint*)calloc(resRunCount * 2, sizeof(jint));
if (cResRuns) {
int32_t limit = 0;
UBiDiLevel level;
jint *p = cResRuns;
while (limit < length) {
ubidi_getLogicalRun(bidi, limit, &limit, &level);
*p++ = (jint)limit;
*p++ = (jint)level;
}
{
const DirProp *dp = bidi->dirProps;
jint ccws = 0;
jint n = 0;
p = cResRuns;
do {
if ((*(p+1) ^ resLevel) & 0x1) {
while (n < *p) {
if (dp[n++] == WS) {
++ccws;
}
}
} else {
n = *p;
}
p += 2;
} while (n < length);
resCWS = (*env)->NewIntArray(env, ccws);
if (resCWS) {
jint* cResCWS = (jint*)(*env)->GetPrimitiveArrayCritical(env, resCWS, NULL);
if (cResCWS) {
jint ccws = 0;
jint n = 0;
p = cResRuns;
do {
if ((*(p+1) ^ resLevel) & 0x1) {
while (n < *p) {
if (dp[n] == WS) {
cResCWS[ccws++] = n;
}
++n;
}
} else {
n = *p;
}
p += 2;
} while (n < length);
(*env)->ReleasePrimitiveArrayCritical(env, resCWS, cResCWS, 0);
}
}
}
resRuns = (*env)->NewIntArray(env, resRunCount * 2);
if (resRuns) {
(*env)->SetIntArrayRegion(env, resRuns, 0, resRunCount * 2, cResRuns);
}
free(cResRuns);
}
}
}
}
resetBidi(env, cls, jbidi, resDir, resLevel, length, resRuns, resCWS);
}
}
ubidi_close(bidi);
}
}
此差异已折叠。
此差异已折叠。
/*
* Portions Copyright 2000-2003 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* (C) Copyright IBM Corp. 1999-2003 - All Rights Reserved
*
* The original version of this source code and documentation is
* copyrighted and owned by IBM. These materials are provided
* under terms of a License Agreement between IBM and Sun.
* This technology is protected by multiple US and International
* patents. This notice and attribution to IBM may not be removed.
*/
/*
* file name: ubidiimp.h
* encoding: US-ASCII
* tab size: 8 (not used)
* indentation:4
*
* created on: 1999aug06
* created by: Markus W. Scherer
*/
#ifndef UBIDIIMP_H
#define UBIDIIMP_H
/* set import/export definitions */
#ifdef U_COMMON_IMPLEMENTATION
#include "utypes.h"
#include "uchardir.h"
/* miscellaneous definitions ---------------------------------------------- */
typedef uint8_t DirProp;
typedef uint32_t Flags;
/* Comparing the description of the BiDi algorithm with this implementation
is easier with the same names for the BiDi types in the code as there.
See UCharDirection in uchar.h .
*/
enum {
L= U_LEFT_TO_RIGHT,
R= U_RIGHT_TO_LEFT,
EN= U_EUROPEAN_NUMBER,
ES= U_EUROPEAN_NUMBER_SEPARATOR,
ET= U_EUROPEAN_NUMBER_TERMINATOR,
AN= U_ARABIC_NUMBER,
CS= U_COMMON_NUMBER_SEPARATOR,
B= U_BLOCK_SEPARATOR,
S= U_SEGMENT_SEPARATOR,
WS= U_WHITE_SPACE_NEUTRAL,
ON= U_OTHER_NEUTRAL,
LRE=U_LEFT_TO_RIGHT_EMBEDDING,
LRO=U_LEFT_TO_RIGHT_OVERRIDE,
AL= U_RIGHT_TO_LEFT_ARABIC,
RLE=U_RIGHT_TO_LEFT_EMBEDDING,
RLO=U_RIGHT_TO_LEFT_OVERRIDE,
PDF=U_POP_DIRECTIONAL_FORMAT,
NSM=U_DIR_NON_SPACING_MARK,
BN= U_BOUNDARY_NEUTRAL,
dirPropCount
};
/*
* Sometimes, bit values are more appropriate
* to deal with directionality properties.
* Abbreviations in these macro names refer to names
* used in the BiDi algorithm.
*/
#define DIRPROP_FLAG(dir) (1UL<<(dir))
/* special flag for multiple runs from explicit embedding codes */
#define DIRPROP_FLAG_MULTI_RUNS (1UL<<31)
/* are there any characters that are LTR or RTL? */
#define MASK_LTR (DIRPROP_FLAG(L)|DIRPROP_FLAG(EN)|DIRPROP_FLAG(AN)|DIRPROP_FLAG(LRE)|DIRPROP_FLAG(LRO))
#define MASK_RTL (DIRPROP_FLAG(R)|DIRPROP_FLAG(AL)|DIRPROP_FLAG(RLE)|DIRPROP_FLAG(RLO))
/* explicit embedding codes */
#define MASK_LRX (DIRPROP_FLAG(LRE)|DIRPROP_FLAG(LRO))
#define MASK_RLX (DIRPROP_FLAG(RLE)|DIRPROP_FLAG(RLO))
#define MASK_OVERRIDE (DIRPROP_FLAG(LRO)|DIRPROP_FLAG(RLO))
#define MASK_EXPLICIT (MASK_LRX|MASK_RLX|DIRPROP_FLAG(PDF))
#define MASK_BN_EXPLICIT (DIRPROP_FLAG(BN)|MASK_EXPLICIT)
/* paragraph and segment separators */
#define MASK_B_S (DIRPROP_FLAG(B)|DIRPROP_FLAG(S))
/* all types that are counted as White Space or Neutral in some steps */
#define MASK_WS (MASK_B_S|DIRPROP_FLAG(WS)|MASK_BN_EXPLICIT)
#define MASK_N (DIRPROP_FLAG(ON)|MASK_WS)
/* all types that are included in a sequence of European Terminators for (W5) */
#define MASK_ET_NSM_BN (DIRPROP_FLAG(ET)|DIRPROP_FLAG(NSM)|MASK_BN_EXPLICIT)
/* types that are neutrals or could becomes neutrals in (Wn) */
#define MASK_POSSIBLE_N (DIRPROP_FLAG(CS)|DIRPROP_FLAG(ES)|DIRPROP_FLAG(ET)|MASK_N)
/*
* These types may be changed to "e",
* the embedding type (L or R) of the run,
* in the BiDi algorithm (N2)
*/
#define MASK_EMBEDDING (DIRPROP_FLAG(NSM)|MASK_POSSIBLE_N)
/* the dirProp's L and R are defined to 0 and 1 values in UCharDirection */
#define GET_LR_FROM_LEVEL(level) ((DirProp)((level)&1))
#define IS_DEFAULT_LEVEL(level) (((level)&0xfe)==0xfe)
/* handle surrogate pairs --------------------------------------------------- */
/* Note: dlf added for java */
#define IS_FIRST_SURROGATE(uchar) (((uchar)&0xfc00)==0xd800)
#define IS_SECOND_SURROGATE(uchar) (((uchar)&0xfc00)==0xdc00)
/* get the UTF-32 value directly from the surrogate pseudo-characters */
#define SURROGATE_OFFSET ((0xd800<<10UL)+0xdc00-0x10000)
#define GET_UTF_32(first, second) (((first)<<10UL)+(second)-SURROGATE_OFFSET)
/* Run structure for reordering --------------------------------------------- */
typedef struct Run {
int32_t logicalStart, /* first character of the run; b31 indicates even/odd level */
visualLimit; /* last visual position of the run +1 */
} Run;
/* in a Run, logicalStart will get this bit set if the run level is odd */
#define INDEX_ODD_BIT (1UL<<31)
#define MAKE_INDEX_ODD_PAIR(index, level) (index|((uint32_t)level<<31))
#define ADD_ODD_BIT_FROM_LEVEL(x, level) ((x)|=((uint32_t)level<<31))
#define REMOVE_ODD_BIT(x) ((x)&=~INDEX_ODD_BIT)
#define GET_INDEX(x) (x&~INDEX_ODD_BIT)
#define GET_ODD_BIT(x) ((uint32_t)x>>31)
#define IS_ODD_RUN(x) ((x&INDEX_ODD_BIT)!=0)
#define IS_EVEN_RUN(x) ((x&INDEX_ODD_BIT)==0)
U_CFUNC bool_t
ubidi_getRuns(UBiDi *pBiDi);
/* UBiDi structure ----------------------------------------------------------- */
struct UBiDi {
/* alias pointer to the current text */
const UChar *text;
/* length of the current text */
int32_t length;
/* memory sizes in bytes */
int32_t dirPropsSize, levelsSize, runsSize;
/* allocated memory */
DirProp *dirPropsMemory;
UBiDiLevel *levelsMemory;
Run *runsMemory;
/* indicators for whether memory may be allocated after ubidi_open() */
bool_t mayAllocateText, mayAllocateRuns;
/* arrays with one value per text-character */
const DirProp *dirProps;
UBiDiLevel *levels;
/* are we performing an approximation of the "inverse BiDi" algorithm? */
bool_t isInverse;
/* the paragraph level */
UBiDiLevel paraLevel;
/* the overall paragraph or line directionality - see UBiDiDirection */
UBiDiDirection direction;
/* flags is a bit set for which directional properties are in the text */
Flags flags;
/* characters after trailingWSStart are WS and are */
/* implicitly at the paraLevel (rule (L1)) - levels may not reflect that */
int32_t trailingWSStart;
/* fields for line reordering */
int32_t runCount; /* ==-1: runs not set up yet */
Run *runs;
/* for non-mixed text, we only need a tiny array of runs (no malloc()) */
Run simpleRuns[1];
};
/* helper function to (re)allocate memory if allowed */
extern bool_t
ubidi_getMemory(void **pMemory, int32_t *pSize, bool_t mayAllocate, int32_t sizeNeeded);
/* helper macros for each allocated array in UBiDi */
#define getDirPropsMemory(pBiDi, length) \
ubidi_getMemory((void **)&(pBiDi)->dirPropsMemory, &(pBiDi)->dirPropsSize, \
(pBiDi)->mayAllocateText, (length))
#define getLevelsMemory(pBiDi, length) \
ubidi_getMemory((void **)&(pBiDi)->levelsMemory, &(pBiDi)->levelsSize, \
(pBiDi)->mayAllocateText, (length))
#define getRunsMemory(pBiDi, length) \
ubidi_getMemory((void **)&(pBiDi)->runsMemory, &(pBiDi)->runsSize, \
(pBiDi)->mayAllocateRuns, (length)*sizeof(Run))
/* additional macros used by ubidi_open() - always allow allocation */
#define getInitialDirPropsMemory(pBiDi, length) \
ubidi_getMemory((void **)&(pBiDi)->dirPropsMemory, &(pBiDi)->dirPropsSize, \
TRUE, (length))
#define getInitialLevelsMemory(pBiDi, length) \
ubidi_getMemory((void **)&(pBiDi)->levelsMemory, &(pBiDi)->levelsSize, \
TRUE, (length))
#define getInitialRunsMemory(pBiDi, length) \
ubidi_getMemory((void **)&(pBiDi)->runsMemory, &(pBiDi)->runsSize, \
TRUE, (length)*sizeof(Run))
#endif
#endif
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -36,7 +36,8 @@
#define LE_USE_CMEMORY
#ifdef LE_USE_CMEMORY
#include "cmemory.h"
#include <stdlib.h>
#include <string.h>
#endif
#ifndef _LP64
......
......@@ -337,7 +337,7 @@ getAllConfigs (JNIEnv *env, int screen, AwtScreenDataPtr screenDataPtr) {
char errmsg[128];
int xinawareScreen;
void* xrenderLibHandle = NULL;
XRenderFindVisualFormatFunc *XRenderFindVisualFormat = NULL;
XRenderFindVisualFormatFunc* xrenderFindVisualFormat = NULL;
int major_opcode, first_event, first_error;
if (usingXinerama) {
......@@ -435,7 +435,7 @@ getAllConfigs (JNIEnv *env, int screen, AwtScreenDataPtr screenDataPtr) {
#endif
if (xrenderLibHandle != NULL) {
XRenderFindVisualFormat =
xrenderFindVisualFormat =
(XRenderFindVisualFormatFunc*)dlsym(xrenderLibHandle,
"XRenderFindVisualFormat");
}
......@@ -454,8 +454,8 @@ getAllConfigs (JNIEnv *env, int screen, AwtScreenDataPtr screenDataPtr) {
graphicsConfigs [ind]->awt_depth = pVITrue [i].depth;
memcpy (&graphicsConfigs [ind]->awt_visInfo, &pVITrue [i],
sizeof (XVisualInfo));
if (XRenderFindVisualFormat != NULL) {
XRenderPictFormat *format = XRenderFindVisualFormat (awt_display,
if (xrenderFindVisualFormat != NULL) {
XRenderPictFormat *format = xrenderFindVisualFormat (awt_display,
pVITrue [i].visual);
if (format &&
format->type == PictTypeDirect &&
......
此差异已折叠。
......@@ -61,6 +61,14 @@ class AwtDropTarget;
typedef VOID (CALLBACK* IDLEPROC)(VOID);
typedef BOOL (CALLBACK* PEEKMESSAGEPROC)(MSG&);
// Struct for _WInputMethod_enable|disableNativeIME method
struct EnableNativeIMEStruct {
jobject self;
jobject peer;
jint context;
jboolean useNativeCompWindow;
};
/*
* class JNILocalFrame
* Push/PopLocalFrame helper
......
此差异已折叠。
此差异已折叠。
grant {
permission java.util.PropertyPermission "test.classes", "read";
permission java.util.PropertyPermission "java.io.tmpdir", "read";
permission java.io.FilePermission "${java.io.tmpdir}${/}*", "read, write";
};
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册