Mercurial > hg > openjdk > jdk7 > jdk
changeset 4333:c102e1221afa
Merge
author | lana |
---|---|
date | Fri, 17 Jun 2011 10:27:40 -0700 |
parents | 4961be00d3b5 (diff) c46f97579fe6 (current diff) |
children | 539e576793a8 |
files | |
diffstat | 55 files changed, 1170 insertions(+), 231 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgtags Fri Jun 17 16:47:16 2011 +0100 +++ b/.hgtags Fri Jun 17 10:27:40 2011 -0700 @@ -119,3 +119,4 @@ 312612e89ece62633f4809706dec00bcd5fe7c2d jdk7-b142 efbf75c24b0f31847c9c403f6dc07dc80551908d jdk7-b143 23bdcede4e3945894574892e80b848bd9f15b5f3 jdk7-b144 +1e04b38b3824a4a1d197ef681a302e6813e53f8b jdk7-b145
--- a/make/com/sun/tools/attach/Makefile Fri Jun 17 16:47:16 2011 +0100 +++ b/make/com/sun/tools/attach/Makefile Fri Jun 17 10:27:40 2011 -0700 @@ -48,6 +48,9 @@ ifeq ($(PLATFORM), solaris) OTHER_LDLIBS += -ldoor endif +ifeq ($(PLATFORM), windows) +EXTRA_LIBS += psapi.lib +endif vpath %.c $(PLATFORM_SRC)/native/sun/tools/attach
--- a/make/sun/security/pkcs11/Makefile Fri Jun 17 16:47:16 2011 +0100 +++ b/make/sun/security/pkcs11/Makefile Fri Jun 17 10:27:40 2011 -0700 @@ -147,7 +147,7 @@ # Rules # CLASSDESTDIR = $(TEMPDIR)/classes -JAVAHFLAGS += -classpath $(CLASSDESTDIR) +JAVAHFLAGS += -Xbootclasspath/p:$(CLASSDESTDIR) include $(BUILDDIR)/common/Mapfile-vers.gmk
--- a/src/share/classes/com/sun/java/swing/plaf/gtk/GTKFileChooserUI.java Fri Jun 17 16:47:16 2011 +0100 +++ b/src/share/classes/com/sun/java/swing/plaf/gtk/GTKFileChooserUI.java Fri Jun 17 10:27:40 2011 -0700 @@ -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) {
--- a/src/share/classes/java/awt/color/ICC_Profile.java Fri Jun 17 16:47:16 2011 +0100 +++ b/src/share/classes/java/awt/color/ICC_Profile.java Fri Jun 17 10:27:40 2011 -0700 @@ -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) {
--- a/src/share/classes/java/lang/invoke/MethodHandleImpl.java Fri Jun 17 16:47:16 2011 +0100 +++ b/src/share/classes/java/lang/invoke/MethodHandleImpl.java Fri Jun 17 10:27:40 2011 -0700 @@ -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); }
--- a/src/share/classes/java/lang/invoke/MethodHandleNatives.java Fri Jun 17 16:47:16 2011 +0100 +++ b/src/share/classes/java/lang/invoke/MethodHandleNatives.java Fri Jun 17 10:27:40 2011 -0700 @@ -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);
--- a/src/share/classes/java/lang/invoke/MethodHandleStatics.java Fri Jun 17 16:47:16 2011 +0100 +++ b/src/share/classes/java/lang/invoke/MethodHandleStatics.java Fri Jun 17 10:27:40 2011 -0700 @@ -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)
--- a/src/share/classes/java/lang/invoke/MethodHandles.java Fri Jun 17 16:47:16 2011 +0100 +++ b/src/share/classes/java/lang/invoke/MethodHandles.java Fri Jun 17 10:27:40 2011 -0700 @@ -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()); + 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()); - checkSecurityManager(refc, ctor); // stack walk magic: do not refactor 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); + } } /**
--- a/src/share/classes/java/lang/invoke/SwitchPoint.java Fri Jun 17 16:47:16 2011 +0100 +++ b/src/share/classes/java/lang/invoke/SwitchPoint.java Fri Jun 17 10:27:40 2011 -0700 @@ -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); } /**
--- a/src/share/classes/java/net/NetworkInterface.java Fri Jun 17 16:47:16 2011 +0100 +++ b/src/share/classes/java/net/NetworkInterface.java Fri Jun 17 10:27:40 2011 -0700 @@ -547,13 +547,8 @@ if (displayName != null) { result += " (" + displayName + ")"; } - result += " index: "+index+" addresses:\n"; - for (Enumeration e = getInetAddresses(); e.hasMoreElements(); ) { - InetAddress addr = (InetAddress)e.nextElement(); - result += addr+";\n"; - } return result; } + private static native void init(); - }
--- a/src/share/classes/java/security/SignedObject.java Fri Jun 17 16:47:16 2011 +0100 +++ b/src/share/classes/java/security/SignedObject.java Fri Jun 17 10:27:40 2011 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -249,10 +249,10 @@ * a stream. */ private void readObject(java.io.ObjectInputStream s) - throws java.io.IOException, ClassNotFoundException - { - s.defaultReadObject(); - content = content.clone(); - signature = signature.clone(); + throws java.io.IOException, ClassNotFoundException { + java.io.ObjectInputStream.GetField fields = s.readFields(); + content = ((byte[])fields.get("content", null)).clone(); + signature = ((byte[])fields.get("signature", null)).clone(); + thealgorithm = (String)fields.get("thealgorithm", null); } }
--- a/src/share/classes/javax/swing/ImageIcon.java Fri Jun 17 16:47:16 2011 +0100 +++ b/src/share/classes/javax/swing/ImageIcon.java Fri Jun 17 10:27:40 2011 -0700 @@ -40,8 +40,7 @@ import sun.awt.AppContext; import java.lang.reflect.Field; -import java.security.PrivilegedAction; -import java.security.AccessController; +import java.security.*; /** * An implementation of the Icon interface that paints Icons @@ -81,32 +80,51 @@ ImageObserver imageObserver; String description = null; + // Fields for twisted backward compatibility only. DO NOT USE. protected final static Component component; protected final static MediaTracker tracker; static { - component = new Component() {}; - AccessController.doPrivileged(new PrivilegedAction<Object>() { - public Object run() { + component = AccessController.doPrivileged(new PrivilegedAction<Component>() { + public Component run() { try { + final Component component = createNoPermsComponent(); + // 6482575 - clear the appContext field so as not to leak it Field appContextField = - Component.class.getDeclaredField("appContext"); + + Component.class.getDeclaredField("appContext"); appContextField.setAccessible(true); appContextField.set(component, null); - } - catch (NoSuchFieldException e) { + + return component; + } catch (Throwable e) { + // We don't care about component. + // So don't prevent class initialisation. e.printStackTrace(); + return null; } - catch (IllegalAccessException e) { - e.printStackTrace(); - } - return null; } }); tracker = new MediaTracker(component); } + private static Component createNoPermsComponent() { + // 7020198 - set acc field to no permissions and no subject + // Note, will have appContext set. + return AccessController.doPrivileged( + new PrivilegedAction<Component>() { + public Component run() { + return new Component() { + }; + } + }, + new AccessControlContext(new ProtectionDomain[]{ + new ProtectionDomain(null, null) + }) + ); + } + /** * Id used in loading images from MediaTracker. */
--- a/src/share/classes/sun/invoke/util/ValueConversions.java Fri Jun 17 16:47:16 2011 +0100 +++ b/src/share/classes/sun/invoke/util/ValueConversions.java Fri Jun 17 10:27:40 2011 -0700 @@ -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();
--- a/src/share/classes/sun/java2d/pipe/DrawImage.java Fri Jun 17 16:47:16 2011 +0100 +++ b/src/share/classes/sun/java2d/pipe/DrawImage.java Fri Jun 17 10:27:40 2011 -0700 @@ -509,6 +509,9 @@ * edges thus has to be h*2+2 in length */ int edges[] = new int[(dy2-dy1)*2+2]; + // It is important that edges[0]=edges[1]=0 when we call + // Transform in case it must return early and we would + // not want to render anything on an error condition. helper.Transform(tmpmaskblit, srcData, tmpData, AlphaComposite.Src, null, itx, interpType,
--- a/src/share/classes/sun/security/pkcs11/Config.java Fri Jun 17 16:47:16 2011 +0100 +++ b/src/share/classes/sun/security/pkcs11/Config.java Fri Jun 17 10:27:40 2011 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -653,6 +653,13 @@ } } debug(keyword + ": " + lib); + + // Check to see if full path is specified to prevent the DLL + // preloading attack + if (!(new File(lib)).isAbsolute()) { + throw new ConfigurationException( + "Absolute path required for library value: " + lib); + } return lib; }
--- a/src/share/classes/sun/security/pkcs11/Secmod.java Fri Jun 17 16:47:16 2011 +0100 +++ b/src/share/classes/sun/security/pkcs11/Secmod.java Fri Jun 17 10:27:40 2011 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -236,7 +236,8 @@ throw new IllegalStateException(e); } if (modules == null) { - List<Module> modules = (List<Module>)nssGetModuleList(nssHandle); + List<Module> modules = (List<Module>)nssGetModuleList(nssHandle, + nssLibDir); this.modules = Collections.unmodifiableList(modules); } return modules; @@ -358,7 +359,7 @@ * A representation of one PKCS#11 slot in a PKCS#11 module. */ public static final class Module { - // name of the native library + // path of the native library final String libraryName; // descriptive name used by NSS final String commonName; @@ -371,8 +372,10 @@ // trust attributes. Used for the KEYSTORE and TRUSTANCHOR modules only private Map<Bytes,TrustAttributes> trust; - Module(String libraryName, String commonName, boolean fips, int slot) { + Module(String libraryDir, String libraryName, String commonName, + boolean fips, int slot) { ModuleType type; + if ((libraryName == null) || (libraryName.length() == 0)) { // must be softtoken libraryName = System.mapLibraryName(SOFTTOKEN_LIB_NAME); @@ -397,7 +400,7 @@ + "module: " + libraryName + ", " + commonName); } } - this.libraryName = libraryName; + this.libraryName = (new File(libraryDir, libraryName)).getPath(); this.commonName = commonName; this.slot = slot; this.type = type; @@ -752,6 +755,6 @@ private static native boolean nssInit(String functionName, long handle, String configDir); - private static native Object nssGetModuleList(long handle); + private static native Object nssGetModuleList(long handle, String libDir); }
--- a/src/share/native/common/jdk_util.h Fri Jun 17 16:47:16 2011 +0100 +++ b/src/share/native/common/jdk_util.h Fri Jun 17 10:27:40 2011 -0700 @@ -28,6 +28,7 @@ #include "jni.h" #include "jvm.h" +#include "jdk_util_md.h" #ifdef __cplusplus extern "C" {
--- a/src/share/native/sun/awt/image/jpeg/imageioJPEG.c Fri Jun 17 16:47:16 2011 +0100 +++ b/src/share/native/sun/awt/image/jpeg/imageioJPEG.c Fri Jun 17 10:27:40 2011 -0700 @@ -1971,6 +1971,13 @@ return data->abortFlag; } + if (cinfo->output_components <= 0 || + cinfo->image_width > (0xffffffffu / (unsigned int)cinfo->output_components)) + { + JNU_ThrowByName(env, "javax/imageio/IIOException", + "Invalid number of output components"); + return data->abortFlag; + } // Allocate a 1-scanline buffer scanLinePtr = (JSAMPROW)malloc(cinfo->image_width*cinfo->output_components);
--- a/src/share/native/sun/font/layout/SunLayoutEngine.cpp Fri Jun 17 16:47:16 2011 +0100 +++ b/src/share/native/sun/font/layout/SunLayoutEngine.cpp Fri Jun 17 10:27:40 2011 -0700 @@ -186,7 +186,11 @@ jchar buffer[256]; jchar* chars = buffer; if (len > 256) { - chars = (jchar*)malloc(len * sizeof(jchar)); + size_t size = len * sizeof(jchar); + if (size / sizeof(jchar) != len) { + return; + } + chars = (jchar*)malloc(size); if (chars == 0) { return; }
--- a/src/share/native/sun/java2d/cmm/lcms/LCMS.c Fri Jun 17 16:47:16 2011 +0100 +++ b/src/share/native/sun/java2d/cmm/lcms/LCMS.c Fri Jun 17 10:27:40 2011 -0700 @@ -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; +}
--- a/src/share/native/sun/java2d/cmm/lcms/cmsio0.c Fri Jun 17 16:47:16 2011 +0100 +++ b/src/share/native/sun/java2d/cmm/lcms/cmsio0.c Fri Jun 17 10:27:40 2011 -0700 @@ -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
--- a/src/share/native/sun/java2d/loops/TransformHelper.c Fri Jun 17 16:47:16 2011 +0100 +++ b/src/share/native/sun/java2d/loops/TransformHelper.c Fri Jun 17 10:27:40 2011 -0700 @@ -75,6 +75,94 @@ TransformInterpFunc *pBicubicFunc = BicubicInterp; /* + * The dxydxy parameters of the inverse transform determine how + * quickly we step through the source image. For tiny scale + * factors (on the order of 1E-16 or so) the stepping distances + * are huge. The image has been scaled so small that stepping + * a single pixel in device space moves the sampling point by + * billions (or more) pixels in the source image space. These + * huge stepping values can overflow the whole part of the longs + * we use for the fixed point stepping equations and so we need + * a more robust solution. We could simply iterate over every + * device pixel, use the inverse transform to transform it back + * into the source image coordinate system and then test it for + * being in range and sample pixel-by-pixel, but that is quite + * a bit more expensive. Fortunately, if the scale factors are + * so tiny that we overflow our long values then the number of + * pixels we are planning to visit should be very tiny. The only + * exception to that rule is if the scale factor along one + * dimension is tiny (creating the huge stepping values), and + * the scale factor along the other dimension is fairly regular + * or an up-scale. In that case we have a lot of pixels along + * the direction of the larger axis to sample, but few along the + * smaller axis. Though, pessimally, with an added shear factor + * such a linearly tiny image could have bounds that cover a large + * number of pixels. Such odd transformations should be very + * rare and the absolute limit on calculations would involve a + * single reverse transform of every pixel in the output image + * which is not fast, but it should not cause an undue stall + * of the rendering software. + * + * The specific test we will use is to calculate the inverse + * transformed values of every corner of the destination bounds + * (in order to be user-clip independent) and if we can + * perform a fixed-point-long inverse transform of all of + * those points without overflowing we will use the fast + * fixed point algorithm. Otherwise we will use the safe + * per-pixel transform algorithm. + * The 4 corners are 0,0, 0,dsth, dstw,0, dstw,dsth + * Transformed they are: + * tx, ty + * tx +dxdy*H, ty +dydy*H + * tx+dxdx*W, ty+dydx*W + * tx+dxdx*W+dxdy*H, ty+dydx*W+dydy*H + */ +/* We reject coordinates not less than 1<<30 so that the distance between */ +/* any 2 of them is less than 1<<31 which would overflow into the sign */ +/* bit of a signed long value used to represent fixed point coordinates. */ +#define TX_FIXED_UNSAFE(v) (fabs(v) >= (1<<30)) +static jboolean +checkOverflow(jint dxoff, jint dyoff, + SurfaceDataBounds *pBounds, + TransformInfo *pItxInfo, + jdouble *retx, jdouble *rety) +{ + jdouble x, y; + + x = dxoff+pBounds->x1+0.5; /* Center of pixel x1 */ + y = dyoff+pBounds->y1+0.5; /* Center of pixel y1 */ + Transform_transform(pItxInfo, &x, &y); + *retx = x; + *rety = y; + if (TX_FIXED_UNSAFE(x) || TX_FIXED_UNSAFE(y)) { + return JNI_TRUE; + } + + x = dxoff+pBounds->x2-0.5; /* Center of pixel x2-1 */ + y = dyoff+pBounds->y1+0.5; /* Center of pixel y1 */ + Transform_transform(pItxInfo, &x, &y); + if (TX_FIXED_UNSAFE(x) || TX_FIXED_UNSAFE(y)) { + return JNI_TRUE; + } + + x = dxoff+pBounds->x1+0.5; /* Center of pixel x1 */ + y = dyoff+pBounds->y2-0.5; /* Center of pixel y2-1 */ + Transform_transform(pItxInfo, &x, &y); + if (TX_FIXED_UNSAFE(x) || TX_FIXED_UNSAFE(y)) { + return JNI_TRUE; + } + + x = dxoff+pBounds->x2-0.5; /* Center of pixel x2-1 */ + y = dyoff+pBounds->y2-0.5; /* Center of pixel y2-1 */ + Transform_transform(pItxInfo, &x, &y); + if (TX_FIXED_UNSAFE(x) || TX_FIXED_UNSAFE(y)) { + return JNI_TRUE; + } + + return JNI_FALSE; +} + +/* * Fill the edge buffer with pairs of coordinates representing the maximum * left and right pixels of the destination surface that should be processed * on each scanline, clipped to the bounds parameter. @@ -82,21 +170,19 @@ * Only pixels that map back through the specified (inverse) transform to a * source coordinate that falls within the (0, 0, sw, sh) bounds of the * source image should be processed. - * pEdgeBuf points to an array of jints that holds MAXEDGES*2 values. - * If more storage is needed, then this function allocates a new buffer. - * In either case, a pointer to the buffer actually used to store the - * results is returned. - * The caller is responsible for freeing the buffer if the return value - * is not the same as the original pEdgeBuf passed in. + * pEdges points to an array of jints that holds 2 + numedges*2 values where + * numedges should match (pBounds->y2 - pBounds->y1). + * The first two jints in pEdges should be set to y1 and y2 and every pair + * of jints after that represent the xmin,xmax of all pixels in range of + * the transformed blit for the corresponding scanline. */ -static jint * -calculateEdges(jint *pEdgeBuf, +static void +calculateEdges(jint *pEdges, SurfaceDataBounds *pBounds, TransformInfo *pItxInfo, jlong xbase, jlong ybase, juint sw, juint sh) { - jint *pEdges; jlong dxdxlong, dydxlong; jlong dxdylong, dydylong; jlong drowxlong, drowylong; @@ -111,10 +197,8 @@ dy1 = pBounds->y1; dx2 = pBounds->x2; dy2 = pBounds->y2; - if ((dy2-dy1) > MAXEDGES) { - pEdgeBuf = malloc(2 * (dy2-dy1) * sizeof (*pEdges)); - } - pEdges = pEdgeBuf; + *pEdges++ = dy1; + *pEdges++ = dy2; drowxlong = (dx2-dx1-1) * dxdxlong; drowylong = (dx2-dx1-1) * dydxlong; @@ -155,9 +239,21 @@ ybase += dydylong; dy1++; } +} - return pEdgeBuf; -} +static void +Transform_SafeHelper(JNIEnv *env, + SurfaceDataOps *srcOps, + SurfaceDataOps *dstOps, + SurfaceDataRasInfo *pSrcInfo, + SurfaceDataRasInfo *pDstInfo, + NativePrimitive *pMaskBlitPrim, + CompositeInfo *pCompInfo, + TransformHelperFunc *pHelperFunc, + TransformInterpFunc *pInterpFunc, + RegionData *pClipInfo, TransformInfo *pItxInfo, + jint *pData, jint *pEdges, + jint dxoff, jint dyoff, jint sw, jint sh); /* * Class: sun_java2d_loops_TransformHelper @@ -187,12 +283,14 @@ jint maxlinepix; TransformHelperFunc *pHelperFunc; TransformInterpFunc *pInterpFunc; - jint edgebuf[MAXEDGES * 2]; + jdouble xorig, yorig; + jint numedges; jint *pEdges; - jdouble x, y; - jlong xbase, ybase; - jlong dxdxlong, dydxlong; - jlong dxdylong, dydylong; + jint edgebuf[2 + MAXEDGES * 2]; + union { + jlong align; + jint data[LINE_SIZE]; + } rgb; #ifdef MAKE_STUBS static int th_initialized; @@ -269,39 +367,62 @@ if (srcOps->Lock(env, srcOps, &srcInfo, pHelperPrim->srcflags) != SD_SUCCESS) { + /* edgeArray should already contain zeros for min/maxy */ return; } if (dstOps->Lock(env, dstOps, &dstInfo, pMaskBlitPrim->dstflags) != SD_SUCCESS) { SurfaceData_InvokeUnlock(env, srcOps, &srcInfo); + /* edgeArray should already contain zeros for min/maxy */ return; } Region_IntersectBounds(&clipInfo, &dstInfo.bounds); + numedges = (dstInfo.bounds.y2 - dstInfo.bounds.y1); + if (numedges > MAXEDGES) { + pEdges = malloc((2 + 2 * numedges) * sizeof (*pEdges)); + if (pEdges == NULL) { + SurfaceData_InvokeUnlock(env, dstOps, &dstInfo); + SurfaceData_InvokeUnlock(env, srcOps, &srcInfo); + /* edgeArray should already contain zeros for min/maxy */ + return; + } + } else { + pEdges = edgebuf; + } + Transform_GetInfo(env, itxform, &itxInfo); - dxdxlong = DblToLong(itxInfo.dxdx); - dydxlong = DblToLong(itxInfo.dydx); - dxdylong = DblToLong(itxInfo.dxdy); - dydylong = DblToLong(itxInfo.dydy); - x = dxoff+dstInfo.bounds.x1+0.5; /* Center of pixel x1 */ - y = dyoff+dstInfo.bounds.y1+0.5; /* Center of pixel y1 */ - Transform_transform(&itxInfo, &x, &y); - xbase = DblToLong(x); - ybase = DblToLong(y); - - pEdges = calculateEdges(edgebuf, &dstInfo.bounds, &itxInfo, - xbase, ybase, sx2-sx1, sy2-sy1); if (!Region_IsEmpty(&clipInfo)) { srcOps->GetRasInfo(env, srcOps, &srcInfo); dstOps->GetRasInfo(env, dstOps, &dstInfo); - if (srcInfo.rasBase && dstInfo.rasBase) { - union { - jlong align; - jint data[LINE_SIZE]; - } rgb; + if (srcInfo.rasBase == NULL || dstInfo.rasBase == NULL) { + pEdges[0] = pEdges[1] = 0; + } else if (checkOverflow(dxoff, dyoff, &dstInfo.bounds, + &itxInfo, &xorig, &yorig)) + { + Transform_SafeHelper(env, srcOps, dstOps, + &srcInfo, &dstInfo, + pMaskBlitPrim, &compInfo, + pHelperFunc, pInterpFunc, + &clipInfo, &itxInfo, rgb.data, pEdges, + dxoff, dyoff, sx2-sx1, sy2-sy1); + } else { SurfaceDataBounds span; + jlong dxdxlong, dydxlong; + jlong dxdylong, dydylong; + jlong xbase, ybase; + + dxdxlong = DblToLong(itxInfo.dxdx); + dydxlong = DblToLong(itxInfo.dydx); + dxdylong = DblToLong(itxInfo.dxdy); + dydylong = DblToLong(itxInfo.dydy); + xbase = DblToLong(xorig); + ybase = DblToLong(yorig); + + calculateEdges(pEdges, &dstInfo.bounds, &itxInfo, + xbase, ybase, sx2-sx1, sy2-sy1); Region_StartIteration(env, &clipInfo); while (Region_NextIteration(&clipInfo, &span)) { @@ -318,8 +439,8 @@ /* Note - process at most one scanline at a time. */ - dx1 = pEdges[(dy1 - dstInfo.bounds.y1) * 2]; - dx2 = pEdges[(dy1 - dstInfo.bounds.y1) * 2 + 1]; + dx1 = pEdges[(dy1 - dstInfo.bounds.y1) * 2 + 2]; + dx2 = pEdges[(dy1 - dstInfo.bounds.y1) * 2 + 3]; if (dx1 < span.x1) dx1 = span.x1; if (dx2 > span.x2) dx2 = span.x2; @@ -376,21 +497,124 @@ } SurfaceData_InvokeRelease(env, dstOps, &dstInfo); SurfaceData_InvokeRelease(env, srcOps, &srcInfo); + } else { + pEdges[0] = pEdges[1] = 0; } SurfaceData_InvokeUnlock(env, dstOps, &dstInfo); SurfaceData_InvokeUnlock(env, srcOps, &srcInfo); if (!JNU_IsNull(env, edgeArray)) { - (*env)->SetIntArrayRegion(env, edgeArray, 0, 1, &dstInfo.bounds.y1); - (*env)->SetIntArrayRegion(env, edgeArray, 1, 1, &dstInfo.bounds.y2); - (*env)->SetIntArrayRegion(env, edgeArray, - 2, (dstInfo.bounds.y2 - dstInfo.bounds.y1)*2, - pEdges); + (*env)->SetIntArrayRegion(env, edgeArray, 0, 2+numedges*2, pEdges); } if (pEdges != edgebuf) { free(pEdges); } } +static void +Transform_SafeHelper(JNIEnv *env, + SurfaceDataOps *srcOps, + SurfaceDataOps *dstOps, + SurfaceDataRasInfo *pSrcInfo, + SurfaceDataRasInfo *pDstInfo, + NativePrimitive *pMaskBlitPrim, + CompositeInfo *pCompInfo, + TransformHelperFunc *pHelperFunc, + TransformInterpFunc *pInterpFunc, + RegionData *pClipInfo, TransformInfo *pItxInfo, + jint *pData, jint *pEdges, + jint dxoff, jint dyoff, jint sw, jint sh) +{ + SurfaceDataBounds span; + jint dx1, dx2; + jint dy1, dy2; + jint i, iy; + + dy1 = pDstInfo->bounds.y1; + dy2 = pDstInfo->bounds.y2; + dx1 = pDstInfo->bounds.x1; + dx2 = pDstInfo->bounds.x2; + pEdges[0] = dy1; + pEdges[1] = dy2; + for (iy = dy1; iy < dy2; iy++) { + jint i = (iy - dy1) * 2; + /* row spans are set to max,min until we find a pixel in range below */ + pEdges[i + 2] = dx2; + pEdges[i + 3] = dx1; + } + + Region_StartIteration(env, pClipInfo); + while (Region_NextIteration(pClipInfo, &span)) { + dy1 = span.y1; + dy2 = span.y2; + while (dy1 < dy2) { + dx1 = span.x1; + dx2 = span.x2; + i = (dy1 - pDstInfo->bounds.y1) * 2; + while (dx1 < dx2) { + jdouble x, y; + jlong xlong, ylong; + + x = dxoff + dx1 + 0.5; + y = dyoff + dy1 + 0.5; + Transform_transform(pItxInfo, &x, &y); + xlong = DblToLong(x); + ylong = DblToLong(y); + + /* Process only pixels with centers in bounds + * Test double values to avoid overflow in conversion + * to long values and then also test the long values + * in case they rounded up and out of bounds during + * the conversion. + */ + if (x >= 0 && y >= 0 && x < sw && y < sh && + WholeOfLong(xlong) < sw && + WholeOfLong(ylong) < sh) + { + void *pDst; + + if (pEdges[i + 2] > dx1) { + pEdges[i + 2] = dx1; + } + if (pEdges[i + 3] <= dx1) { + pEdges[i + 3] = dx1 + 1; + } + + /* Get IntArgbPre pixel data from source */ + (*pHelperFunc)(pSrcInfo, + pData, 1, + xlong, 0, + ylong, 0); + + /* Interpolate result pixels if needed */ + if (pInterpFunc) { + (*pInterpFunc)(pData, 1, + FractOfLong(xlong-LongOneHalf), 0, + FractOfLong(ylong-LongOneHalf), 0); + } + + /* Store/Composite interpolated pixels into dest */ + pDst = PtrCoord(pDstInfo->rasBase, + dx1, pDstInfo->pixelStride, + dy1, pDstInfo->scanStride); + (*pMaskBlitPrim->funcs.maskblit)(pDst, pData, + 0, 0, 0, + 1, 1, + pDstInfo, pSrcInfo, + pMaskBlitPrim, + pCompInfo); + } + + /* Increment to next input pixel */ + dx1++; + } + + /* Increment to next scanline */ + dy1++; + } + } + Region_EndIteration(env, pClipInfo); +} + #define BL_INTERP_V1_to_V2_by_F(v1, v2, f) \ (((v1)<<8) + ((v2)-(v1))*(f))
--- a/src/share/native/sun/security/pkcs11/j2secmod.c Fri Jun 17 16:47:16 2011 +0100 +++ b/src/share/native/sun/security/pkcs11/j2secmod.c Fri Jun 17 10:27:40 2011 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -74,7 +74,7 @@ } JNIEXPORT jobject JNICALL Java_sun_security_pkcs11_Secmod_nssGetModuleList - (JNIEnv *env, jclass thisClass, jlong jHandle) + (JNIEnv *env, jclass thisClass, jlong jHandle, jstring jLibDir) { FPTR_GetDBModuleList getModuleList = (FPTR_GetDBModuleList)findFunction(env, jHandle, "SECMOD_GetDefaultModuleList"); @@ -104,8 +104,8 @@ jList = (*env)->NewObject(env, jListClass, jListConstructor); jModuleClass = (*env)->FindClass(env, "sun/security/pkcs11/Secmod$Module"); - jModuleConstructor = (*env)->GetMethodID - (env, jModuleClass, "<init>", "(Ljava/lang/String;Ljava/lang/String;ZI)V"); + jModuleConstructor = (*env)->GetMethodID(env, jModuleClass, "<init>", + "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZI)V"); while (list != NULL) { module = list->module; @@ -124,7 +124,8 @@ } jFIPS = module->isFIPS; for (i = 0; i < module->slotCount; i++ ) { - jModule = (*env)->NewObject(env, jModuleClass, jModuleConstructor, jDllName, jCommonName, jFIPS, i); + jModule = (*env)->NewObject(env, jModuleClass, jModuleConstructor, + jLibDir, jDllName, jCommonName, jFIPS, i); (*env)->CallVoidMethod(env, jList, jAdd, jModule); } list = list->next;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/solaris/native/common/jdk_util_md.h Fri Jun 17 10:27:40 2011 -0700 @@ -0,0 +1,26 @@ +/* + * 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// Currently, there are no unix specific functions defined.
--- a/src/windows/classes/sun/tools/attach/WindowsAttachProvider.java Fri Jun 17 16:47:16 2011 +0100 +++ b/src/windows/classes/sun/tools/attach/WindowsAttachProvider.java Fri Jun 17 10:27:40 2011 -0700 @@ -126,16 +126,6 @@ * of the process list. */ private List<VirtualMachineDescriptor> listJavaProcesses() { - // ensure that process status helper is loaded (psapi.dll) - if (!isProcessStatusHelperInitialized) { - synchronized (WindowsAttachProvider.class) { - if (!isProcessStatusHelperInitialized) { - initializeProcessStatusHelper(); - isProcessStatusHelperInitialized = true; - } - } - } - ArrayList<VirtualMachineDescriptor> list = new ArrayList<VirtualMachineDescriptor>(); @@ -172,12 +162,6 @@ return list; } - // indicates if psapi.dll has been initialized - private static volatile boolean isProcessStatusHelperInitialized; - - // loads psapi - private static native void initializeProcessStatusHelper(); - // enumerates processes using psapi's EnumProcesses private static native int enumProcesses(int[] processes, int max);
--- a/src/windows/native/common/jdk_util_md.c Fri Jun 17 16:47:16 2011 +0100 +++ b/src/windows/native/common/jdk_util_md.c Fri Jun 17 10:27:40 2011 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 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 @@ -38,3 +38,25 @@ void* JDK_FindJvmEntry(const char* name) { return (void*) GetProcAddress(jvm_handle, name); } + +JNIEXPORT HMODULE JDK_LoadSystemLibrary(const char* name) { + HMODULE handle = NULL; + char path[MAX_PATH]; + int ret; + + if (GetSystemDirectory(path, sizeof(path)) != 0) { + strcat(path, "\\"); + strcat(path, name); + handle = LoadLibrary(path); + } + + if (handle == NULL) { + if (GetWindowsDirectory(path, sizeof(path)) != 0) { + strcat(path, "\\"); + strcat(path, name); + handle = LoadLibrary(path); + } + } + return handle; +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/windows/native/common/jdk_util_md.h Fri Jun 17 10:27:40 2011 -0700 @@ -0,0 +1,42 @@ +/* + * 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + + +#ifndef JDK_UTIL_MD_H +#define JDK_UTIL_MD_H + +#include "jni.h" + +#ifdef __cplusplus +extern "C" { +#endif + +JNIEXPORT HMODULE JDK_LoadSystemLibrary(const char* name); + +#ifdef __cplusplus +} /* extern "C" */ +#endif /* __cplusplus */ + +#endif /* JDK_UTIL_MD_H */
--- a/src/windows/native/sun/java2d/d3d/D3DPipelineManager.cpp Fri Jun 17 16:47:16 2011 +0100 +++ b/src/windows/native/sun/java2d/d3d/D3DPipelineManager.cpp Fri Jun 17 10:27:40 2011 -0700 @@ -117,7 +117,7 @@ { typedef IDirect3D9 * WINAPI FnDirect3DCreate9(UINT SDKVersion); - hLibD3D9 = ::LoadLibrary(TEXT("d3d9.dll")); + hLibD3D9 = JDK_LoadSystemLibrary("d3d9.dll"); if (hLibD3D9 == NULL) { J2dRlsTraceLn(J2D_TRACE_ERROR, "InitD3D: no d3d9.dll"); return E_FAIL;
--- a/src/windows/native/sun/java2d/opengl/OGLFuncs_md.h Fri Jun 17 16:47:16 2011 +0100 +++ b/src/windows/native/sun/java2d/opengl/OGLFuncs_md.h Fri Jun 17 10:27:40 2011 -0700 @@ -29,6 +29,7 @@ #include <windows.h> #include "J2D_GL/wglext.h" #include "OGLFuncMacros.h" +#include <jdk_util.h> /** * Core WGL functions @@ -60,7 +61,7 @@ #define OGL_LIB_IS_UNINITIALIZED() \ (OGL_LIB_HANDLE == 0) #define OGL_OPEN_LIB() \ - OGL_LIB_HANDLE = LoadLibrary(L"opengl32.dll") + OGL_LIB_HANDLE = JDK_LoadSystemLibrary("opengl32.dll") #define OGL_CLOSE_LIB() \ FreeLibrary(OGL_LIB_HANDLE) #define OGL_GET_PROC_ADDRESS(f) \
--- a/src/windows/native/sun/tools/attach/WindowsAttachProvider.c Fri Jun 17 16:47:16 2011 +0100 +++ b/src/windows/native/sun/tools/attach/WindowsAttachProvider.c Fri Jun 17 10:27:40 2011 -0700 @@ -25,6 +25,7 @@ #include <windows.h> #include <stdlib.h> #include <string.h> +#include <Psapi.h> #include "jni.h" #include "jni_util.h" @@ -97,41 +98,6 @@ /* - * Process status helper library functions - */ -static BOOL (WINAPI *_EnumProcesses) (DWORD *, DWORD, DWORD *); -static BOOL (WINAPI *_EnumProcessModules)(HANDLE, HMODULE *, DWORD, LPDWORD); -static DWORD (WINAPI *_GetModuleBaseName) (HANDLE, HMODULE, LPTSTR, DWORD); - - -/* - * Class: sun_tools_attach_WindowsAttachProvider - * Method: initializeProcessStatusHelper - * Signature: ()V - */ -JNIEXPORT void JNICALL -Java_sun_tools_attach_WindowsAttachProvider_initializeProcessStatusHelper(JNIEnv *env, jclass cls) -{ - HINSTANCE psapi = LoadLibrary("PSAPI.DLL") ; - if (psapi != NULL) { - _EnumProcesses = (BOOL(WINAPI *)(DWORD *, DWORD, DWORD *)) - GetProcAddress(psapi, "EnumProcesses") ; - _EnumProcessModules = (BOOL(WINAPI *)(HANDLE, HMODULE *, DWORD, LPDWORD)) - GetProcAddress(psapi, "EnumProcessModules"); - _GetModuleBaseName = (DWORD(WINAPI *)(HANDLE, HMODULE, LPTSTR, DWORD)) - GetProcAddress(psapi, "GetModuleBaseNameA"); - } - - if ((_EnumProcesses == NULL) || - (_EnumProcessModules == NULL) || - (_GetModuleBaseName == NULL)) - { - JNU_ThrowInternalError(env, "Unable to initialize process status helper library"); - } -} - - -/* * Class: sun_tools_attach_WindowsAttachProvider * Method: enumProcesses * Signature: ([JI)I @@ -147,7 +113,7 @@ size = max * sizeof(DWORD); ptr = (DWORD*)malloc(size); if (ptr != NULL) { - BOOL res = (*_EnumProcesses)(ptr, size, &bytesReturned); + BOOL res = EnumProcesses(ptr, size, &bytesReturned); if (res != 0) { result = (jint)(bytesReturned / sizeof(DWORD)); (*env)->SetIntArrayRegion(env, arr, 0, (jsize)result, (jint*)ptr); @@ -192,13 +158,13 @@ size = 1024 * sizeof(HMODULE); ptr = (HMODULE*)malloc(size); if (ptr != NULL) { - BOOL res = (*_EnumProcessModules)(hProcess, ptr, size, &bytesReturned); + BOOL res = EnumProcessModules(hProcess, ptr, size, &bytesReturned); if (res != 0) { int count = bytesReturned / sizeof(HMODULE); int i = 0; while (i < count) { char base[256]; - BOOL res = (*_GetModuleBaseName)(hProcess, ptr[i], base, sizeof(base)); + BOOL res = GetModuleBaseName(hProcess, ptr[i], base, sizeof(base)); if (res != 0) { if (strcmp(base, lib) == 0) { result = JNI_TRUE;
--- a/src/windows/native/sun/tools/attach/WindowsVirtualMachine.c Fri Jun 17 16:47:16 2011 +0100 +++ b/src/windows/native/sun/tools/attach/WindowsVirtualMachine.c Fri Jun 17 10:27:40 2011 -0700 @@ -32,13 +32,13 @@ /* kernel32 */ -typedef HINSTANCE (WINAPI* LoadLibraryFunc) (LPCTSTR); +typedef HINSTANCE (WINAPI* GetModuleHandleFunc) (LPCTSTR); typedef FARPROC (WINAPI* GetProcAddressFunc)(HMODULE, LPCSTR); /* only on Windows 64-bit or 32-bit application running under WOW64 */ typedef BOOL (WINAPI *IsWow64ProcessFunc) (HANDLE, PBOOL); -static LoadLibraryFunc _LoadLibrary; +static GetModuleHandleFunc _GetModuleHandle; static GetProcAddressFunc _GetProcAddress; static IsWow64ProcessFunc _IsWow64Process; @@ -70,7 +70,7 @@ #define MAX_PIPE_NAME_LENGTH 256 typedef struct { - LoadLibraryFunc _LoadLibrary; + GetModuleHandleFunc _GetModuleHandle; GetProcAddressFunc _GetProcAddress; char jvmLib[MAX_LIBNAME_LENGTH]; /* "jvm.dll" */ char func1[MAX_FUNC_LENGTH]; @@ -96,7 +96,7 @@ HINSTANCE h; EnqueueOperationFunc addr; - h = pData->_LoadLibrary(pData->jvmLib); + h = pData->_GetModuleHandle(pData->jvmLib); if (h == NULL) { return ERR_OPEN_JVM_FAIL; } @@ -131,15 +131,10 @@ JNIEXPORT void JNICALL Java_sun_tools_attach_WindowsVirtualMachine_init (JNIEnv *env, jclass cls) { - HINSTANCE h = LoadLibrary("kernel32"); - if (h != NULL) { - _LoadLibrary = (LoadLibraryFunc) GetProcAddress(h, "LoadLibraryA"); - _GetProcAddress = (GetProcAddressFunc)GetProcAddress(h, "GetProcAddress"); - _IsWow64Process = (IsWow64ProcessFunc)GetProcAddress(h, "IsWow64Process"); - } - if (_LoadLibrary == NULL || _GetProcAddress == NULL) { - JNU_ThrowInternalError(env, "Unable to get address of LoadLibraryA or GetProcAddress"); - } + // All following APIs exist on Windows XP with SP2/Windows Server 2008 + _GetModuleHandle = (GetModuleHandleFunc)GetModuleHandle; + _GetProcAddress = (GetProcAddressFunc)GetProcAddress; + _IsWow64Process = (IsWow64ProcessFunc)IsWow64Process; } @@ -375,7 +370,7 @@ /* * Setup data to copy to target process */ - data._LoadLibrary = _LoadLibrary; + data._GetModuleHandle = _GetModuleHandle; data._GetProcAddress = _GetProcAddress; strcpy(data.jvmLib, "jvm");
--- a/src/windows/native/sun/tracing/dtrace/jvm_symbols_md.c Fri Jun 17 16:47:16 2011 +0100 +++ b/src/windows/native/sun/tracing/dtrace/jvm_symbols_md.c Fri Jun 17 10:27:40 2011 -0700 @@ -35,7 +35,7 @@ JvmSymbols* lookupJvmSymbols() { JvmSymbols* syms = (JvmSymbols*)malloc(sizeof(JvmSymbols)); if (syms != NULL) { - HINSTANCE jvm = LoadLibrary("jvm.dll"); + HINSTANCE jvm = GetModuleHandle("jvm.dll"); if (jvm == NULL) { free(syms); return NULL;
--- a/src/windows/native/sun/windows/DllUtil.cpp Fri Jun 17 16:47:16 2011 +0100 +++ b/src/windows/native/sun/windows/DllUtil.cpp Fri Jun 17 10:27:40 2011 -0700 @@ -25,6 +25,7 @@ #include "DllUtil.h" +#include <jdk_util.h> // Disable warning about using this in the initializer list. #pragma warning( disable : 4355) @@ -40,7 +41,7 @@ HMODULE DllUtil::GetModule() { if (!module) { - module = ::LoadLibrary(name); + module = JDK_LoadSystemLibrary(name); } return module; } @@ -60,7 +61,7 @@ } DwmAPI::DwmAPI() : - DllUtil(_T("DWMAPI.DLL")), + DllUtil("DWMAPI.DLL"), DwmIsCompositionEnabledFunction((DllUtil*)this, "DwmIsCompositionEnabled"), DwmGetWindowAttributeFunction((DllUtil*)this, "DwmGetWindowAttribute") {
--- a/src/windows/native/sun/windows/DllUtil.h Fri Jun 17 16:47:16 2011 +0100 +++ b/src/windows/native/sun/windows/DllUtil.h Fri Jun 17 10:27:40 2011 -0700 @@ -43,7 +43,7 @@ FARPROC GetProcAddress(LPCSTR name); protected: - DllUtil(const TCHAR * name) : name(name), module(NULL) {} + DllUtil(const char * name) : name(name), module(NULL) {} virtual ~DllUtil(); HMODULE GetModule(); @@ -68,7 +68,7 @@ }; private: - const TCHAR * const name; + const char * const name; HMODULE module; };
--- a/src/windows/native/sun/windows/ShellFolder2.cpp Fri Jun 17 16:47:16 2011 +0100 +++ b/src/windows/native/sun/windows/ShellFolder2.cpp Fri Jun 17 10:27:40 2011 -0700 @@ -120,15 +120,15 @@ return TRUE; } // Load libraries - libShell32 = LoadLibrary(TEXT("shell32.dll")); + libShell32 = JDK_LoadSystemLibrary("shell32.dll"); if (libShell32 == NULL) { return FALSE; } - libUser32 = LoadLibrary(TEXT("user32.dll")); + libUser32 = JDK_LoadSystemLibrary("user32.dll"); if (libUser32 == NULL) { return FALSE; } - libComCtl32 = LoadLibrary(TEXT("comctl32.dll")); + libComCtl32 = JDK_LoadSystemLibrary("comctl32.dll"); if (libComCtl32 == NULL) { return FALSE; } @@ -1021,7 +1021,8 @@ (JNIEnv* env, jclass cls, jstring libName, jint iconID, jint cxDesired, jint cyDesired, jboolean useVGAColors) { - HINSTANCE libHandle = LoadLibrary(JNU_GetStringPlatformChars(env, libName, NULL)); + const char *pLibName = env->GetStringUTFChars(libName, NULL); + HINSTANCE libHandle = (HINSTANCE)JDK_LoadSystemLibrary(pLibName); if (libHandle != NULL) { UINT fuLoad = (useVGAColors && !IS_WINXP) ? LR_VGACOLOR : 0; return ptr_to_jlong(LoadImage(libHandle, MAKEINTRESOURCE(iconID),
--- a/src/windows/native/sun/windows/ThemeReader.cpp Fri Jun 17 16:47:16 2011 +0100 +++ b/src/windows/native/sun/windows/ThemeReader.cpp Fri Jun 17 10:27:40 2011 -0700 @@ -150,7 +150,7 @@ BOOL InitThemes() { static HMODULE hModThemes = NULL; - hModThemes = LoadLibrary(TEXT("UXTHEME.DLL")); + hModThemes = JDK_LoadSystemLibrary("UXTHEME.DLL"); DTRACE_PRINTLN1("InitThemes hModThemes = %x\n", hModThemes); if(hModThemes) { DTRACE_PRINTLN("Loaded UxTheme.dll\n");
--- a/src/windows/native/sun/windows/awt_FileDialog.cpp Fri Jun 17 16:47:16 2011 +0100 +++ b/src/windows/native/sun/windows/awt_FileDialog.cpp Fri Jun 17 10:27:40 2011 -0700 @@ -284,7 +284,7 @@ file = (jstring)env->GetObjectField(target, AwtFileDialog::fileID); if (file != NULL) { LPCTSTR tmp = JNU_GetStringPlatformChars(env, file, NULL); - _tcscpy(fileBuffer, tmp); + _tcsncpy(fileBuffer, tmp, bufferLimit - 2); // the fileBuffer is double null terminated string JNU_ReleaseStringPlatformChars(env, file, tmp); } else { fileBuffer[0] = _T('\0');
--- a/src/windows/native/sun/windows/awt_Mlib.cpp Fri Jun 17 16:47:16 2011 +0100 +++ b/src/windows/native/sun/windows/awt_Mlib.cpp Fri Jun 17 10:27:40 2011 -0700 @@ -43,12 +43,13 @@ mlibSysFnS_t tempSysFns; mlib_status ret = MLIB_SUCCESS; - /* Try to load library. Routine should find the library successfully - * because this library is already loaded to the process space by - * the System.loadLibrary() call. Here we just need to get handle to - * initialize the pointers to required mlib routines. + /* Try to receive handle for the library. Routine should find + * the library successfully because this library is already + * loaded to the process space by the System.loadLibrary() call. + * Here we just need to get handle to initialize the pointers to + * required mlib routines. */ - hDLL = ::LoadLibrary(TEXT("mlib_image.dll")); + hDLL = ::GetModuleHandle(TEXT("mlib_image.dll")); if (hDLL == NULL) { return MLIB_FAILURE; @@ -94,9 +95,6 @@ i++; } - if (ret != MLIB_SUCCESS) { - ::FreeLibrary(hDLL); - } return ret; }
--- a/src/windows/native/sun/windows/awt_TextArea.cpp Fri Jun 17 16:47:16 2011 +0100 +++ b/src/windows/native/sun/windows/awt_TextArea.cpp Fri Jun 17 10:27:40 2011 -0700 @@ -77,7 +77,7 @@ LPCTSTR AwtTextArea::GetClassName() { static BOOL richedLibraryLoaded = FALSE; if (!richedLibraryLoaded) { - ::LoadLibrary(TEXT("RICHED20.DLL")); + JDK_LoadSystemLibrary("RICHED20.DLL"); richedLibraryLoaded = TRUE; } return RICHEDIT_CLASS;
--- a/src/windows/native/sun/windows/awt_TrayIcon.cpp Fri Jun 17 16:47:16 2011 +0100 +++ b/src/windows/native/sun/windows/awt_TrayIcon.cpp Fri Jun 17 10:27:40 2011 -0700 @@ -185,7 +185,7 @@ int shellVersion = 5; // WIN_2000 // MSDN: DllGetVersion should not be implicitly called, but rather // loaded using GetProcAddress - HMODULE hShell = LoadLibrary(TEXT("Shell32.dll")); + HMODULE hShell = JDK_LoadSystemLibrary("Shell32.dll"); if (hShell != NULL) { DLLGETVERSIONPROC proc = (DLLGETVERSIONPROC)GetProcAddress(hShell, "DllGetVersion"); if (proc != NULL) {
--- a/src/windows/native/sun/windows/awt_Win32GraphicsDevice.cpp Fri Jun 17 16:47:16 2011 +0100 +++ b/src/windows/native/sun/windows/awt_Win32GraphicsDevice.cpp Fri Jun 17 10:27:40 2011 -0700 @@ -673,6 +673,12 @@ */ void AwtWin32GraphicsDevice::ResetAllMonitorInfo() { + //IE in some circumstances generates WM_SETTINGCHANGE message on appearance + //and thus triggers this method + //but we may not have the devices list initialized yet. + if (!Devices::GetInstance()){ + return; + } Devices::InstanceAccess devices; int devicesNum = devices->GetNumDevices(); for (int deviceIndex = 0; deviceIndex < devicesNum; deviceIndex++) {
--- a/src/windows/native/sun/windows/awt_Win32GraphicsEnv.cpp Fri Jun 17 16:47:16 2011 +0100 +++ b/src/windows/native/sun/windows/awt_Win32GraphicsEnv.cpp Fri Jun 17 10:27:40 2011 -0700 @@ -63,7 +63,7 @@ bAlreadySet = TRUE; - HMODULE hLibUser32Dll = ::LoadLibrary(TEXT("user32.dll")); + HMODULE hLibUser32Dll = JDK_LoadSystemLibrary("user32.dll"); if (hLibUser32Dll != NULL) { SetProcessDPIAwareFunc *lpSetProcessDPIAware =
--- a/src/windows/native/sun/windows/stdhdrs.h Fri Jun 17 16:47:16 2011 +0100 +++ b/src/windows/native/sun/windows/stdhdrs.h Fri Jun 17 10:27:40 2011 -0700 @@ -47,6 +47,7 @@ // standard Java headers #include <jni.h> #include <jni_util.h> +#include <jdk_util.h> } // extern "C"
--- a/src/windows/npt/npt_md.h Fri Jun 17 16:47:16 2011 +0100 +++ b/src/windows/npt/npt_md.h Fri Jun 17 10:27:40 2011 -0700 @@ -47,7 +47,7 @@ _handle = NULL; \ *(pnpt) = NULL; \ buf[0] = 0; \ - jvm = LoadLibrary("jvm.dll"); \ + jvm = GetModuleHandle("jvm.dll"); \ if ( jvm == NULL ) NPT_ERROR("Cannot find jvm.dll"); \ GetModuleFileName(jvm, buf, FILENAME_MAX); \ lastSlash = strrchr(buf, '\\'); \
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/image/BufferedImage/TinyScale.java Fri Jun 17 10:27:40 2011 -0700 @@ -0,0 +1,68 @@ +/* + * @test %W% %E% + * @bug 7016495 + * @summary Test tiny scales of BufferedImage + */ + +import java.awt.*; +import java.awt.geom.*; +import java.awt.image.*; + +public class TinyScale { + static double tinyscales[] = { + 1E-0, + 1E-1, + 1E-2, + 1E-3, + 1E-4, + 1E-5, + 1E-6, + 1E-7, + 1E-8, + 1E-9, + 1E-10, + 1E-11, + 1E-12, + 1E-13, + 1E-14, + 1E-15, + 1E-16, + 1E-17, + 1E-18, + 1E-19, + 1E-20, + 1E-21, + 1E-22, + 1E-23, + 1E-24, + 1E-25, + 1E-26, + 1E-27, + 1E-28, + 1E-29, + }; + + static void test(BufferedImage rendImg, BufferedImage drawImg, double s) { + Graphics2D g = drawImg.createGraphics(); + g.transform(new AffineTransform(s, 0.0, -1.0, 1.0, 0.0, 0.0)); + g.drawImage(rendImg, + -rendImg.getWidth() / 2, + -rendImg.getHeight() / 2, + null); + g.drawImage(rendImg, 0, 0, null); + g.dispose(); + } + + public static void main(String[] args) { + BufferedImage rendImg = + new BufferedImage(100, 100, BufferedImage.TYPE_3BYTE_BGR); + BufferedImage drawImg = + new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB); + for (double s: tinyscales) { + test(rendImg, drawImg, s); + for (int i = 0; args.length > 0 && i < 10; i++) { + test(rendImg, drawImg, Math.random()*s); + } + } + } +}
--- a/test/java/lang/invoke/InvokeDynamicPrintArgs.java Fri Jun 17 16:47:16 2011 +0100 +++ b/test/java/lang/invoke/InvokeDynamicPrintArgs.java Fri Jun 17 10:27:40 2011 -0700 @@ -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.
--- a/test/java/lang/invoke/JavaDocExamplesTest.java Fri Jun 17 16:47:16 2011 +0100 +++ b/test/java/lang/invoke/JavaDocExamplesTest.java Fri Jun 17 10:27:40 2011 -0700 @@ -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")); {} }}
--- a/test/java/lang/invoke/RicochetTest.java Fri Jun 17 16:47:16 2011 +0100 +++ b/test/java/lang/invoke/RicochetTest.java Fri Jun 17 10:27:40 2011 -0700 @@ -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 */
--- a/test/java/security/Security/NoInstalledProviders.java Fri Jun 17 16:47:16 2011 +0100 +++ b/test/java/security/Security/NoInstalledProviders.java Fri Jun 17 10:27:40 2011 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -23,8 +23,9 @@ /* * @test - * @bug 4273454 + * @bug 4273454 7052537 * @summary Make sure getProviders(filter) doesn't throw NPE + * @run main/othervm NoInstalledProviders */ import java.security.*;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/security/SignedObject/Correctness.java Fri Jun 17 10:27:40 2011 -0700 @@ -0,0 +1,71 @@ +/* + * 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 6618658 + * @summary Deserialization allows creation of mutable SignedObject + */ + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.Signature; +import java.security.SignedObject; + + +public class Correctness { + + public static void main(String[] args) throws Exception { + + String SIGALG = "SHA1withRSA"; + KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA"); + KeyPair kp = kpg.generateKeyPair(); + + SignedObject so1 = new SignedObject("Hello", kp.getPrivate(), + Signature.getInstance(SIGALG)); + + ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); + ObjectOutputStream out = new ObjectOutputStream(byteOut); + out.writeObject(so1); + out.close(); + + byte[] data = byteOut.toByteArray(); + + SignedObject so2 = (SignedObject)new ObjectInputStream( + new ByteArrayInputStream(data)).readObject(); + + if (!so2.getObject().equals("Hello")) { + throw new Exception("Content changed"); + } + if (!so2.getAlgorithm().equals(SIGALG)) { + throw new Exception("Signature algorithm unknown"); + } + if (!so2.verify(kp.getPublic(), Signature.getInstance(SIGALG))) { + throw new Exception("Not verified"); + } + } +}
--- a/test/sun/java2d/cmm/ProfileOp/ReadWriteProfileTest.java Fri Jun 17 16:47:16 2011 +0100 +++ b/test/sun/java2d/cmm/ProfileOp/ReadWriteProfileTest.java Fri Jun 17 10:27:40 2011 -0700 @@ -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);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/sun/java2d/cmm/ProfileOp/SetDataTest.java Fri Jun 17 10:27:40 2011 -0700 @@ -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!."); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/sun/security/pkcs11/Provider/Absolute.cfg Fri Jun 17 10:27:40 2011 -0700 @@ -0,0 +1,10 @@ +# +# Configuration file to allow the SunPKCS11 provider to utilize +# the Solaris Cryptographic Framework, if it is available +# + +name = Absolute + +description = SunPKCS11 using a relative path + +library = ./libpkcs11.so
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/sun/security/pkcs11/Provider/Absolute.java Fri Jun 17 10:27:40 2011 -0700 @@ -0,0 +1,63 @@ +/* + * 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 7003952 + * @summary load DLLs and launch executables using fully qualified path + */ +import java.security.*; +import java.lang.reflect.*; +import sun.security.pkcs11.*; + +public class Absolute { + + public static void main(String[] args) throws Exception { + Constructor cons; + try { + Class clazz = Class.forName("sun.security.pkcs11.SunPKCS11"); + cons = clazz.getConstructor(new Class[] {String.class}); + } catch (Exception ex) { + System.out.println("Skipping test - no PKCS11 provider available"); + return; + } + + String config = + System.getProperty("test.src", ".") + "/Absolute.cfg"; + + try { + Object obj = cons.newInstance(new Object[] {config}); + } catch (InvocationTargetException ite) { + Throwable cause = ite.getCause(); + if (cause instanceof ProviderException) { + Throwable cause2 = cause.getCause(); + if ((cause2 == null) || + !cause2.getMessage().startsWith( + "Absolute path required for library value:")) { + // rethrow + throw (ProviderException) cause; + } + System.out.println("Caught expected Exception: \n" + cause2); + } + } + } +}