Merge
diff --git a/.hgtags b/.hgtags
index 0ace621..8930649 100644
--- a/.hgtags
+++ b/.hgtags
@@ -119,3 +119,4 @@
312612e89ece62633f4809706dec00bcd5fe7c2d jdk7-b142
efbf75c24b0f31847c9c403f6dc07dc80551908d jdk7-b143
23bdcede4e3945894574892e80b848bd9f15b5f3 jdk7-b144
+1e04b38b3824a4a1d197ef681a302e6813e53f8b jdk7-b145
diff --git a/src/share/classes/com/sun/java/swing/plaf/gtk/GTKFileChooserUI.java b/src/share/classes/com/sun/java/swing/plaf/gtk/GTKFileChooserUI.java
index ac12b20..0cff673 100644
--- a/src/share/classes/com/sun/java/swing/plaf/gtk/GTKFileChooserUI.java
+++ b/src/share/classes/com/sun/java/swing/plaf/gtk/GTKFileChooserUI.java
@@ -174,8 +174,11 @@
// construct the resulting string
for (int i=0; i<len; i++) {
+ if (i > 0) {
+ buf.append(" ");
+ }
if (len > 1) {
- buf.append(" \"");
+ buf.append("\"");
}
buf.append(result.get(i));
if (len > 1) {
diff --git a/src/share/classes/java/awt/color/ICC_Profile.java b/src/share/classes/java/awt/color/ICC_Profile.java
index 8bfe98e..81212fb 100644
--- a/src/share/classes/java/awt/color/ICC_Profile.java
+++ b/src/share/classes/java/awt/color/ICC_Profile.java
@@ -1382,13 +1382,19 @@
/**
* Sets a particular tagged data element in the profile from
- * a byte array. This method is useful
- * for advanced applets or applications which need to access
- * profile data directly.
+ * a byte array. The array should contain data in a format, corresponded
+ * to the {@code tagSignature} as defined in the ICC specification, section 10.
+ * This method is useful for advanced applets or applications which need to
+ * access profile data directly.
*
* @param tagSignature The ICC tag signature for the data element
* you want to set.
* @param tagData the data to set for the specified tag signature
+ * @throws IllegalArgumentException if {@code tagSignature} is not a signature
+ * as defined in the ICC specification.
+ * @throws IllegalArgumentException if a content of the {@code tagData}
+ * array can not be interpreted as valid tag data, corresponding
+ * to the {@code tagSignature}.
* @see #getData
*/
public void setData(int tagSignature, byte[] tagData) {
diff --git a/src/share/classes/java/lang/invoke/MethodHandleImpl.java b/src/share/classes/java/lang/invoke/MethodHandleImpl.java
index 06811fe..5437e85 100644
--- a/src/share/classes/java/lang/invoke/MethodHandleImpl.java
+++ b/src/share/classes/java/lang/invoke/MethodHandleImpl.java
@@ -26,6 +26,8 @@
package java.lang.invoke;
import sun.invoke.util.VerifyType;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -336,18 +338,20 @@
void setFieldL(C obj, V x) { unsafe.putObject(obj, offset, x); }
// cast (V) is OK here, since we wrap convertArguments around the MH.
- static Object staticBase(MemberName field) {
+ static Object staticBase(final MemberName field) {
if (!field.isStatic()) return null;
- Class c = field.getDeclaringClass();
- java.lang.reflect.Field f;
- try {
- // FIXME: Should not have to create 'f' to get this value.
- f = c.getDeclaredField(field.getName());
- // Note: Previous line might invalidly throw SecurityException (7042829)
- return unsafe.staticFieldBase(f);
- } catch (NoSuchFieldException ee) {
- throw uncaughtException(ee);
- }
+ return AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ try {
+ Class c = field.getDeclaringClass();
+ // FIXME: Should not have to create 'f' to get this value.
+ java.lang.reflect.Field f = c.getDeclaredField(field.getName());
+ return unsafe.staticFieldBase(f);
+ } catch (NoSuchFieldException ee) {
+ throw uncaughtException(ee);
+ }
+ }
+ });
}
int getStaticI() { return unsafe.getInt(base, offset); }
diff --git a/src/share/classes/java/lang/invoke/MethodHandleNatives.java b/src/share/classes/java/lang/invoke/MethodHandleNatives.java
index daf6422..ef3df63 100644
--- a/src/share/classes/java/lang/invoke/MethodHandleNatives.java
+++ b/src/share/classes/java/lang/invoke/MethodHandleNatives.java
@@ -359,6 +359,12 @@
required = Object[].class; // should have been an array
code = 192; // checkcast
break;
+ case 191: // athrow
+ // JVM is asking us to wrap an exception which happened during resolving
+ if (required == BootstrapMethodError.class) {
+ throw new BootstrapMethodError((Throwable) actual);
+ }
+ break;
}
// disregard the identity of the actual object, if it is not a class:
if (message == null) {
@@ -389,18 +395,7 @@
Class<?> defc, String name, Object type) {
try {
Lookup lookup = IMPL_LOOKUP.in(callerClass);
- switch (refKind) {
- case REF_getField: return lookup.findGetter( defc, name, (Class<?>) type );
- case REF_getStatic: return lookup.findStaticGetter( defc, name, (Class<?>) type );
- case REF_putField: return lookup.findSetter( defc, name, (Class<?>) type );
- case REF_putStatic: return lookup.findStaticSetter( defc, name, (Class<?>) type );
- case REF_invokeVirtual: return lookup.findVirtual( defc, name, (MethodType) type );
- case REF_invokeStatic: return lookup.findStatic( defc, name, (MethodType) type );
- case REF_invokeSpecial: return lookup.findSpecial( defc, name, (MethodType) type, callerClass );
- case REF_newInvokeSpecial: return lookup.findConstructor( defc, (MethodType) type );
- case REF_invokeInterface: return lookup.findVirtual( defc, name, (MethodType) type );
- }
- throw new InternalError("bad MethodHandle constant "+name+" : "+type);
+ return lookup.linkMethodHandleConstant(refKind, defc, name, type);
} catch (ReflectiveOperationException ex) {
Error err = new IncompatibleClassChangeError();
err.initCause(ex);
diff --git a/src/share/classes/java/lang/invoke/MethodHandleStatics.java b/src/share/classes/java/lang/invoke/MethodHandleStatics.java
index 61c4427..e812d24 100644
--- a/src/share/classes/java/lang/invoke/MethodHandleStatics.java
+++ b/src/share/classes/java/lang/invoke/MethodHandleStatics.java
@@ -25,6 +25,9 @@
package java.lang.invoke;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
/**
* This class consists exclusively of static names internal to the
* method handle implementation.
@@ -35,7 +38,17 @@
private MethodHandleStatics() { } // do not instantiate
- static final boolean DEBUG_METHOD_HANDLE_NAMES = Boolean.getBoolean("java.lang.invoke.MethodHandle.DEBUG_NAMES");
+ static final boolean DEBUG_METHOD_HANDLE_NAMES;
+ static {
+ final Object[] values = { false };
+ AccessController.doPrivileged(new PrivilegedAction<Void>() {
+ public Void run() {
+ values[0] = Boolean.getBoolean("java.lang.invoke.MethodHandle.DEBUG_NAMES");
+ return null;
+ }
+ });
+ DEBUG_METHOD_HANDLE_NAMES = (Boolean) values[0];
+ }
/*non-public*/ static String getNameString(MethodHandle target, MethodType type) {
if (type == null)
diff --git a/src/share/classes/java/lang/invoke/MethodHandles.java b/src/share/classes/java/lang/invoke/MethodHandles.java
index 42de213..9e18b4b 100644
--- a/src/share/classes/java/lang/invoke/MethodHandles.java
+++ b/src/share/classes/java/lang/invoke/MethodHandles.java
@@ -35,6 +35,7 @@
import java.util.Arrays;
import sun.reflect.Reflection;
import static java.lang.invoke.MethodHandleStatics.*;
+import static java.lang.invoke.MethodHandleNatives.Constants.*;
/**
* This class consists exclusively of static methods that operate on or return
@@ -579,9 +580,18 @@
MethodHandle findStatic(Class<?> refc, String name, MethodType type) throws NoSuchMethodException, IllegalAccessException {
MemberName method = resolveOrFail(refc, name, type, true);
checkSecurityManager(refc, method); // stack walk magic: do not refactor
+ return accessStatic(refc, method);
+ }
+ private
+ MethodHandle accessStatic(Class<?> refc, MemberName method) throws IllegalAccessException {
checkMethod(refc, method, true);
return MethodHandleImpl.findMethod(method, false, lookupClassOrNull());
}
+ private
+ MethodHandle resolveStatic(Class<?> refc, String name, MethodType type) throws NoSuchMethodException, IllegalAccessException {
+ MemberName method = resolveOrFail(refc, name, type, true);
+ return accessStatic(refc, method);
+ }
/**
* Produces a method handle for a virtual method.
@@ -624,6 +634,13 @@
public MethodHandle findVirtual(Class<?> refc, String name, MethodType type) throws NoSuchMethodException, IllegalAccessException {
MemberName method = resolveOrFail(refc, name, type, false);
checkSecurityManager(refc, method); // stack walk magic: do not refactor
+ return accessVirtual(refc, method);
+ }
+ private MethodHandle resolveVirtual(Class<?> refc, String name, MethodType type) throws NoSuchMethodException, IllegalAccessException {
+ MemberName method = resolveOrFail(refc, name, type, false);
+ return accessVirtual(refc, method);
+ }
+ private MethodHandle accessVirtual(Class<?> refc, MemberName method) throws IllegalAccessException {
checkMethod(refc, method, false);
MethodHandle mh = MethodHandleImpl.findMethod(method, true, lookupClassOrNull());
return restrictProtectedReceiver(method, mh);
@@ -658,13 +675,21 @@
public MethodHandle findConstructor(Class<?> refc, MethodType type) throws NoSuchMethodException, IllegalAccessException {
String name = "<init>";
MemberName ctor = resolveOrFail(refc, name, type, false, false, lookupClassOrNull());
- assert(ctor.isConstructor());
checkSecurityManager(refc, ctor); // stack walk magic: do not refactor
+ return accessConstructor(refc, ctor);
+ }
+ private MethodHandle accessConstructor(Class<?> refc, MemberName ctor) throws IllegalAccessException {
+ assert(ctor.isConstructor());
checkAccess(refc, ctor);
MethodHandle rawMH = MethodHandleImpl.findMethod(ctor, false, lookupClassOrNull());
MethodHandle allocMH = MethodHandleImpl.makeAllocator(rawMH);
return fixVarargs(allocMH, rawMH);
}
+ private MethodHandle resolveConstructor(Class<?> refc, MethodType type) throws NoSuchMethodException, IllegalAccessException {
+ String name = "<init>";
+ MemberName ctor = resolveOrFail(refc, name, type, false, false, lookupClassOrNull());
+ return accessConstructor(refc, ctor);
+ }
/** Return a version of MH which matches matchMH w.r.t. isVarargsCollector. */
private static MethodHandle fixVarargs(MethodHandle mh, MethodHandle matchMH) {
@@ -720,10 +745,20 @@
checkSpecialCaller(specialCaller);
MemberName method = resolveOrFail(refc, name, type, false, false, specialCaller);
checkSecurityManager(refc, method); // stack walk magic: do not refactor
+ return accessSpecial(refc, method, specialCaller);
+ }
+ private MethodHandle accessSpecial(Class<?> refc, MemberName method,
+ Class<?> specialCaller) throws NoSuchMethodException, IllegalAccessException {
checkMethod(refc, method, false);
MethodHandle mh = MethodHandleImpl.findMethod(method, false, specialCaller);
return restrictReceiver(method, mh, specialCaller);
}
+ private MethodHandle resolveSpecial(Class<?> refc, String name, MethodType type) throws NoSuchMethodException, IllegalAccessException {
+ Class<?> specialCaller = lookupClass();
+ checkSpecialCaller(specialCaller);
+ MemberName method = resolveOrFail(refc, name, type, false, false, specialCaller);
+ return accessSpecial(refc, method, specialCaller);
+ }
/**
* Produces a method handle giving read access to a non-static field.
@@ -747,6 +782,10 @@
checkSecurityManager(refc, field); // stack walk magic: do not refactor
return makeAccessor(refc, field, false, false, 0);
}
+ private MethodHandle resolveGetter(Class<?> refc, String name, Class<?> type) throws NoSuchFieldException, IllegalAccessException {
+ MemberName field = resolveOrFail(refc, name, type, false);
+ return makeAccessor(refc, field, false, false, 0);
+ }
/**
* Produces a method handle giving write access to a non-static field.
@@ -770,6 +809,10 @@
checkSecurityManager(refc, field); // stack walk magic: do not refactor
return makeAccessor(refc, field, false, true, 0);
}
+ private MethodHandle resolveSetter(Class<?> refc, String name, Class<?> type) throws NoSuchFieldException, IllegalAccessException {
+ MemberName field = resolveOrFail(refc, name, type, false);
+ return makeAccessor(refc, field, false, true, 0);
+ }
/**
* Produces a method handle giving read access to a static field.
@@ -792,6 +835,10 @@
checkSecurityManager(refc, field); // stack walk magic: do not refactor
return makeAccessor(refc, field, false, false, 1);
}
+ private MethodHandle resolveStaticGetter(Class<?> refc, String name, Class<?> type) throws NoSuchFieldException, IllegalAccessException {
+ MemberName field = resolveOrFail(refc, name, type, true);
+ return makeAccessor(refc, field, false, false, 1);
+ }
/**
* Produces a method handle giving write access to a static field.
@@ -814,6 +861,10 @@
checkSecurityManager(refc, field); // stack walk magic: do not refactor
return makeAccessor(refc, field, false, true, 1);
}
+ private MethodHandle resolveStaticSetter(Class<?> refc, String name, Class<?> type) throws NoSuchFieldException, IllegalAccessException {
+ MemberName field = resolveOrFail(refc, name, type, true);
+ return makeAccessor(refc, field, false, true, 1);
+ }
/**
* Produces an early-bound method handle for a non-static method.
@@ -1179,6 +1230,25 @@
MethodHandle mh = MethodHandleImpl.accessField(field, isSetter, lookupClassOrNull());
return restrictProtectedReceiver(field, mh);
}
+
+ /** Hook called from the JVM (via MethodHandleNatives) to link MH constants:
+ */
+ /*non-public*/
+ MethodHandle linkMethodHandleConstant(int refKind, Class<?> defc, String name, Object type) throws ReflectiveOperationException {
+ switch (refKind) {
+ case REF_getField: return resolveGetter( defc, name, (Class<?>) type );
+ case REF_getStatic: return resolveStaticGetter( defc, name, (Class<?>) type );
+ case REF_putField: return resolveSetter( defc, name, (Class<?>) type );
+ case REF_putStatic: return resolveStaticSetter( defc, name, (Class<?>) type );
+ case REF_invokeVirtual: return resolveVirtual( defc, name, (MethodType) type );
+ case REF_invokeStatic: return resolveStatic( defc, name, (MethodType) type );
+ case REF_invokeSpecial: return resolveSpecial( defc, name, (MethodType) type );
+ case REF_newInvokeSpecial: return resolveConstructor( defc, (MethodType) type );
+ case REF_invokeInterface: return resolveVirtual( defc, name, (MethodType) type );
+ }
+ // oops
+ throw new ReflectiveOperationException("bad MethodHandle constant #"+refKind+" "+name+" : "+type);
+ }
}
/**
diff --git a/src/share/classes/java/lang/invoke/SwitchPoint.java b/src/share/classes/java/lang/invoke/SwitchPoint.java
index 11d8018..7469e40 100644
--- a/src/share/classes/java/lang/invoke/SwitchPoint.java
+++ b/src/share/classes/java/lang/invoke/SwitchPoint.java
@@ -59,14 +59,14 @@
MethodHandle MH_strcat = MethodHandles.lookup()
.findVirtual(String.class, "concat", MethodType.methodType(String.class, String.class));
SwitchPoint spt = new SwitchPoint();
-assert(spt.isValid());
+assert(!spt.hasBeenInvalidated());
// the following steps may be repeated to re-use the same switch point:
MethodHandle worker1 = MH_strcat;
MethodHandle worker2 = MethodHandles.permuteArguments(MH_strcat, MH_strcat.type(), 1, 0);
MethodHandle worker = spt.guardWithTest(worker1, worker2);
assertEquals("method", (String) worker.invokeExact("met", "hod"));
SwitchPoint.invalidateAll(new SwitchPoint[]{ spt });
-assert(!spt.isValid());
+assert(spt.hasBeenInvalidated());
assertEquals("hodmet", (String) worker.invokeExact("met", "hod"));
* </pre></blockquote>
* <p style="font-size:smaller;">
@@ -126,16 +126,30 @@
}
/**
- * Determines if this switch point is still valid.
- * <p>
+ * Determines if this switch point has been invalidated yet.
+ *
+ * <p style="font-size:smaller;">
+ * <em>Discussion:</em>
+ * Because of the one-way nature of invalidation, once a switch point begins
+ * to return true for {@code hasBeenInvalidated},
+ * it will always do so in the future.
+ * On the other hand, a valid switch point visible to other threads may
+ * invalidated at any moment, due to a request by another thread.
+ * <p style="font-size:smaller;">
* Since invalidation is a global and immediate operation,
- * this query must be sequenced with any
- * other threads that could invalidate this switch point.
- * It may therefore be expensive.
- * @return true if this switch point has never been invalidated
+ * the execution of this query, on a valid switchpoint,
+ * must be internally sequenced with any
+ * other threads that could cause invalidation.
+ * This query may therefore be expensive.
+ * The recommended way to build a boolean-valued method handle
+ * which queries the invalidation state of a switch point {@code s} is
+ * to call {@code s.guardWithTest} on
+ * {@link MethodHandles#constant constant} true and false method handles.
+ *
+ * @return true if this switch point has been invalidated
*/
- public boolean isValid() {
- return (mcs.getTarget() == K_true);
+ public boolean hasBeenInvalidated() {
+ return (mcs.getTarget() != K_true);
}
/**
diff --git a/src/share/classes/java/nio/file/Path.java b/src/share/classes/java/nio/file/Path.java
index 370c38d..6e57268 100644
--- a/src/share/classes/java/nio/file/Path.java
+++ b/src/share/classes/java/nio/file/Path.java
@@ -460,15 +460,13 @@
/**
* Returns a URI to represent this path.
*
- * <p> This method constructs a hierarchical {@link URI} that is absolute
- * with a non-empty path component. Its {@link URI#getScheme() scheme} is
- * equal to the URI scheme that identifies the provider. The exact form of
- * the other URI components is highly provider dependent. In particular, it
- * is implementation dependent if its query, fragment, and authority
- * components are defined or undefined.
+ * <p> This method constructs an absolute {@link URI} with a {@link
+ * URI#getScheme() scheme} equal to the URI scheme that identifies the
+ * provider. The exact form of the scheme specific part is highly provider
+ * dependent.
*
- * <p> For the default provider the {@link URI#getPath() path} component
- * will represent the {@link #toAbsolutePath absolute} path; the query,
+ * <p> In the case of the default provider, the URI is hierarchical with
+ * a {@link URI#getPath() path} component that is absolute. The query and
* fragment components are undefined. Whether the authority component is
* defined or not is implementation dependent. There is no guarantee that
* the {@code URI} may be used to construct a {@link java.io.File java.io.File}.
@@ -497,7 +495,7 @@
* A format for compound URIs is not defined in this release; such a scheme
* may be added in a future release.
*
- * @return an absolute, hierarchical URI with a non-empty path component
+ * @return the URI representing this path
*
* @throws java.io.IOError
* if an I/O error occurs obtaining the absolute path, or where a
diff --git a/src/share/classes/sun/invoke/util/ValueConversions.java b/src/share/classes/sun/invoke/util/ValueConversions.java
index f3e2f85..9179785 100644
--- a/src/share/classes/sun/invoke/util/ValueConversions.java
+++ b/src/share/classes/sun/invoke/util/ValueConversions.java
@@ -29,6 +29,8 @@
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodHandles.Lookup;
import java.lang.invoke.MethodType;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -38,7 +40,17 @@
public class ValueConversions {
private static final Class<?> THIS_CLASS = ValueConversions.class;
// Do not adjust this except for special platforms:
- private static final int MAX_ARITY = Integer.getInteger(THIS_CLASS.getName()+".MAX_ARITY", 255);
+ private static final int MAX_ARITY;
+ static {
+ final Object[] values = { 255 };
+ AccessController.doPrivileged(new PrivilegedAction<Void>() {
+ public Void run() {
+ values[0] = Integer.getInteger(THIS_CLASS.getName()+".MAX_ARITY", 255);
+ return null;
+ }
+ });
+ MAX_ARITY = (Integer) values[0];
+ }
private static final Lookup IMPL_LOOKUP = MethodHandles.lookup();
diff --git a/src/share/native/sun/java2d/cmm/lcms/LCMS.c b/src/share/native/sun/java2d/cmm/lcms/LCMS.c
index 8ac40e4..1195f7c 100644
--- a/src/share/native/sun/java2d/cmm/lcms/LCMS.c
+++ b/src/share/native/sun/java2d/cmm/lcms/LCMS.c
@@ -233,9 +233,19 @@
jint dataSize;
storeID_t sProf;
+ if (JNU_IsNull(env, data)) {
+ JNU_ThrowIllegalArgumentException(env, "Invalid profile data");
+ return 0L;
+ }
+
dataArray = (*env)->GetByteArrayElements (env, data, 0);
dataSize = (*env)->GetArrayLength (env, data);
+ if (dataArray == NULL) {
+ JNU_ThrowIllegalArgumentException(env, "Invalid profile data");
+ return 0L;
+ }
+
sProf.pf = cmsOpenProfileFromMem((const void *)dataArray,
(cmsUInt32Number) dataSize);
@@ -334,8 +344,9 @@
}
/* Get profile header info */
-cmsBool _getHeaderInfo(cmsHPROFILE pf, jbyte* pBuffer, jint bufferSize);
-cmsBool _setHeaderInfo(cmsHPROFILE pf, jbyte* pBuffer, jint bufferSize);
+static cmsBool _getHeaderInfo(cmsHPROFILE pf, jbyte* pBuffer, jint bufferSize);
+static cmsBool _setHeaderInfo(cmsHPROFILE pf, jbyte* pBuffer, jint bufferSize);
+static cmsBool _writeCookedTag(cmsHPROFILE pfTarget, cmsTagSignature sig, jbyte *pData, jint size);
/*
* Class: sun_java2d_cmm_lcms_LCMS
@@ -356,7 +367,7 @@
result = sizeof(cmsICCHeader);
} else {
if (cmsIsTag(sProf.pf, sig.cms)) {
- result = cmsReadRawTag(sProf.pf, sig.cms, NULL, 0);
+ result = cmsReadRawTag(sProf.pf, sig.cms, NULL, 0);
} else {
JNU_ThrowByName(env, "java/awt/color/CMMException",
"ICC profile tag not found");
@@ -468,22 +479,30 @@
sProf.j = id;
sig.j = tagSig;
+ if (JNU_IsNull(env, data)) {
+ JNU_ThrowIllegalArgumentException(env, "Can not write tag data.");
+ return;
+ }
tagSize =(*env)->GetArrayLength(env, data);
dataArray = (*env)->GetByteArrayElements(env, data, 0);
+ if (dataArray == NULL) {
+ JNU_ThrowIllegalArgumentException(env, "Can not write tag data.");
+ return;
+ }
+
if (tagSig == SigHead) {
status = _setHeaderInfo(sProf.pf, dataArray, tagSize);
} else {
- status = cmsWriteRawTag(sProf.pf, sig.cms, dataArray, tagSize);
+ status = _writeCookedTag(sProf.pf, sig.cms, dataArray, tagSize);
}
(*env)->ReleaseByteArrayElements(env, data, dataArray, 0);
if (!status) {
- JNU_ThrowByName(env, "java/awt/color/CMMException",
- "Can not write tag data.");
+ JNU_ThrowIllegalArgumentException(env, "Can not write tag data.");
}
}
@@ -645,7 +664,7 @@
PF_ID_fID = (*env)->GetFieldID (env, Pf, "ID", "J");
}
-cmsBool _getHeaderInfo(cmsHPROFILE pf, jbyte* pBuffer, jint bufferSize)
+static cmsBool _getHeaderInfo(cmsHPROFILE pf, jbyte* pBuffer, jint bufferSize)
{
cmsUInt32Number pfSize = 0;
cmsUInt8Number* pfBuffer = NULL;
@@ -672,7 +691,7 @@
return status;
}
-cmsBool _setHeaderInfo(cmsHPROFILE pf, jbyte* pBuffer, jint bufferSize)
+static cmsBool _setHeaderInfo(cmsHPROFILE pf, jbyte* pBuffer, jint bufferSize)
{
cmsICCHeader pfHeader = { 0 };
@@ -696,3 +715,77 @@
return TRUE;
}
+
+static cmsBool _writeCookedTag(cmsHPROFILE pfTarget,
+ cmsTagSignature sig,
+ jbyte *pData, jint size)
+{
+ cmsBool status;
+ cmsUInt32Number pfSize = 0;
+ cmsUInt8Number* pfBuffer = NULL;
+
+ cmsHPROFILE p = cmsCreateProfilePlaceholder(NULL);
+ if (NULL != p) {
+ cmsICCHeader hdr = { 0 };
+
+ /* Populate the placeholder's header according to target profile */
+ hdr.flags = cmsGetHeaderFlags(pfTarget);
+ hdr.renderingIntent = cmsGetHeaderRenderingIntent(pfTarget);
+ hdr.manufacturer = cmsGetHeaderManufacturer(pfTarget);
+ hdr.model = cmsGetHeaderModel(pfTarget);
+ hdr.pcs = cmsGetPCS(pfTarget);
+ hdr.colorSpace = cmsGetColorSpace(pfTarget);
+ hdr.deviceClass = cmsGetDeviceClass(pfTarget);
+ hdr.version = cmsGetEncodedICCversion(pfTarget);
+ cmsGetHeaderAttributes(pfTarget, &hdr.attributes);
+ cmsGetHeaderProfileID(pfTarget, (cmsUInt8Number*)&hdr.profileID);
+
+ cmsSetHeaderFlags(p, hdr.flags);
+ cmsSetHeaderManufacturer(p, hdr.manufacturer);
+ cmsSetHeaderModel(p, hdr.model);
+ cmsSetHeaderAttributes(p, hdr.attributes);
+ cmsSetHeaderProfileID(p, (cmsUInt8Number*)&(hdr.profileID));
+ cmsSetHeaderRenderingIntent(p, hdr.renderingIntent);
+ cmsSetPCS(p, hdr.pcs);
+ cmsSetColorSpace(p, hdr.colorSpace);
+ cmsSetDeviceClass(p, hdr.deviceClass);
+ cmsSetEncodedICCversion(p, hdr.version);
+
+
+ if (cmsWriteRawTag(p, sig, pData, size)) {
+ if (cmsSaveProfileToMem(p, NULL, &pfSize)) {
+ pfBuffer = malloc(pfSize);
+ if (pfBuffer != NULL) {
+ /* load raw profile data into the buffer */
+ if (!cmsSaveProfileToMem(p, pfBuffer, &pfSize)) {
+ free(pfBuffer);
+ pfBuffer = NULL;
+ }
+ }
+ }
+ }
+ cmsCloseProfile(p);
+ }
+
+ if (pfBuffer == NULL) {
+ return FALSE;
+ }
+
+ /* re-open the placeholder profile */
+ p = cmsOpenProfileFromMem(pfBuffer, pfSize);
+ free(pfBuffer);
+ status = FALSE;
+
+ if (p != NULL) {
+ /* Note that pCookedTag points to internal structures of the placeholder,
+ * so this data is valid only while the placeholder is open.
+ */
+ void *pCookedTag = cmsReadTag(p, sig);
+ if (pCookedTag != NULL) {
+ status = cmsWriteTag(pfTarget, sig, pCookedTag);
+ }
+ pCookedTag = NULL;
+ cmsCloseProfile(p);
+ }
+ return status;
+}
diff --git a/src/share/native/sun/java2d/cmm/lcms/cmsio0.c b/src/share/native/sun/java2d/cmm/lcms/cmsio0.c
index 8b7fb66..257a964 100644
--- a/src/share/native/sun/java2d/cmm/lcms/cmsio0.c
+++ b/src/share/native/sun/java2d/cmm/lcms/cmsio0.c
@@ -1636,6 +1636,11 @@
TagDescriptor = _cmsGetTagDescriptor(sig);
// Serialize
+ if (!_cmsWriteTypeBase(MemIO, TypeHandler ->Signature)) {
+ cmsCloseIOhandler(MemIO);
+ return 0;
+ }
+
if (!TypeHandler ->WritePtr(TypeHandler, MemIO, Object, TagDescriptor ->ElemCount)) return 0;
// Get Size and close
diff --git a/test/java/lang/invoke/InvokeDynamicPrintArgs.java b/test/java/lang/invoke/InvokeDynamicPrintArgs.java
index 9c3db42..89d2fdb 100644
--- a/test/java/lang/invoke/InvokeDynamicPrintArgs.java
+++ b/test/java/lang/invoke/InvokeDynamicPrintArgs.java
@@ -30,6 +30,10 @@
* --verify-specifier-count=3
* --expand-properties --classpath ${test.classes}
* --java test.java.lang.invoke.InvokeDynamicPrintArgs --check-output
+ * @run main/othervm
+ * indify.Indify
+ * --expand-properties --classpath ${test.classes}
+ * --java test.java.lang.invoke.InvokeDynamicPrintArgs --security-manager
*/
package test.java.lang.invoke;
@@ -45,7 +49,8 @@
public class InvokeDynamicPrintArgs {
public static void main(String... av) throws Throwable {
- if (av.length > 0) openBuf(); // --check-output mode
+ if (av.length > 0 && av[0].equals("--check-output")) openBuf();
+ if (av.length > 0 && av[0].equals("--security-manager")) setSM();
System.out.println("Printing some argument lists, starting with a empty one:");
INDY_nothing().invokeExact(); // BSM specifier #0 = {bsm}
INDY_bar().invokeExact("bar arg", 1); // BSM specifier #1 = {bsm2, Void.class, "void type"}
@@ -55,6 +60,43 @@
// Hence, BSM specifier count should be 3. See "--verify-specifier-count=3" above.
System.out.println("Done printing argument lists.");
closeBuf();
+ checkConstantRefs();
+ }
+
+ private static void checkConstantRefs() throws Throwable {
+ // check some constant references:
+ assertEquals(MT_bsm(), MH_bsm().type());
+ assertEquals(MT_bsm2(), MH_bsm2().type());
+ try {
+ assertEquals(MT_bsm(), non_MH_bsm().type());
+ // if SM is installed, must throw before this point
+ assertEquals(false, System.getSecurityManager() != null);
+ } catch (SecurityException ex) {
+ // if SM is installed, must throw to this point
+ assertEquals(true, System.getSecurityManager() != null);
+ }
+ }
+ private static void assertEquals(Object exp, Object act) {
+ if (exp == act || (exp != null && exp.equals(act))) return;
+ throw new AssertionError("not equal: "+exp+", "+act);
+ }
+
+ private static void setSM() {
+ // Test for severe security manager interactions (7050328).
+ class SM extends SecurityManager {
+ public void checkPackageAccess(String pkg) {
+ if (pkg.startsWith("test."))
+ throw new SecurityException("checkPackageAccess "+pkg);
+ }
+ public void checkMemberAccess(Class<?> clazz, int which) {
+ if (clazz == InvokeDynamicPrintArgs.class)
+ throw new SecurityException("checkMemberAccess "+clazz.getName()+" #"+which);
+ }
+ // allow these others:
+ public void checkPermission(java.security.Permission perm) {
+ }
+ }
+ System.setSecurityManager(new SM());
}
@Test
@@ -130,6 +172,9 @@
shouldNotCallThis();
return lookup().findStatic(lookup().lookupClass(), "bsm", MT_bsm());
}
+ private static MethodHandle non_MH_bsm() throws ReflectiveOperationException {
+ return lookup().findStatic(lookup().lookupClass(), "bsm", MT_bsm());
+ }
/* Example of a constant call site with user-data.
* In this case, the user data is exactly the BSM data.
diff --git a/test/java/lang/invoke/JavaDocExamplesTest.java b/test/java/lang/invoke/JavaDocExamplesTest.java
index 0e373c1..ba1eed5 100644
--- a/test/java/lang/invoke/JavaDocExamplesTest.java
+++ b/test/java/lang/invoke/JavaDocExamplesTest.java
@@ -477,14 +477,14 @@
MethodHandle MH_strcat = MethodHandles.lookup()
.findVirtual(String.class, "concat", MethodType.methodType(String.class, String.class));
SwitchPoint spt = new SwitchPoint();
-assert(spt.isValid());
+assert(!spt.hasBeenInvalidated());
// the following steps may be repeated to re-use the same switch point:
MethodHandle worker1 = MH_strcat;
MethodHandle worker2 = MethodHandles.permuteArguments(MH_strcat, MH_strcat.type(), 1, 0);
MethodHandle worker = spt.guardWithTest(worker1, worker2);
assertEquals("method", (String) worker.invokeExact("met", "hod"));
SwitchPoint.invalidateAll(new SwitchPoint[]{ spt });
-assert(!spt.isValid());
+assert(spt.hasBeenInvalidated());
assertEquals("hodmet", (String) worker.invokeExact("met", "hod"));
{}
}}
diff --git a/test/java/lang/invoke/RicochetTest.java b/test/java/lang/invoke/RicochetTest.java
index 310b576..1ac7290 100644
--- a/test/java/lang/invoke/RicochetTest.java
+++ b/test/java/lang/invoke/RicochetTest.java
@@ -25,6 +25,10 @@
/* @test
* @summary unit tests for recursive method handles
+ * @run junit/othervm -DRicochetTest.MAX_ARITY=50 test.java.lang.invoke.RicochetTest
+ */
+/*
+ * @ignore The following test creates an unreasonable number of adapters in -Xcomp mode (7049122)
* @run junit/othervm -DRicochetTest.MAX_ARITY=255 test.java.lang.invoke.RicochetTest
*/
diff --git a/test/java/security/Policy/GetPermissions/JarURL.java b/test/java/security/Policy/GetPermissions/JarURL.java
index d81c044..1d68225 100644
--- a/test/java/security/Policy/GetPermissions/JarURL.java
+++ b/test/java/security/Policy/GetPermissions/JarURL.java
@@ -23,11 +23,13 @@
/*
* @test
- * @bug 7044443
+ * @bug 7044443 7050329
+ * @run main/othervm/policy=JarURL.policy JarURL
* @summary Permissions resolved incorrectly for jar protocol
*/
import java.net.URL;
+import java.io.File;
import java.security.AllPermission;
import java.security.CodeSource;
import java.security.PermissionCollection;
@@ -35,11 +37,11 @@
import java.security.cert.Certificate;
public class JarURL {
+
public static void main(String[] args) throws Exception {
- URL codeSourceURL
- = new URL("jar:file:"
- + System.getProperty("java.ext.dirs").split(":")[0]
- + "/foo.jar!/");
+ String userDir = System.getProperty("user.dir");
+ String jarURL = "jar:file:" + userDir + File.separator + "foo.jar!/";
+ URL codeSourceURL = new URL(jarURL);
CodeSource cs = new CodeSource(codeSourceURL, new Certificate[0]);
PermissionCollection perms = Policy.getPolicy().getPermissions(cs);
if (!perms.implies(new AllPermission()))
diff --git a/test/java/security/Policy/GetPermissions/JarURL.policy b/test/java/security/Policy/GetPermissions/JarURL.policy
new file mode 100644
index 0000000..f568b91
--- /dev/null
+++ b/test/java/security/Policy/GetPermissions/JarURL.policy
@@ -0,0 +1,8 @@
+grant codeBase "file:${user.dir}/*" {
+ permission java.security.AllPermission;
+};
+
+grant {
+ permission java.util.PropertyPermission "user.dir", "read";
+ permission java.security.SecurityPermission "getPolicy";
+};
diff --git a/test/sun/java2d/cmm/ProfileOp/ReadWriteProfileTest.java b/test/sun/java2d/cmm/ProfileOp/ReadWriteProfileTest.java
index 19d113a..bc14128 100644
--- a/test/sun/java2d/cmm/ProfileOp/ReadWriteProfileTest.java
+++ b/test/sun/java2d/cmm/ProfileOp/ReadWriteProfileTest.java
@@ -23,7 +23,7 @@
/**
* @test
- * @bug 6476665 6523403 6733501
+ * @bug 6476665 6523403 6733501 7042594
* @summary Verifies reading and writing profiles and tags of the standard color
* spaces
* @run main ReadWriteProfileTest
@@ -94,7 +94,16 @@
for (int tagSig : tags[i].keySet()) {
byte [] tagData = pf.getData(tagSig);
byte [] empty = new byte[tagData.length];
- pf.setData(tagSig, empty);
+ boolean emptyDataRejected = false;
+ try {
+ pf.setData(tagSig, empty);
+ } catch (IllegalArgumentException e) {
+ emptyDataRejected = true;
+ }
+ if (!emptyDataRejected) {
+ throw new
+ RuntimeException("Test failed: empty tag data was not rejected.");
+ }
pf.setData(tagSig, tagData);
byte [] tagData1 = pf.getData(tagSig);
diff --git a/test/sun/java2d/cmm/ProfileOp/SetDataTest.java b/test/sun/java2d/cmm/ProfileOp/SetDataTest.java
new file mode 100644
index 0000000..e426820
--- /dev/null
+++ b/test/sun/java2d/cmm/ProfileOp/SetDataTest.java
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 7042594
+ * @summary Test verifies that ICC_Profile.setData() conforms the spec.
+ *
+ * @run main SetDataTest
+ */
+
+
+import java.util.ArrayList;
+import java.util.List;
+import java.awt.color.ICC_Profile;
+import static java.awt.color.ICC_ColorSpace.CS_GRAY;
+import static java.awt.color.ICC_Profile.icSigGrayTRCTag;
+import static java.awt.color.ICC_Profile.icSigRedTRCTag;
+import static java.awt.color.ICC_Profile.icSigGreenTRCTag;
+
+public class SetDataTest {
+
+ static class TestCase {
+
+ static ICC_Profile profile;
+ static byte[] validTRCdata;
+ static byte[] invalidTRCData;
+
+ static {
+ profile = ICC_Profile.getInstance(CS_GRAY);
+ validTRCdata = profile.getData(icSigGrayTRCTag);
+ invalidTRCData = new byte[]{0x42, 0x42, 0x42, 0x42, 1, 3, 4, 6,};
+ }
+ String desciption;
+ int signature;
+ boolean useValidData;
+ Throwable err;
+ boolean isIAEexpected;
+
+ public TestCase(String descr, int sig,
+ boolean useValidData,
+ boolean isIAEexpected) {
+ this.desciption = descr;
+ this.signature = sig;
+
+ this.useValidData = useValidData;
+ this.isIAEexpected = isIAEexpected;
+
+ }
+
+ public void doTest() {
+ System.out.println(desciption);
+ byte[] data = useValidData
+ ? validTRCdata : invalidTRCData;
+ err = null;
+ try {
+ profile.setData(signature, data);
+ } catch (Throwable e) {
+ err = e;
+ System.out.println("Got exception: " +
+ e.getClass().getName() + ": " +
+ e.getMessage());
+ }
+
+ if (isIAEexpected) {
+ if (err == null) {
+ throw new RuntimeException(
+ "Test failed: expected exception was not thrown");
+ }
+ if (!(err instanceof IllegalArgumentException)) {
+ throw new RuntimeException(
+ "Unexpected exception was thrown: " +
+ err.getMessage(), err);
+ }
+ } else {
+ if (err != null) {
+ throw new RuntimeException(
+ "Unexpected exception was thrown: " +
+ err.getMessage(), err);
+ }
+ }
+ System.out.println("Testcase PASSED");
+ }
+ }
+
+ public static void main(String[] args) {
+ List<TestCase> tests = new ArrayList<TestCase>();
+
+ TestCase selfupdate = new TestCase(
+ "Selfupdate: update grayTRC with the same data.",
+ icSigGrayTRCTag, true, false);
+ tests.add(selfupdate);
+
+ TestCase newValdTag = new TestCase(
+ "Insert new valid tag",
+ icSigRedTRCTag,
+ true, false);
+ tests.add(newValdTag);
+
+ TestCase newInvalidTag = new TestCase(
+ "Insert new tag with invalid contet",
+ icSigGreenTRCTag,
+ false, true);
+ tests.add(newInvalidTag);
+
+ TestCase newUnknowInvalidTag = new TestCase(
+ "Insert new tag with invalid data and unknown signature",
+ 0x41414141,
+ false, true);
+ tests.add(newUnknowInvalidTag);
+
+ TestCase newUnknownValidTag = new TestCase(
+ "Insert new tag with valid data and unknown signatiure",
+ 0x41414141,
+ true, true);
+ tests.add(newUnknownValidTag);
+
+ for (TestCase t: tests) {
+ t.doTest();
+ }
+ System.out.println("Test passed!.");
+ }
+}