Changeset 309 for trunk/openjdk/jdk/src
- Timestamp:
- Feb 13, 2012, 10:07:12 PM (14 years ago)
- Location:
- trunk/openjdk
- Files:
-
- 74 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/openjdk
- Property svn:mergeinfo changed
/branches/vendor/oracle/openjdk6/b24 (added) merged: 308 /branches/vendor/oracle/openjdk6/current merged: 307
- Property svn:mergeinfo changed
-
trunk/openjdk/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java
r278 r309 1 1 /* 2 * Copyright (c) 2000, 20 06, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * -
trunk/openjdk/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGImageWriter.java
r278 r309 1 1 /* 2 * Copyright (c) 2000, 20 05, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * -
trunk/openjdk/jdk/src/share/classes/com/sun/imageio/plugins/png/PNGMetadata.java
r278 r309 1 1 /* 2 * Copyright (c) 2000, 20 01, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * -
trunk/openjdk/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java
r278 r309 1 1 /* 2 * Copyright (c) 2002, 20 07, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * -
trunk/openjdk/jdk/src/share/classes/com/sun/net/ssl/HttpsURLConnection.java
r278 r309 1 1 /* 2 * Copyright (c) 2000, 20 04, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 180 180 "no SSLSocketFactory specified"); 181 181 } 182 183 SecurityManager sm = System.getSecurityManager(); 184 if (sm != null) { 185 sm.checkSetFactory(); 186 } 187 182 188 sslSocketFactory = sf; 183 189 } -
trunk/openjdk/jdk/src/share/classes/com/sun/script/javascript/RhinoScriptEngine.java
r278 r309 1 1 /* 2 * Copyright (c) 2005, 20 06, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 30 30 import java.lang.reflect.Method; 31 31 import java.io.*; 32 import java.security.*; 32 33 import java.util.*; 33 34 … … 46 47 private static final boolean DEBUG = false; 47 48 49 private AccessControlContext accCtxt; 50 48 51 /* Scope where standard JavaScript objects and our 49 52 * extensions to it are stored. Note that these are not … … 64 67 static { 65 68 ContextFactory.initGlobal(new ContextFactory() { 69 /** 70 * Create new Context instance to be associated with the current thread. 71 */ 72 @Override 66 73 protected Context makeContext() { 67 74 Context cx = super.makeContext(); … … 69 76 cx.setWrapFactory(RhinoWrapFactory.getInstance()); 70 77 return cx; 78 } 79 80 81 /** 82 * Execute top call to script or function. When the runtime is about to 83 * execute a script or function that will create the first stack frame 84 * with scriptable code, it calls this method to perform the real call. 85 * In this way execution of any script happens inside this function. 86 */ 87 @Override 88 protected Object doTopCall(final Callable callable, 89 final Context cx, final Scriptable scope, 90 final Scriptable thisObj, final Object[] args) { 91 AccessControlContext accCtxt = null; 92 Scriptable global = ScriptableObject.getTopLevelScope(scope); 93 Scriptable globalProto = global.getPrototype(); 94 if (globalProto instanceof RhinoTopLevel) { 95 accCtxt = ((RhinoTopLevel)globalProto).getAccessContext(); 96 } 97 98 if (accCtxt != null) { 99 return AccessController.doPrivileged(new PrivilegedAction<Object>() { 100 public Object run() { 101 return superDoTopCall(callable, cx, scope, thisObj, args); 102 } 103 }, accCtxt); 104 } else { 105 return superDoTopCall(callable, cx, scope, thisObj, args); 106 } 107 } 108 109 private Object superDoTopCall(Callable callable, 110 Context cx, Scriptable scope, 111 Scriptable thisObj, Object[] args) { 112 return super.doTopCall(callable, cx, scope, thisObj, args); 71 113 } 72 114 … … 87 129 */ 88 130 public RhinoScriptEngine() { 131 132 if (System.getSecurityManager() != null) { 133 accCtxt = AccessController.getContext(); 134 } 89 135 90 136 Context cx = enterContext(); … … 315 361 } 316 362 363 AccessControlContext getAccessContext() { 364 return accCtxt; 365 } 366 317 367 Object[] wrapArguments(Object[] args) { 318 368 if (args == null) { -
trunk/openjdk/jdk/src/share/classes/com/sun/script/javascript/RhinoTopLevel.java
r278 r309 1 1 /* 2 * Copyright (c) 2005, 20 06, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 48 48 49 49 RhinoTopLevel(Context cx, RhinoScriptEngine engine) { 50 super(cx); 50 // second boolean parameter to super constructor tells whether 51 // to seal standard JavaScript objects or not. If security manager 52 // is present, we seal the standard objects. 53 super(cx, System.getSecurityManager() != null); 51 54 this.engine = engine; 52 55 … … 165 168 } 166 169 170 AccessControlContext getAccessContext() { 171 return engine.getAccessContext(); 172 } 173 167 174 private RhinoScriptEngine engine; 168 175 } -
trunk/openjdk/jdk/src/share/classes/java/awt/AWTEvent.java
r278 r309 1 1 /* 2 * Copyright (c) 1996, 20 07, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * -
trunk/openjdk/jdk/src/share/classes/java/awt/AWTKeyStroke.java
r278 r309 26 26 27 27 import java.awt.event.KeyEvent; 28 import sun.awt.AppContext; 28 29 import java.awt.event.InputEvent; 29 30 import java.util.Collections; … … 67 68 static final long serialVersionUID = -6430539691155161871L; 68 69 69 private static Map cache;70 private static AWTKeyStroke cacheKey;71 private static Constructor ctor = getCtor(AWTKeyStroke.class);72 70 private static Map modifierKeywords; 73 71 /** … … 77 75 */ 78 76 private static VKCollection vks; 77 78 //A key for the collection of AWTKeyStrokes within AppContext. 79 private static Object APP_CONTEXT_CACHE_KEY = new Object(); 80 //A key withing the cache 81 private static AWTKeyStroke APP_CONTEXT_KEYSTROKE_KEY = new AWTKeyStroke(); 82 83 /* 84 * Reads keystroke class from AppContext and if null, puts there the 85 * AWTKeyStroke class. 86 * Must be called under locked AWTKeyStroke.class 87 */ 88 private static Class getAWTKeyStrokeClass() { 89 Class clazz = (Class)AppContext.getAppContext().get(AWTKeyStroke.class); 90 if (clazz == null) { 91 clazz = AWTKeyStroke.class; 92 AppContext.getAppContext().put(AWTKeyStroke.class, AWTKeyStroke.class); 93 } 94 return clazz; 95 } 79 96 80 97 private char keyChar = KeyEvent.CHAR_UNDEFINED; … … 165 182 throw new IllegalArgumentException("subclass cannot be null"); 166 183 } 167 if (AWTKeyStroke.ctor.getDeclaringClass().equals(subclass)) { 168 // Already registered 169 return; 184 synchronized (AWTKeyStroke.class) { 185 Class keyStrokeClass = (Class)AppContext.getAppContext().get(AWTKeyStroke.class); 186 if (keyStrokeClass != null && keyStrokeClass.equals(subclass)){ 187 // Already registered 188 return; 189 } 170 190 } 171 191 if (!AWTKeyStroke.class.isAssignableFrom(subclass)) { … … 198 218 199 219 synchronized (AWTKeyStroke.class) { 200 A WTKeyStroke.ctor = ctor;201 cache = null;202 cacheKey = null;220 AppContext.getAppContext().put(AWTKeyStroke.class, subclass); 221 AppContext.getAppContext().remove(APP_CONTEXT_CACHE_KEY); 222 AppContext.getAppContext().remove(APP_CONTEXT_KEYSTROKE_KEY); 203 223 } 204 224 } … … 230 250 (char keyChar, int keyCode, int modifiers, boolean onKeyRelease) 231 251 { 252 Map cache = (Map)AppContext.getAppContext().get(APP_CONTEXT_CACHE_KEY); 253 AWTKeyStroke cacheKey = (AWTKeyStroke)AppContext.getAppContext().get(APP_CONTEXT_KEYSTROKE_KEY); 254 232 255 if (cache == null) { 233 256 cache = new HashMap(); 257 AppContext.getAppContext().put(APP_CONTEXT_CACHE_KEY, cache); 234 258 } 235 259 236 260 if (cacheKey == null) { 237 261 try { 238 cacheKey = (AWTKeyStroke)ctor.newInstance((Object[]) null); 262 Class clazz = getAWTKeyStrokeClass(); 263 cacheKey = (AWTKeyStroke)getCtor(clazz).newInstance((Object[]) null); 264 AppContext.getAppContext().put(APP_CONTEXT_KEYSTROKE_KEY, cacheKey); 239 265 } catch (InstantiationException e) { 240 266 assert(false); … … 254 280 stroke = cacheKey; 255 281 cache.put(stroke, stroke); 256 cacheKey = null; 257 } 258 282 AppContext.getAppContext().remove(APP_CONTEXT_KEYSTROKE_KEY); 283 } 259 284 return stroke; 260 285 } … … 776 801 synchronized (AWTKeyStroke.class) { 777 802 Class newClass = getClass(); 778 if (!newClass.equals(ctor.getDeclaringClass())) { 803 Class awtKeyStrokeClass = getAWTKeyStrokeClass(); 804 if (!newClass.equals(awtKeyStrokeClass)) { 779 805 registerSubclass(newClass); 780 806 } -
trunk/openjdk/jdk/src/share/classes/java/awt/Component.java
r278 r309 1 1 /* 2 * Copyright (c) 1995, 20 07, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * -
trunk/openjdk/jdk/src/share/classes/java/awt/EventDispatchThread.java
r278 r309 1 1 /* 2 * Copyright (c) 1996, 20 07, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * -
trunk/openjdk/jdk/src/share/classes/java/awt/EventQueue.java
r278 r309 1 1 /* 2 * Copyright (c) 1996, 20 07, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * -
trunk/openjdk/jdk/src/share/classes/java/awt/MenuComponent.java
r278 r309 1 1 /* 2 * Copyright (c) 1995, 20 06, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * -
trunk/openjdk/jdk/src/share/classes/java/awt/TrayIcon.java
r278 r309 1 1 /* 2 * Copyright (c) 2005, 20 06, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * -
trunk/openjdk/jdk/src/share/classes/java/io/InputStream.java
r278 r309 1 1 /* 2 * Copyright (c) 1994, 20 06, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 45 45 public abstract class InputStream implements Closeable { 46 46 47 // SKIP_BUFFER_SIZE is used to determine the size of skipBuffer 48 private static final int SKIP_BUFFER_SIZE = 2048; 49 // skipBuffer is initialized in skip(long), if needed. 50 private static byte[] skipBuffer; 47 // MAX_SKIP_BUFFER_SIZE is used to determine the maximum buffer skip to 48 // use when skipping. 49 private static final int MAX_SKIP_BUFFER_SIZE = 2048; 51 50 52 51 /** … … 213 212 long remaining = n; 214 213 int nr; 215 if (skipBuffer == null)216 skipBuffer = new byte[SKIP_BUFFER_SIZE];217 218 byte[] localSkipBuffer = skipBuffer;219 214 220 215 if (n <= 0) { … … 222 217 } 223 218 219 int size = (int)Math.min(MAX_SKIP_BUFFER_SIZE, remaining); 220 byte[] skipBuffer = new byte[size]; 224 221 while (remaining > 0) { 225 nr = read(localSkipBuffer, 0, 226 (int) Math.min(SKIP_BUFFER_SIZE, remaining)); 222 nr = read(skipBuffer, 0, (int)Math.min(size, remaining)); 227 223 if (nr < 0) { 228 224 break; -
trunk/openjdk/jdk/src/share/classes/java/net/AbstractPlainDatagramSocketImpl.java
r278 r309 1 1 /* 2 * Copyright (c) 1996, 20 07, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * -
trunk/openjdk/jdk/src/share/classes/java/net/AbstractPlainSocketImpl.java
r278 r309 1 1 /* 2 * Copyright (c) 1995, 20 07, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * -
trunk/openjdk/jdk/src/share/classes/java/net/NetworkInterface.java
r278 r309 531 531 result += " (" + displayName + ")"; 532 532 } 533 result += " index: "+index+" addresses:\n";534 for (Enumeration e = getInetAddresses(); e.hasMoreElements(); ) {535 InetAddress addr = (InetAddress)e.nextElement();536 result += addr+";\n";537 }538 533 return result; 539 534 } 535 540 536 private static native void init(); 541 542 537 } -
trunk/openjdk/jdk/src/share/classes/java/security/AccessControlContext.java
r278 r309 1 1 /* 2 * Copyright (c) 1997, 20 08, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * -
trunk/openjdk/jdk/src/share/classes/java/security/SignedObject.java
r278 r309 1 1 /* 2 * Copyright (c) 1997, 20 03, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 250 250 */ 251 251 private void readObject(java.io.ObjectInputStream s) 252 throws java.io.IOException, ClassNotFoundException253 {254 s.defaultReadObject();255 content = content.clone();256 signature = signature.clone();252 throws java.io.IOException, ClassNotFoundException { 253 java.io.ObjectInputStream.GetField fields = s.readFields(); 254 content = ((byte[])fields.get("content", null)).clone(); 255 signature = ((byte[])fields.get("signature", null)).clone(); 256 thealgorithm = (String)fields.get("thealgorithm", null); 257 257 } 258 258 } -
trunk/openjdk/jdk/src/share/classes/java/sql/Timestamp.java
r278 r309 489 489 */ 490 490 public int compareTo(Timestamp ts) { 491 int i = super.compareTo(ts); 491 long thisTime = this.getTime(); 492 long anotherTime = ts.getTime(); 493 int i = (thisTime<anotherTime ? -1 :(thisTime==anotherTime?0 :1)); 492 494 if (i == 0) { 493 495 if (nanos > ts.nanos) { -
trunk/openjdk/jdk/src/share/classes/javax/net/ssl/HttpsURLConnection.java
r278 r309 1 1 /* 2 * Copyright (c) 1999, 20 05, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 369 369 } 370 370 371 SecurityManager sm = System.getSecurityManager(); 372 if (sm != null) { 373 sm.checkSetFactory(); 374 } 371 375 sslSocketFactory = sf; 372 376 } -
trunk/openjdk/jdk/src/share/classes/javax/swing/ImageIcon.java
r278 r309 37 37 import javax.accessibility.*; 38 38 39 import sun.awt.AppContext; 40 import java.lang.reflect.Field; 41 import java.security.*; 39 42 40 43 /** … … 76 79 String description = null; 77 80 78 protected final static Component component = new Component() {}; 79 protected final static MediaTracker tracker = new MediaTracker(component); 81 // Fields for twisted backward compatibility only. DO NOT USE. 82 protected final static Component component; 83 protected final static MediaTracker tracker; 84 85 static { 86 component = AccessController.doPrivileged(new PrivilegedAction<Component>() { 87 public Component run() { 88 89 try { 90 final Component component = createNoPermsComponent(); 91 92 // 6482575 - clear the appContext field so as not to leak it 93 Field appContextField = 94 95 Component.class.getDeclaredField("appContext"); 96 appContextField.setAccessible(true); 97 appContextField.set(component, null); 98 99 return component; 100 } catch (Throwable e) { 101 // We don't care about component. 102 // So don't prevent class initialisation. 103 e.printStackTrace(); 104 105 return null; 106 } 107 } 108 }); 109 tracker = new MediaTracker(component); 110 } 111 112 private static Component createNoPermsComponent() { 113 // 7020198 - set acc field to no permissions and no subject 114 // Note, will have appContext set. 115 return AccessController.doPrivileged( 116 new PrivilegedAction<Component>() { 117 public Component run() { 118 return new Component() { 119 }; 120 } 121 }, 122 new AccessControlContext(new ProtectionDomain[]{ 123 new ProtectionDomain(null, null) 124 }) 125 ); 126 } 80 127 81 128 /** … … 83 130 */ 84 131 private static int mediaTrackerID; 132 133 private final static Object TRACKER_KEY = new StringBuilder("TRACKER_KEY"); 85 134 86 135 int width = -1; … … 244 293 */ 245 294 protected void loadImage(Image image) { 246 synchronized(tracker) { 295 MediaTracker mTracker = getTracker(); 296 synchronized(mTracker) { 247 297 int id = getNextID(); 248 298 249 tracker.addImage(image, id);299 mTracker.addImage(image, id); 250 300 try { 251 tracker.waitForID(id, 0);301 mTracker.waitForID(id, 0); 252 302 } catch (InterruptedException e) { 253 303 System.out.println("INTERRUPTED while loading Image"); 254 304 } 255 loadStatus = tracker.statusID(id, false);256 tracker.removeImage(image, id);305 loadStatus = mTracker.statusID(id, false); 306 mTracker.removeImage(image, id); 257 307 258 308 width = image.getWidth(imageObserver); … … 265 315 */ 266 316 private int getNextID() { 267 synchronized( tracker) {317 synchronized(getTracker()) { 268 318 return ++mediaTrackerID; 269 319 } 320 } 321 322 /** 323 * Returns the MediaTracker for the current AppContext, creating a new 324 * MediaTracker if necessary. 325 */ 326 private MediaTracker getTracker() { 327 Object trackerObj; 328 AppContext ac = AppContext.getAppContext(); 329 // Opt: Only synchronize if trackerObj comes back null? 330 // If null, synchronize, re-check for null, and put new tracker 331 synchronized (ac) { 332 trackerObj = ac.get(TRACKER_KEY); 333 if (trackerObj == null) { 334 Component comp = new Component() { 335 }; 336 trackerObj = new MediaTracker(comp); 337 ac.put(TRACKER_KEY, trackerObj); 338 } 339 } 340 return (MediaTracker) trackerObj; 270 341 } 271 342 -
trunk/openjdk/jdk/src/share/classes/javax/swing/Timer.java
r278 r309 1 1 /* 2 * Copyright (c) 1997, 20 06, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * -
trunk/openjdk/jdk/src/share/classes/javax/swing/TransferHandler.java
r278 r309 1 1 /* 2 * Copyright (c) 2000, 20 06, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * -
trunk/openjdk/jdk/src/share/classes/sun/awt/SunToolkit.java
r278 r309 71 71 /* Load debug settings for native code */ 72 72 static { 73 String nativeDebug = System.getProperty("sun.awt.nativedebug"); 74 if ("true".equalsIgnoreCase(nativeDebug)) { 73 if (AccessController.doPrivileged(new GetBooleanAction("sun.awt.nativedebug"))) { 75 74 DebugSettings.init(); 76 75 } -
trunk/openjdk/jdk/src/share/classes/sun/font/FileFont.java
r278 r309 1 1 /* 2 * Copyright (c) 2003, 20 08, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * -
trunk/openjdk/jdk/src/share/classes/sun/font/TrueTypeFont.java
r278 r309 1 1 /* 2 * Copyright (c) 2003, 20 06, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * -
trunk/openjdk/jdk/src/share/classes/sun/font/Type1Font.java
r278 r309 1 1 /* 2 * Copyright (c) 2003, 20 05, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * -
trunk/openjdk/jdk/src/share/classes/sun/java2d/pipe/DrawImage.java
r278 r309 510 510 */ 511 511 int edges[] = new int[(dy2-dy1)*2+2]; 512 // It is important that edges[0]=edges[1]=0 when we call 513 // Transform in case it must return early and we would 514 // not want to render anything on an error condition. 512 515 helper.Transform(tmpmaskblit, srcData, tmpData, 513 516 AlphaComposite.Src, null, -
trunk/openjdk/jdk/src/share/classes/sun/misc/FloatingDecimal.java
r278 r309 1 1 /* 2 * Copyright (c) 1996, 20 04, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * -
trunk/openjdk/jdk/src/share/classes/sun/misc/SharedSecrets.java
r278 r309 1 1 /* 2 * Copyright (c) 2002, 201 0, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * -
trunk/openjdk/jdk/src/share/classes/sun/net/ResourceManager.java
r278 r309 42 42 /* default maximum number of udp sockets per VM 43 43 * when a security manager is enabled. 44 * The default is 1024which is high enough to be useful44 * The default is 25 which is high enough to be useful 45 45 * but low enough to be well below the maximum number 46 * of port numbers actually available on all OSes for 47 * such sockets (5000 on some versions of windows) 46 * of port numbers actually available on all OSes 47 * when multiplied by the maximum feasible number of VM processes 48 * that could practically be spawned. 48 49 */ 49 50 50 private static final int DEFAULT_MAX_SOCKETS = 1024;51 private static final int DEFAULT_MAX_SOCKETS = 25; 51 52 private static final int maxSockets; 52 53 private static final AtomicInteger numSockets; -
trunk/openjdk/jdk/src/share/classes/sun/nio/ch/DatagramChannelImpl.java
r278 r309 1 1 /* 2 * Copyright (c) 2001, 20 06, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * -
trunk/openjdk/jdk/src/share/classes/sun/nio/ch/Net.java
r278 r309 1 1 /* 2 * Copyright (c) 2000, 20 05, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * -
trunk/openjdk/jdk/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java
r278 r309 1 1 /* 2 * Copyright (c) 2003, 20 04, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 41 41 */ 42 42 class AnnotationInvocationHandler implements InvocationHandler, Serializable { 43 private static final long serialVersionUID = 6182022883658399397L; 43 44 private final Class type; 44 45 private final Map<String, Object> memberValues; -
trunk/openjdk/jdk/src/share/classes/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java
r278 r309 1 1 /* 2 * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 35 35 */ 36 36 class AnnotationTypeMismatchExceptionProxy extends ExceptionProxy { 37 private static final long serialVersionUID = 7844069490309503934L; 37 38 private Method member; 38 39 private String foundType; -
trunk/openjdk/jdk/src/share/classes/sun/reflect/annotation/EnumConstantNotPresentExceptionProxy.java
r278 r309 1 1 /* 2 * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 34 34 */ 35 35 public class EnumConstantNotPresentExceptionProxy extends ExceptionProxy { 36 private static final long serialVersionUID = -604662101303187330L; 36 37 Class<? extends Enum> enumType; 37 38 String constName; -
trunk/openjdk/jdk/src/share/classes/sun/reflect/annotation/TypeNotPresentExceptionProxy.java
r278 r309 1 1 /* 2 * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 34 34 */ 35 35 public class TypeNotPresentExceptionProxy extends ExceptionProxy { 36 private static final long serialVersionUID = 5565925172427947573L; 36 37 String typeName; 37 38 Throwable cause; -
trunk/openjdk/jdk/src/share/classes/sun/rmi/registry/RegistryImpl.java
r278 r309 1 1 /* 2 * Copyright (c) 1996, 20 06, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 39 39 import java.rmi.server.RMIClientSocketFactory; 40 40 import java.rmi.server.RMIServerSocketFactory; 41 import java.security.AccessControlContext; 42 import java.security.AccessController; 43 import java.security.CodeSource; 44 import java.security.Policy; 41 45 import java.security.PrivilegedActionException; 46 import java.security.PrivilegedExceptionAction; 47 import java.security.PermissionCollection; 48 import java.security.Permissions; 49 import java.security.ProtectionDomain; 42 50 import java.text.MessageFormat; 51 import sun.rmi.server.LoaderHandler; 43 52 import sun.rmi.server.UnicastServerRef; 44 53 import sun.rmi.server.UnicastServerRef2; … … 46 55 import sun.rmi.transport.ObjectTable; 47 56 import sun.rmi.transport.Target; 57 import sun.security.action.GetPropertyAction; 48 58 49 59 /** … … 325 335 ClassLoader cl = new URLClassLoader(urls); 326 336 337 String codebaseProperty = null; 338 String prop = java.security.AccessController.doPrivileged( 339 new GetPropertyAction("java.rmi.server.codebase")); 340 if (prop != null && prop.trim().length() > 0) { 341 codebaseProperty = prop; 342 } 343 URL[] codebaseURLs = null; 344 if (codebaseProperty != null) { 345 codebaseURLs = sun.misc.URLClassPath.pathToURLs(codebaseProperty); 346 } else { 347 codebaseURLs = new URL[0]; 348 } 349 327 350 /* 328 351 * Fix bugid 4242317: Classes defined by this class loader should … … 334 357 Thread.currentThread().setContextClassLoader(cl); 335 358 336 int regPort = Registry.REGISTRY_PORT; 337 if (args.length >= 1) { 338 regPort = Integer.parseInt(args[0]); 339 } 340 registry = new RegistryImpl(regPort); 359 final int regPort = (args.length >= 1) ? Integer.parseInt(args[0]) 360 : Registry.REGISTRY_PORT; 361 try { 362 registry = AccessController.doPrivileged( 363 new PrivilegedExceptionAction<RegistryImpl>() { 364 public RegistryImpl run() throws RemoteException { 365 return new RegistryImpl(regPort); 366 } 367 }, getAccessControlContext(codebaseURLs)); 368 } catch (PrivilegedActionException ex) { 369 throw (RemoteException) ex.getException(); 370 } 371 341 372 // prevent registry from exiting 342 373 while (true) { … … 358 389 System.exit(1); 359 390 } 391 392 /** 393 * Generates an AccessControlContext from several URLs. 394 * The approach used here is taken from the similar method 395 * getAccessControlContext() in the sun.applet.AppletPanel class. 396 */ 397 private static AccessControlContext getAccessControlContext(URL[] urls) { 398 // begin with permissions granted to all code in current policy 399 PermissionCollection perms = AccessController.doPrivileged( 400 new java.security.PrivilegedAction<PermissionCollection>() { 401 public PermissionCollection run() { 402 CodeSource codesource = new CodeSource(null, 403 (java.security.cert.Certificate[]) null); 404 Policy p = java.security.Policy.getPolicy(); 405 if (p != null) { 406 return p.getPermissions(codesource); 407 } else { 408 return new Permissions(); 409 } 410 } 411 }); 412 413 /* 414 * Anyone can connect to the registry and the registry can connect 415 * to and possibly download stubs from anywhere. Downloaded stubs and 416 * related classes themselves are more tightly limited by RMI. 417 */ 418 perms.add(new SocketPermission("*", "connect,accept")); 419 420 perms.add(new RuntimePermission("accessClassInPackage.sun.*")); 421 422 // add permissions required to load from codebase URL path 423 LoaderHandler.addPermissionsForURLs(urls, perms, false); 424 425 /* 426 * Create an AccessControlContext that consists of a single 427 * protection domain with only the permissions calculated above. 428 */ 429 ProtectionDomain pd = new ProtectionDomain( 430 new CodeSource((urls.length > 0 ? urls[0] : null), 431 (java.security.cert.Certificate[]) null), 432 perms); 433 return new AccessControlContext(new ProtectionDomain[] { pd }); 434 } 360 435 } -
trunk/openjdk/jdk/src/share/classes/sun/rmi/server/LoaderHandler.java
r278 r309 1 1 /* 2 * Copyright (c) 1996, 20 05, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 1029 1029 * it is not already implied by the collection. 1030 1030 */ 1031 p rivatestatic void addPermissionsForURLs(URL[] urls,1031 public static void addPermissionsForURLs(URL[] urls, 1032 1032 PermissionCollection perms, 1033 1033 boolean forLoader) -
trunk/openjdk/jdk/src/share/classes/sun/rmi/server/UnicastServerRef.java
r278 r309 1 1 /* 2 * Copyright (c) 1996, 20 05, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 391 391 try { 392 392 in = call.getInputStream(); 393 try { 394 Class<?> clazz = Class.forName("sun.rmi.transport.DGCImpl_Skel"); 395 if (clazz.isAssignableFrom(skel.getClass())) { 396 ((MarshalInputStream)in).useCodebaseOnly(); 397 } 398 } catch (ClassNotFoundException ignore) { } 393 399 hash = in.readLong(); 394 400 } catch (Exception readEx) { -
trunk/openjdk/jdk/src/share/classes/sun/security/jgss/spi/GSSContextSpi.java
r278 r309 25 25 26 26 /* 27 * ===========================================================================28 * IBM Confidential29 * OCO Source Materials30 * Licensed Materials - Property of IBM31 27 * 32 28 * (C) Copyright IBM Corp. 1999 All Rights Reserved. 33 *34 * The source code for this program is not published or otherwise divested of35 * its trade secrets, irrespective of what has been deposited with the U.S.36 * Copyright Office.37 *38 29 * Copyright 1997 The Open Group Research Institute. All rights reserved. 39 * ===========================================================================40 *41 30 */ 42 43 31 package sun.security.jgss.spi; 44 32 -
trunk/openjdk/jdk/src/share/classes/sun/security/jgss/spnego/NegTokenInit.java
r278 r309 1 1 /* 2 * Copyright (c) 2005, 200 6, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 67 67 private Oid[] mechTypeList = null; 68 68 69 private byte[]reqFlags = null;69 private BitArray reqFlags = null; 70 70 private byte[] mechToken = null; 71 71 private byte[] mechListMIC = null; 72 72 73 NegTokenInit(byte[] mechTypes, byte[]flags,73 NegTokenInit(byte[] mechTypes, BitArray flags, 74 74 byte[] token, byte[] mechListMIC) 75 75 { … … 102 102 if (reqFlags != null) { 103 103 DerOutputStream flags = new DerOutputStream(); 104 flags.put BitString(reqFlags);104 flags.putUnalignedBitString(reqFlags); 105 105 initToken.write(DerValue.createTag(DerValue.TAG_CONTEXT, 106 106 true, (byte) 0x01), flags); … … 238 238 } 239 239 240 byte[]getReqFlags() {240 BitArray getReqFlags() { 241 241 return reqFlags; 242 242 } -
trunk/openjdk/jdk/src/share/classes/sun/security/jgss/spnego/SpNegoContext.java
r278 r309 1 1 /* 2 * Copyright (c) 2005, 200 6, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 54 54 private int state = STATE_NEW; 55 55 56 private static final int CHECKSUM_DELEG_FLAG = 1;57 private static final int CHECKSUM_MUTUAL_FLAG = 2;58 private static final int CHECKSUM_REPLAY_FLAG = 4;59 private static final int CHECKSUM_SEQUENCE_FLAG = 8;60 private static final int CHECKSUM_CONF_FLAG = 16;61 private static final int CHECKSUM_INTEG_FLAG = 32;62 63 56 /* 64 57 * Optional features that the application can set and their default … … 701 694 * get the context flags 702 695 */ 703 private byte[] getContextFlags() { 704 int flags = 0; 705 706 if (getCredDelegState()) 707 flags |= CHECKSUM_DELEG_FLAG; 708 if (getMutualAuthState()) 709 flags |= CHECKSUM_MUTUAL_FLAG; 710 if (getReplayDetState()) 711 flags |= CHECKSUM_REPLAY_FLAG; 712 if (getSequenceDetState()) 713 flags |= CHECKSUM_SEQUENCE_FLAG; 714 if (getIntegState()) 715 flags |= CHECKSUM_INTEG_FLAG; 716 if (getConfState()) 717 flags |= CHECKSUM_CONF_FLAG; 718 719 byte[] temp = new byte[1]; 720 temp[0] = (byte)(flags & 0xff); 721 return temp; 696 private BitArray getContextFlags() { 697 BitArray out = new BitArray(7); 698 699 if (getCredDelegState()) out.set(0, true); 700 if (getMutualAuthState()) out.set(1, true); 701 if (getReplayDetState()) out.set(2, true); 702 if (getSequenceDetState()) out.set(3, true); 703 if (getConfState()) out.set(5, true); 704 if (getIntegState()) out.set(6, true); 705 706 return out; 722 707 } 723 708 -
trunk/openjdk/jdk/src/share/classes/sun/security/krb5/internal/ccache/CCacheInputStream.java
r278 r309 248 248 } 249 249 250 Ticket readData() throws IOException, RealmException, KrbApErrException, Asn1Exception {250 byte[] readData() throws IOException { 251 251 int length; 252 252 length = read(4); 253 if (length > 0) { 253 if (length == 0) { 254 return null; 255 } else { 254 256 byte[] bytes = new byte[length]; 255 257 read(bytes, 0, length); 256 Ticket ticket = new Ticket(bytes); 257 return ticket; 258 } 259 else return null; 258 return bytes; 259 } 260 260 } 261 261 … … 326 326 return flags; 327 327 } 328 329 /** 330 * Reads the next cred in stream. 331 * @return the next cred, null if ticket or second_ticket unparseable. 332 * 333 * Note: MIT krb5 1.8.1 might generate a config entry with server principal 334 * X-CACHECONF:/krb5_ccache_conf_data/fast_avail/krbtgt/REALM@REALM. The 335 * entry is used by KDC to inform the client that it support certain 336 * features. Its ticket is not a valid krb5 ticket and thus this method 337 * returns null. 338 */ 328 339 Credentials readCred(int version) throws IOException,RealmException, KrbApErrException, Asn1Exception { 329 340 PrincipalName cpname = readPrincipal(version); … … 361 372 auData = new AuthorizationData(auDataEntry); 362 373 } 363 Ticket ticket= readData();364 if (DEBUG) {365 System.out.println(">>>DEBUG <CCacheInputStream>"); 366 if (ticket == null){367 System.out.println("///ticket is null");368 }369 }370 Ticket secTicket = readData();371 Credentials cred = new Credentials(cpname, spname, key, authtime, starttime,372 endtime, renewTill, skey, tFlags,373 addrs, auData, ticket, secTicket);374 return cred;374 byte[] ticketData = readData(); 375 byte[] ticketData2 = readData(); 376 377 try { 378 return new Credentials(cpname, spname, key, authtime, starttime, 379 endtime, renewTill, skey, tFlags, 380 addrs, auData, 381 ticketData != null ? new Ticket(ticketData) : null, 382 ticketData2 != null ? new Ticket(ticketData2) : null); 383 } catch (Exception e) { // If any of new Ticket(*) fails. 384 return null; 385 } 375 386 } 376 387 } -
trunk/openjdk/jdk/src/share/classes/sun/security/krb5/internal/ccache/FileCredentialsCache.java
r278 r309 1 1 /* 2 * Copyright (c) 2000, 20 06, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 187 187 credentialsList = new Vector<Credentials> (); 188 188 while (cis.available() > 0) { 189 credentialsList.addElement(cis.readCred(version)); 189 Credentials cred = cis.readCred(version); 190 if (cred != null) { 191 credentialsList.addElement(cred); 192 } 190 193 } 191 194 cis.close(); -
trunk/openjdk/jdk/src/share/classes/sun/security/provider/SeedGenerator.java
r278 r309 1 1 /* 2 * Copyright (c) 1996, 20 06, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 136 136 } 137 137 138 void getSeedBytes(byte[] result) { 139 for (int i = 0; i < result.length; i++) { 140 result[i] = getSeedByte(); 141 } 142 } 143 144 abstract byte getSeedByte(); 138 abstract void getSeedBytes(byte[] result); 145 139 146 140 /** … … 337 331 } 338 332 } 333 334 @Override 335 void getSeedBytes(byte[] result) { 336 for (int i = 0; i < result.length; i++) { 337 result[i] = getSeedByte(); 338 } 339 } 339 340 340 341 byte getSeedByte() { … … 424 425 425 426 private String deviceName; 426 private BufferedInputStream devRandom; 427 427 private InputStream devRandom; 428 428 429 429 /** … … 447 447 private void init() throws IOException { 448 448 final URL device = new URL(deviceName); 449 devRandom = java.security.AccessController.doPrivileged 450 (new java.security.PrivilegedAction<BufferedInputStream>() { 451 public BufferedInputStream run() { 452 try { 453 return new BufferedInputStream(device.openStream()); 454 } catch (IOException ioe) { 455 return null; 449 try { 450 devRandom = java.security.AccessController.doPrivileged 451 (new java.security.PrivilegedExceptionAction<InputStream>() { 452 public InputStream run() throws IOException { 453 /* 454 * return a FileInputStream for file URLs and 455 * avoid buffering. The openStream() call wraps 456 * InputStream in a BufferedInputStream which 457 * can buffer up to 8K bytes. This read is a 458 * performance issue for entropy sources which 459 * can be slow to replenish. 460 */ 461 if (device.getProtocol().equalsIgnoreCase("file")) { 462 File deviceFile = getDeviceFile(device); 463 return new FileInputStream(deviceFile); 464 } else { 465 return device.openStream(); 456 466 } 457 467 } 458 468 }); 459 460 if (devRandom == null) { 461 throw new IOException("failed to open " + device); 462 } 463 } 464 465 byte getSeedByte() { 466 byte b[] = new byte[1]; 467 int stat; 468 try { 469 stat = devRandom.read(b, 0, b.length); 469 } catch (Exception e) { 470 throw new IOException("Failed to open " + deviceName, e.getCause()); 471 } 472 } 473 474 /* 475 * Use a URI to access this File. Previous code used a URL 476 * which is less strict on syntax. If we encounter a 477 * URISyntaxException we make best efforts for backwards 478 * compatibility. e.g. space character in deviceName string. 479 * 480 * Method called within PrivilegedExceptionAction block. 481 */ 482 private File getDeviceFile(URL device) throws IOException { 483 try { 484 URI deviceURI = device.toURI(); 485 if(deviceURI.isOpaque()) { 486 // File constructor does not accept opaque URI 487 URI localDir = new File(System.getProperty("user.dir")).toURI(); 488 String uriPath = localDir.toString() + 489 deviceURI.toString().substring(5); 490 return new File(URI.create(uriPath)); 491 } else { 492 return new File(deviceURI); 493 } 494 } catch (URISyntaxException use) { 495 /* 496 * Make best effort to access this File. 497 * We can try using the URL path. 498 */ 499 return new File(device.getPath()); 500 } 501 } 502 503 @Override 504 void getSeedBytes(byte[] result) { 505 int len = result.length; 506 int read = 0; 507 try { 508 while (read < len) { 509 int count = devRandom.read(result, read, len - read); 510 // /dev/random blocks - should never have EOF 511 if (count < 0) 512 throw new InternalError("URLSeedGenerator " + deviceName + 513 " reached end of file"); 514 read += count; 515 } 470 516 } catch (IOException ioe) { 471 517 throw new InternalError("URLSeedGenerator " + deviceName + … … 473 519 ioe.getMessage()); 474 520 } 475 if (stat == b.length) { 476 return b[0]; 477 } else if (stat == -1) { 478 throw new InternalError("URLSeedGenerator " + deviceName + 479 " reached end of file"); 480 } else { 481 throw new InternalError("URLSeedGenerator " + deviceName + 482 " failed read"); 483 } 484 } 485 521 } 486 522 } 487 523 -
trunk/openjdk/jdk/src/share/classes/sun/security/ssl/AppOutputStream.java
r278 r309 1 1 /* 2 * Copyright (c) 1996, 20 07,Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1996, 20111 Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 61 61 // check if the Socket is invalid (error or closed) 62 62 c.checkWrite(); 63 // 64 // Always flush at the end of each application level record. 65 // This lets application synchronize read and write streams 66 // however they like; if we buffered here, they couldn't. 67 // 68 // NOTE: *must* call c.writeRecord() even for len == 0 63 64 /* 65 * By default, we counter chosen plaintext issues on CBC mode 66 * ciphersuites in SSLv3/TLS1.0 by sending one byte of application 67 * data in the first record of every payload, and the rest in 68 * subsequent record(s). Note that the issues have been solved in 69 * TLS 1.1 or later. 70 * 71 * It is not necessary to split the very first application record of 72 * a freshly negotiated TLS session, as there is no previous 73 * application data to guess. To improve compatibility, we will not 74 * split such records. 75 * 76 * This avoids issues in the outbound direction. For a full fix, 77 * the peer must have similar protections. 78 */ 79 boolean isFirstRecordOfThePayload = true; 80 81 /* 82 * Always flush at the end of each application level record. 83 * This lets application synchronize read and write streams 84 * however they like; if we buffered here, they couldn't. 85 * 86 * NOTE: *must* call c.writeRecord() even for len == 0 87 */ 88 69 89 try { 70 90 do { 71 int howmuch = Math.min(len, r.availableDataBytes()); 91 int howmuch; 92 if (isFirstRecordOfThePayload && c.needToSplitPayload()) { 93 howmuch = Math.min(0x01, r.availableDataBytes()); 94 } else { 95 howmuch = Math.min(len, r.availableDataBytes()); 96 } 97 98 if (isFirstRecordOfThePayload && howmuch != 0) { 99 isFirstRecordOfThePayload = false; 100 } 72 101 73 102 if (howmuch > 0) { -
trunk/openjdk/jdk/src/share/classes/sun/security/ssl/CipherBox.java
r278 r309 1 1 /* 2 * Copyright (c) 1996, 20 07, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 77 77 78 78 /** 79 * Is the cipher of CBC mode? 80 */ 81 private final boolean isCBCMode; 82 83 /** 79 84 * NULL cipherbox. Identity operation, no encryption. 80 85 */ … … 82 87 this.protocolVersion = ProtocolVersion.DEFAULT; 83 88 this.cipher = null; 89 this.isCBCMode = false; 84 90 } 85 91 … … 97 103 this.cipher = JsseJce.getCipher(bulkCipher.transformation); 98 104 int mode = encrypt ? Cipher.ENCRYPT_MODE : Cipher.DECRYPT_MODE; 105 this.isCBCMode = bulkCipher.isCBCMode; 99 106 cipher.init(mode, key, iv); 100 107 // do not call getBlockSize until after init() … … 487 494 return newlen; 488 495 } 496 497 /* 498 * Does the cipher use CBC mode? 499 * 500 * @return true if the cipher use CBC mode, false otherwise. 501 */ 502 boolean isCBCMode() { 503 return isCBCMode; 504 } 489 505 } -
trunk/openjdk/jdk/src/share/classes/sun/security/ssl/CipherSuite.java
r278 r309 1 1 /* 2 * Copyright (c) 2002, 201 0, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 341 341 final boolean exportable; 342 342 343 // Is the cipher algorithm of Cipher Block Chaining (CBC) mode? 344 final boolean isCBCMode; 345 343 346 BulkCipher(String transformation, int keySize, 344 347 int expandedKeySize, int ivSize, boolean allowed) { 345 348 this.transformation = transformation; 346 this.algorithm = transformation.split("/")[0]; 349 String[] splits = transformation.split("/"); 350 this.algorithm = splits[0]; 351 this.isCBCMode = 352 splits.length <= 1 ? false : "CBC".equalsIgnoreCase(splits[1]); 347 353 this.description = this.algorithm + "/" + (keySize << 3); 348 354 this.keySize = keySize; … … 357 363 int ivSize, boolean allowed) { 358 364 this.transformation = transformation; 359 this.algorithm = transformation.split("/")[0]; 365 String[] splits = transformation.split("/"); 366 this.algorithm = splits[0]; 367 this.isCBCMode = 368 splits.length <= 1 ? false : "CBC".equalsIgnoreCase(splits[1]); 360 369 this.description = this.algorithm + "/" + (keySize << 3); 361 370 this.keySize = keySize; -
trunk/openjdk/jdk/src/share/classes/sun/security/ssl/EngineOutputRecord.java
r278 r309 1 1 /* 2 * Copyright (c) 2003, 20 07, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 47 47 final class EngineOutputRecord extends OutputRecord { 48 48 49 private SSLEngineImpl engine; 49 50 private EngineWriter writer; 50 51 … … 63 64 EngineOutputRecord(byte type, SSLEngineImpl engine) { 64 65 super(type, recordSize(type)); 66 this.engine = engine; 65 67 writer = engine.writer; 66 68 } … … 228 230 * records, so this increases robustness. 229 231 */ 230 int length = Math.min(ea.getAppRemaining(), maxDataSize); 231 if (length == 0) { 232 if (ea.getAppRemaining() == 0) { 232 233 return; 233 234 } 234 235 236 /* 237 * By default, we counter chosen plaintext issues on CBC mode 238 * ciphersuites in SSLv3/TLS1.0 by sending one byte of application 239 * data in the first record of every payload, and the rest in 240 * subsequent record(s). Note that the issues have been solved in 241 * TLS 1.1 or later. 242 * 243 * It is not necessary to split the very first application record of 244 * a freshly negotiated TLS session, as there is no previous 245 * application data to guess. To improve compatibility, we will not 246 * split such records. 247 * 248 * Because of the compatibility, we'd better produce no more than 249 * SSLSession.getPacketBufferSize() net data for each wrap. As we 250 * need a one-byte record at first, the 2nd record size should be 251 * equal to or less than Record.maxDataSizeMinusOneByteRecord. 252 * 253 * This avoids issues in the outbound direction. For a full fix, 254 * the peer must have similar protections. 255 */ 256 int length; 257 if (engine.needToSplitPayload(writeCipher, protocolVersion)) { 258 write(ea, writeMAC, writeCipher, 0x01); 259 ea.resetLim(); // reset application data buffer limit 260 length = Math.min(ea.getAppRemaining(), 261 maxDataSizeMinusOneByteRecord); 262 } else { 263 length = Math.min(ea.getAppRemaining(), maxDataSize); 264 } 265 266 // Don't bother to really write empty records. 267 if (length > 0) { 268 write(ea, writeMAC, writeCipher, length); 269 } 270 271 return; 272 } 273 274 void write(EngineArgs ea, MAC writeMAC, CipherBox writeCipher, 275 int length) throws IOException { 235 276 /* 236 277 * Copy out existing buffer values. -
trunk/openjdk/jdk/src/share/classes/sun/security/ssl/Record.java
r278 r309 1 1 /* 2 * Copyright (c) 1996, 20 07, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 66 66 + trailerSize; // MAC 67 67 68 static final boolean enableCBCProtection = 69 Debug.getBooleanProperty("jsse.enableCBCProtection", true); 70 71 /* 72 * For CBC protection in SSL3/TLS1, we break some plaintext into two 73 * packets. Max application data size for the second packet. 74 */ 75 static final int maxDataSizeMinusOneByteRecord = 76 maxDataSize // max data size 77 - ( // max one byte record size 78 headerSize // header 79 + 1 // one byte data 80 + maxPadding // padding 81 + trailerSize // MAC 82 ); 83 68 84 /* 69 85 * The maximum large record size. -
trunk/openjdk/jdk/src/share/classes/sun/security/ssl/SSLEngineImpl.java
r278 r309 1 1 /* 2 * Copyright (c) 2003, 201 0, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 307 307 308 308 /* 309 * Is it the first application record to write? 310 */ 311 private boolean isFirstAppOutputRecord = true; 312 313 /* 309 314 * Class and subclass dynamic debugging support 310 315 */ … … 596 601 ("Algorithm missing: ").initCause(e); 597 602 } 603 604 // reset the flag of the first application record 605 isFirstAppOutputRecord = true; 598 606 } 599 607 … … 1213 1221 1214 1222 // eventually compress as well. 1215 return writer.writeRecord(eor, ea, writeMAC, writeCipher); 1223 HandshakeStatus hsStatus = 1224 writer.writeRecord(eor, ea, writeMAC, writeCipher); 1225 1226 /* 1227 * turn off the flag of the first application record if we really 1228 * consumed at least byte. 1229 */ 1230 if (isFirstAppOutputRecord && ea.deltaApp() > 0) { 1231 isFirstAppOutputRecord = false; 1232 } 1233 1234 return hsStatus; 1235 } 1236 1237 /* 1238 * Need to split the payload except the following cases: 1239 * 1240 * 1. protocol version is TLS 1.1 or later; 1241 * 2. bulk cipher does not use CBC mode, including null bulk cipher suites. 1242 * 3. the payload is the first application record of a freshly 1243 * negotiated TLS session. 1244 * 4. the CBC protection is disabled; 1245 * 1246 * More details, please refer to 1247 * EngineOutputRecord.write(EngineArgs, MAC, CipherBox). 1248 */ 1249 boolean needToSplitPayload(CipherBox cipher, ProtocolVersion protocol) { 1250 return (protocol.v <= ProtocolVersion.TLS10.v) && 1251 cipher.isCBCMode() && !isFirstAppOutputRecord && 1252 Record.enableCBCProtection; 1216 1253 } 1217 1254 -
trunk/openjdk/jdk/src/share/classes/sun/security/ssl/SSLSocketImpl.java
r278 r309 1 1 /* 2 * Copyright (c) 1996, 201 0, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 359 359 private static final Debug debug = Debug.getInstance("ssl"); 360 360 361 /* 362 * Is it the first application record to write? 363 */ 364 private boolean isFirstAppOutputRecord = true; 365 361 366 // 362 367 // CONSTRUCTORS AND INITIALIZATION CODE … … 762 767 r.encrypt(writeCipher); 763 768 r.write(sockOutput); 764 } 765 769 770 // turn off the flag of the first application record 771 if (isFirstAppOutputRecord && 772 r.contentType() == Record.ct_application_data) { 773 isFirstAppOutputRecord = false; 774 } 775 } 776 777 /* 778 * Need to split the payload except the following cases: 779 * 780 * 1. protocol version is TLS 1.1 or later; 781 * 2. bulk cipher does not use CBC mode, including null bulk cipher suites. 782 * 3. the payload is the first application record of a freshly 783 * negotiated TLS session. 784 * 4. the CBC protection is disabled; 785 * 786 * More details, please refer to AppOutputStream.write(byte[], int, int). 787 */ 788 boolean needToSplitPayload() { 789 writeLock.lock(); 790 try { 791 return (protocolVersion.v <= ProtocolVersion.TLS10.v) && 792 writeCipher.isCBCMode() && !isFirstAppOutputRecord && 793 Record.enableCBCProtection; 794 } finally { 795 writeLock.unlock(); 796 } 797 } 766 798 767 799 /* … … 1830 1862 ("Algorithm missing: ").initCause(e); 1831 1863 } 1864 1865 // reset the flag of the first application record 1866 isFirstAppOutputRecord = true; 1832 1867 } 1833 1868 -
trunk/openjdk/jdk/src/share/classes/sun/security/validator/EndEntityChecker.java
r278 r309 1 1 /* 2 * Copyright (c) 2002, 20 06, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * -
trunk/openjdk/jdk/src/share/classes/sun/swing/table/DefaultTableCellHeaderRenderer.java
r278 r309 1 1 /* 2 * Copyright (c) 2005, 20 06, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 25 25 package sun.swing.table; 26 26 27 import sun.swing.DefaultLookup; 28 27 29 import java.awt.Component; 28 30 import java.awt.Color; … … 32 34 import java.awt.Point; 33 35 import java.awt.Rectangle; 36 import java.io.Serializable; 34 37 import javax.swing.*; 35 38 import javax.swing.plaf.UIResource; 36 39 import javax.swing.border.Border; 37 40 import javax.swing.table.*; 38 import sun.swing.DefaultLookup;39 40 41 41 42 public class DefaultTableCellHeaderRenderer extends DefaultTableCellRenderer … … 187 188 } 188 189 189 private class EmptyIcon implements Icon {190 private class EmptyIcon implements Icon, Serializable { 190 191 int width = 0; 191 192 int height = 0; -
trunk/openjdk/jdk/src/share/native/com/sun/java/util/jar/pack/unpack.cpp
r278 r309 1 1 /* 2 * Copyright (c) 2001, 201 0, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 1089 1089 if (suffix == 0) continue; // done with empty string 1090 1090 chars.malloc(size3); 1091 CHECK; 1091 1092 byte* chp = chars.ptr; 1092 1093 band saved_band = cp_Utf8_big_chars; 1093 1094 cp_Utf8_big_chars.readData(suffix); 1095 CHECK; 1094 1096 for (int j = 0; j < suffix; j++) { 1095 1097 unsigned short ch = cp_Utf8_big_chars.getInt(); 1098 CHECK; 1096 1099 chp = store_Utf8_char(chp, ch); 1097 1100 } … … 1111 1114 int prevlen = 0; // previous string length (in chars) 1112 1115 tmallocs.add(bigbuf.ptr); // free after this block 1116 CHECK; 1113 1117 cp_Utf8_prefix.rewind(); 1114 1118 for (i = 0; i < len; i++) { 1115 1119 bytes& chars = allsuffixes[i]; 1116 1120 int prefix = (i < PREFIX_SKIP_2)? 0: cp_Utf8_prefix.getInt(); 1121 CHECK; 1117 1122 int suffix = chars.len; 1118 1123 byte* fillp; -
trunk/openjdk/jdk/src/share/native/com/sun/java/util/jar/pack/utils.cpp
r278 r309 1 1 /* 2 * Copyright (c) 2001, 20 08, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 53 53 msize = sizeof(int); // see 0xbaadf00d below 54 54 #endif 55 void* ptr = (msize > PSIZE_MAX ) ? null : malloc(msize);55 void* ptr = (msize > PSIZE_MAX || msize <= 0) ? null : malloc(msize); 56 56 if (ptr != null) { 57 57 memset(ptr, 0, size); -
trunk/openjdk/jdk/src/share/native/com/sun/java/util/jar/pack/utils.h
r278 r309 1 1 /* 2 * Copyright (c) 2001, 20 08, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 34 34 35 35 // overflow management 36 #define OVERFLOW (( size_t)-1)36 #define OVERFLOW ((uint)-1) 37 37 #define PSIZE_MAX (OVERFLOW/2) /* normal size limit */ 38 38 -
trunk/openjdk/jdk/src/share/native/sun/awt/image/jpeg/imageioJPEG.c
r278 r309 41 41 #include <assert.h> 42 42 #include <string.h> 43 #include <limits.h> 43 44 44 45 … … 1922 1923 1923 1924 // Allocate a 1-scanline buffer 1925 if (cinfo->num_components <= 0 || 1926 cinfo->image_width > (UINT_MAX / (unsigned int)cinfo->num_components)) 1927 { 1928 RELEASE_ARRAYS(env, data, src->next_input_byte); 1929 JNU_ThrowByName(env, "javax/imageio/IIOException", 1930 "Invalid number of color components"); 1931 return data->abortFlag; 1932 } 1924 1933 scanLinePtr = (JSAMPROW)malloc(cinfo->image_width*cinfo->num_components); 1925 1934 if (scanLinePtr == NULL) { -
trunk/openjdk/jdk/src/share/native/sun/font/layout/SunLayoutEngine.cpp
r278 r309 187 187 jchar* chars = buffer; 188 188 if (len > 256) { 189 chars = (jchar*)malloc(len * sizeof(jchar)); 189 size_t size = len * sizeof(jchar); 190 if (size / sizeof(jchar) != len) { 191 return; 192 } 193 chars = (jchar*)malloc(size); 190 194 if (chars == 0) { 191 195 return; -
trunk/openjdk/jdk/src/share/native/sun/java2d/loops/TransformHelper.c
r278 r309 1 1 /* 2 * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 76 76 77 77 /* 78 * The dxydxy parameters of the inverse transform determine how 79 * quickly we step through the source image. For tiny scale 80 * factors (on the order of 1E-16 or so) the stepping distances 81 * are huge. The image has been scaled so small that stepping 82 * a single pixel in device space moves the sampling point by 83 * billions (or more) pixels in the source image space. These 84 * huge stepping values can overflow the whole part of the longs 85 * we use for the fixed point stepping equations and so we need 86 * a more robust solution. We could simply iterate over every 87 * device pixel, use the inverse transform to transform it back 88 * into the source image coordinate system and then test it for 89 * being in range and sample pixel-by-pixel, but that is quite 90 * a bit more expensive. Fortunately, if the scale factors are 91 * so tiny that we overflow our long values then the number of 92 * pixels we are planning to visit should be very tiny. The only 93 * exception to that rule is if the scale factor along one 94 * dimension is tiny (creating the huge stepping values), and 95 * the scale factor along the other dimension is fairly regular 96 * or an up-scale. In that case we have a lot of pixels along 97 * the direction of the larger axis to sample, but few along the 98 * smaller axis. Though, pessimally, with an added shear factor 99 * such a linearly tiny image could have bounds that cover a large 100 * number of pixels. Such odd transformations should be very 101 * rare and the absolute limit on calculations would involve a 102 * single reverse transform of every pixel in the output image 103 * which is not fast, but it should not cause an undue stall 104 * of the rendering software. 105 * 106 * The specific test we will use is to calculate the inverse 107 * transformed values of every corner of the destination bounds 108 * (in order to be user-clip independent) and if we can 109 * perform a fixed-point-long inverse transform of all of 110 * those points without overflowing we will use the fast 111 * fixed point algorithm. Otherwise we will use the safe 112 * per-pixel transform algorithm. 113 * The 4 corners are 0,0, 0,dsth, dstw,0, dstw,dsth 114 * Transformed they are: 115 * tx, ty 116 * tx +dxdy*H, ty +dydy*H 117 * tx+dxdx*W, ty+dydx*W 118 * tx+dxdx*W+dxdy*H, ty+dydx*W+dydy*H 119 */ 120 /* We reject coordinates not less than 1<<30 so that the distance between */ 121 /* any 2 of them is less than 1<<31 which would overflow into the sign */ 122 /* bit of a signed long value used to represent fixed point coordinates. */ 123 #define TX_FIXED_UNSAFE(v) (fabs(v) >= (1<<30)) 124 static jboolean 125 checkOverflow(jint dxoff, jint dyoff, 126 SurfaceDataBounds *pBounds, 127 TransformInfo *pItxInfo, 128 jdouble *retx, jdouble *rety) 129 { 130 jdouble x, y; 131 132 x = dxoff+pBounds->x1+0.5; /* Center of pixel x1 */ 133 y = dyoff+pBounds->y1+0.5; /* Center of pixel y1 */ 134 Transform_transform(pItxInfo, &x, &y); 135 *retx = x; 136 *rety = y; 137 if (TX_FIXED_UNSAFE(x) || TX_FIXED_UNSAFE(y)) { 138 return JNI_TRUE; 139 } 140 141 x = dxoff+pBounds->x2-0.5; /* Center of pixel x2-1 */ 142 y = dyoff+pBounds->y1+0.5; /* Center of pixel y1 */ 143 Transform_transform(pItxInfo, &x, &y); 144 if (TX_FIXED_UNSAFE(x) || TX_FIXED_UNSAFE(y)) { 145 return JNI_TRUE; 146 } 147 148 x = dxoff+pBounds->x1+0.5; /* Center of pixel x1 */ 149 y = dyoff+pBounds->y2-0.5; /* Center of pixel y2-1 */ 150 Transform_transform(pItxInfo, &x, &y); 151 if (TX_FIXED_UNSAFE(x) || TX_FIXED_UNSAFE(y)) { 152 return JNI_TRUE; 153 } 154 155 x = dxoff+pBounds->x2-0.5; /* Center of pixel x2-1 */ 156 y = dyoff+pBounds->y2-0.5; /* Center of pixel y2-1 */ 157 Transform_transform(pItxInfo, &x, &y); 158 if (TX_FIXED_UNSAFE(x) || TX_FIXED_UNSAFE(y)) { 159 return JNI_TRUE; 160 } 161 162 return JNI_FALSE; 163 } 164 165 /* 78 166 * Fill the edge buffer with pairs of coordinates representing the maximum 79 167 * left and right pixels of the destination surface that should be processed … … 83 171 * source coordinate that falls within the (0, 0, sw, sh) bounds of the 84 172 * source image should be processed. 85 * pEdgeBuf points to an array of jints that holds MAXEDGES*2 values. 86 * If more storage is needed, then this function allocates a new buffer. 87 * In either case, a pointer to the buffer actually used to store the 88 * results is returned. 89 * The caller is responsible for freeing the buffer if the return value 90 * is not the same as the original pEdgeBuf passed in. 173 * pEdges points to an array of jints that holds 2 + numedges*2 values where 174 * numedges should match (pBounds->y2 - pBounds->y1). 175 * The first two jints in pEdges should be set to y1 and y2 and every pair 176 * of jints after that represent the xmin,xmax of all pixels in range of 177 * the transformed blit for the corresponding scanline. 91 178 */ 92 static jint *93 calculateEdges(jint *pEdge Buf,179 static void 180 calculateEdges(jint *pEdges, 94 181 SurfaceDataBounds *pBounds, 95 182 TransformInfo *pItxInfo, … … 97 184 juint sw, juint sh) 98 185 { 99 jint *pEdges;100 186 jlong dxdxlong, dydxlong; 101 187 jlong dxdylong, dydylong; … … 112 198 dx2 = pBounds->x2; 113 199 dy2 = pBounds->y2; 114 if ((dy2-dy1) > MAXEDGES) { 115 pEdgeBuf = malloc(2 * (dy2-dy1) * sizeof (*pEdges)); 116 } 117 pEdges = pEdgeBuf; 200 *pEdges++ = dy1; 201 *pEdges++ = dy2; 118 202 119 203 drowxlong = (dx2-dx1-1) * dxdxlong; … … 156 240 dy1++; 157 241 } 158 159 return pEdgeBuf;160 242 } 243 244 static void 245 Transform_SafeHelper(JNIEnv *env, 246 SurfaceDataOps *srcOps, 247 SurfaceDataOps *dstOps, 248 SurfaceDataRasInfo *pSrcInfo, 249 SurfaceDataRasInfo *pDstInfo, 250 NativePrimitive *pMaskBlitPrim, 251 CompositeInfo *pCompInfo, 252 TransformHelperFunc *pHelperFunc, 253 TransformInterpFunc *pInterpFunc, 254 RegionData *pClipInfo, TransformInfo *pItxInfo, 255 jint *pData, jint *pEdges, 256 jint dxoff, jint dyoff, jint sw, jint sh); 161 257 162 258 /* … … 188 284 TransformHelperFunc *pHelperFunc; 189 285 TransformInterpFunc *pInterpFunc; 190 jint edgebuf[MAXEDGES * 2]; 286 jdouble xorig, yorig; 287 jlong numedges; 191 288 jint *pEdges; 192 jdouble x, y; 193 jlong xbase, ybase; 194 jlong dxdxlong, dydxlong; 195 jlong dxdylong, dydylong; 289 jint edgebuf[2 + MAXEDGES * 2]; 290 union { 291 jlong align; 292 jint data[LINE_SIZE]; 293 } rgb; 196 294 197 295 #ifdef MAKE_STUBS … … 270 368 != SD_SUCCESS) 271 369 { 370 /* edgeArray should already contain zeros for min/maxy */ 272 371 return; 273 372 } … … 276 375 { 277 376 SurfaceData_InvokeUnlock(env, srcOps, &srcInfo); 377 /* edgeArray should already contain zeros for min/maxy */ 278 378 return; 279 379 } 280 380 Region_IntersectBounds(&clipInfo, &dstInfo.bounds); 281 381 382 numedges = (((jlong) dstInfo.bounds.y2) - ((jlong) dstInfo.bounds.y1)); 383 if (numedges <= 0) { 384 pEdges = NULL; 385 } else if (!JNU_IsNull(env, edgeArray)) { 386 /* 387 * Ideally Java should allocate an array large enough, but if 388 * we ever have a miscommunication about the number of edge 389 * lines, or if the Java array calculation should overflow to 390 * a positive number and succeed in allocating an array that 391 * is too small, we need to verify that it can still hold the 392 * number of integers that we plan to store to be safe. 393 */ 394 jsize edgesize = (*env)->GetArrayLength(env, edgeArray); 395 /* (edgesize/2 - 1) should avoid any overflow or underflow. */ 396 pEdges = (((edgesize / 2) - 1) >= numedges) 397 ? (*env)->GetPrimitiveArrayCritical(env, edgeArray, NULL) 398 : NULL; 399 } else if (numedges > MAXEDGES) { 400 /* numedges variable (jlong) can be at most ((1<<32)-1) */ 401 /* memsize can overflow a jint, but not a jlong */ 402 jlong memsize = ((numedges * 2) + 2) * sizeof(*pEdges); 403 pEdges = (memsize == ((size_t) memsize)) 404 ? malloc((size_t) memsize) 405 : NULL; 406 } else { 407 pEdges = edgebuf; 408 } 409 if (pEdges == NULL) { 410 if (numedges > 0) { 411 JNU_ThrowInternalError(env, "Unable to allocate edge list"); 412 } 413 SurfaceData_InvokeUnlock(env, dstOps, &dstInfo); 414 SurfaceData_InvokeUnlock(env, srcOps, &srcInfo); 415 /* edgeArray should already contain zeros for min/maxy */ 416 return; 417 } 418 282 419 Transform_GetInfo(env, itxform, &itxInfo); 283 dxdxlong = DblToLong(itxInfo.dxdx);284 dydxlong = DblToLong(itxInfo.dydx);285 dxdylong = DblToLong(itxInfo.dxdy);286 dydylong = DblToLong(itxInfo.dydy);287 x = dxoff+dstInfo.bounds.x1+0.5; /* Center of pixel x1 */288 y = dyoff+dstInfo.bounds.y1+0.5; /* Center of pixel y1 */289 Transform_transform(&itxInfo, &x, &y);290 xbase = DblToLong(x);291 ybase = DblToLong(y);292 293 pEdges = calculateEdges(edgebuf, &dstInfo.bounds, &itxInfo,294 xbase, ybase, sx2-sx1, sy2-sy1);295 420 296 421 if (!Region_IsEmpty(&clipInfo)) { 297 422 srcOps->GetRasInfo(env, srcOps, &srcInfo); 298 423 dstOps->GetRasInfo(env, dstOps, &dstInfo); 299 if (srcInfo.rasBase && dstInfo.rasBase) { 300 union { 301 jlong align; 302 jint data[LINE_SIZE]; 303 } rgb; 424 if (srcInfo.rasBase == NULL || dstInfo.rasBase == NULL) { 425 pEdges[0] = pEdges[1] = 0; 426 } else if (checkOverflow(dxoff, dyoff, &dstInfo.bounds, 427 &itxInfo, &xorig, &yorig)) 428 { 429 Transform_SafeHelper(env, srcOps, dstOps, 430 &srcInfo, &dstInfo, 431 pMaskBlitPrim, &compInfo, 432 pHelperFunc, pInterpFunc, 433 &clipInfo, &itxInfo, rgb.data, pEdges, 434 dxoff, dyoff, sx2-sx1, sy2-sy1); 435 } else { 304 436 SurfaceDataBounds span; 437 jlong dxdxlong, dydxlong; 438 jlong dxdylong, dydylong; 439 jlong xbase, ybase; 440 441 dxdxlong = DblToLong(itxInfo.dxdx); 442 dydxlong = DblToLong(itxInfo.dydx); 443 dxdylong = DblToLong(itxInfo.dxdy); 444 dydylong = DblToLong(itxInfo.dydy); 445 xbase = DblToLong(xorig); 446 ybase = DblToLong(yorig); 447 448 calculateEdges(pEdges, &dstInfo.bounds, &itxInfo, 449 xbase, ybase, sx2-sx1, sy2-sy1); 305 450 306 451 Region_StartIteration(env, &clipInfo); … … 319 464 /* Note - process at most one scanline at a time. */ 320 465 321 dx1 = pEdges[(dy1 - dstInfo.bounds.y1) * 2 ];322 dx2 = pEdges[(dy1 - dstInfo.bounds.y1) * 2 + 1];466 dx1 = pEdges[(dy1 - dstInfo.bounds.y1) * 2 + 2]; 467 dx2 = pEdges[(dy1 - dstInfo.bounds.y1) * 2 + 3]; 323 468 if (dx1 < span.x1) dx1 = span.x1; 324 469 if (dx2 > span.x2) dx2 = span.x2; … … 377 522 SurfaceData_InvokeRelease(env, dstOps, &dstInfo); 378 523 SurfaceData_InvokeRelease(env, srcOps, &srcInfo); 524 } else { 525 pEdges[0] = pEdges[1] = 0; 526 } 527 if (!JNU_IsNull(env, edgeArray)) { 528 (*env)->ReleasePrimitiveArrayCritical(env, edgeArray, pEdges, 0); 529 } else if (pEdges != edgebuf) { 530 free(pEdges); 379 531 } 380 532 SurfaceData_InvokeUnlock(env, dstOps, &dstInfo); 381 533 SurfaceData_InvokeUnlock(env, srcOps, &srcInfo); 382 if (!JNU_IsNull(env, edgeArray)) { 383 (*env)->SetIntArrayRegion(env, edgeArray, 0, 1, &dstInfo.bounds.y1); 384 (*env)->SetIntArrayRegion(env, edgeArray, 1, 1, &dstInfo.bounds.y2); 385 (*env)->SetIntArrayRegion(env, edgeArray, 386 2, (dstInfo.bounds.y2 - dstInfo.bounds.y1)*2, 387 pEdges); 388 } 389 if (pEdges != edgebuf) { 390 free(pEdges); 391 } 534 } 535 536 static void 537 Transform_SafeHelper(JNIEnv *env, 538 SurfaceDataOps *srcOps, 539 SurfaceDataOps *dstOps, 540 SurfaceDataRasInfo *pSrcInfo, 541 SurfaceDataRasInfo *pDstInfo, 542 NativePrimitive *pMaskBlitPrim, 543 CompositeInfo *pCompInfo, 544 TransformHelperFunc *pHelperFunc, 545 TransformInterpFunc *pInterpFunc, 546 RegionData *pClipInfo, TransformInfo *pItxInfo, 547 jint *pData, jint *pEdges, 548 jint dxoff, jint dyoff, jint sw, jint sh) 549 { 550 SurfaceDataBounds span; 551 jint dx1, dx2; 552 jint dy1, dy2; 553 jint i, iy; 554 555 dy1 = pDstInfo->bounds.y1; 556 dy2 = pDstInfo->bounds.y2; 557 dx1 = pDstInfo->bounds.x1; 558 dx2 = pDstInfo->bounds.x2; 559 pEdges[0] = dy1; 560 pEdges[1] = dy2; 561 for (iy = dy1; iy < dy2; iy++) { 562 jint i = (iy - dy1) * 2; 563 /* row spans are set to max,min until we find a pixel in range below */ 564 pEdges[i + 2] = dx2; 565 pEdges[i + 3] = dx1; 566 } 567 568 Region_StartIteration(env, pClipInfo); 569 while (Region_NextIteration(pClipInfo, &span)) { 570 dy1 = span.y1; 571 dy2 = span.y2; 572 while (dy1 < dy2) { 573 dx1 = span.x1; 574 dx2 = span.x2; 575 i = (dy1 - pDstInfo->bounds.y1) * 2; 576 while (dx1 < dx2) { 577 jdouble x, y; 578 jlong xlong, ylong; 579 580 x = dxoff + dx1 + 0.5; 581 y = dyoff + dy1 + 0.5; 582 Transform_transform(pItxInfo, &x, &y); 583 xlong = DblToLong(x); 584 ylong = DblToLong(y); 585 586 /* Process only pixels with centers in bounds 587 * Test double values to avoid overflow in conversion 588 * to long values and then also test the long values 589 * in case they rounded up and out of bounds during 590 * the conversion. 591 */ 592 if (x >= 0 && y >= 0 && x < sw && y < sh && 593 WholeOfLong(xlong) < sw && 594 WholeOfLong(ylong) < sh) 595 { 596 void *pDst; 597 598 if (pEdges[i + 2] > dx1) { 599 pEdges[i + 2] = dx1; 600 } 601 if (pEdges[i + 3] <= dx1) { 602 pEdges[i + 3] = dx1 + 1; 603 } 604 605 /* Get IntArgbPre pixel data from source */ 606 (*pHelperFunc)(pSrcInfo, 607 pData, 1, 608 xlong, 0, 609 ylong, 0); 610 611 /* Interpolate result pixels if needed */ 612 if (pInterpFunc) { 613 (*pInterpFunc)(pData, 1, 614 FractOfLong(xlong-LongOneHalf), 0, 615 FractOfLong(ylong-LongOneHalf), 0); 616 } 617 618 /* Store/Composite interpolated pixels into dest */ 619 pDst = PtrCoord(pDstInfo->rasBase, 620 dx1, pDstInfo->pixelStride, 621 dy1, pDstInfo->scanStride); 622 (*pMaskBlitPrim->funcs.maskblit)(pDst, pData, 623 0, 0, 0, 624 1, 1, 625 pDstInfo, pSrcInfo, 626 pMaskBlitPrim, 627 pCompInfo); 628 } 629 630 /* Increment to next input pixel */ 631 dx1++; 632 } 633 634 /* Increment to next scanline */ 635 dy1++; 636 } 637 } 638 Region_EndIteration(env, pClipInfo); 392 639 } 393 640 -
trunk/openjdk/jdk/src/solaris/bin/java_md.c
r278 r309 1 1 /* 2 * Copyright (c) 1998, 20 07, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * -
trunk/openjdk/jdk/src/windows/classes/java/net/TwoStacksPlainDatagramSocketImpl.java
r278 r309 27 27 import java.io.IOException; 28 28 import java.io.FileDescriptor; 29 import sun.net.ResourceManager; 29 30 30 31 /** … … 109 110 if (fd != null || fd1 != null) { 110 111 datagramSocketClose(); 112 ResourceManager.afterUdpClose(); 111 113 fd = null; 112 114 fd1 = null; -
trunk/openjdk/jdk/src/windows/classes/sun/nio/ch/WindowsSelectorImpl.java
r278 r309 1 1 /* 2 * Copyright (c) 2002, 20 07, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 309 309 int numKeysUpdated = 0; 310 310 numKeysUpdated += processFDSet(updateCount, readFds, 311 PollArrayWrapper.POLLIN); 311 PollArrayWrapper.POLLIN, 312 false); 312 313 numKeysUpdated += processFDSet(updateCount, writeFds, 313 314 PollArrayWrapper.POLLCONN | 314 PollArrayWrapper.POLLOUT); 315 PollArrayWrapper.POLLOUT, 316 false); 315 317 numKeysUpdated += processFDSet(updateCount, exceptFds, 316 318 PollArrayWrapper.POLLIN | 317 319 PollArrayWrapper.POLLCONN | 318 PollArrayWrapper.POLLOUT); 320 PollArrayWrapper.POLLOUT, 321 true); 319 322 return numKeysUpdated; 320 323 } … … 328 331 * me.updateCount <= me.clearedCount <= updateCount 329 332 */ 330 private int processFDSet(long updateCount, int[] fds, int rOps) { 333 private int processFDSet(long updateCount, int[] fds, int rOps, 334 boolean isExceptFds) { 331 335 int numKeysUpdated = 0; 332 336 for (int i = 1; i <= fds[0]; i++) { … … 344 348 continue; 345 349 SelectionKeyImpl sk = me.ski; 350 351 // The descriptor may be in the exceptfds set because there is 352 // OOB data queued to the socket. If there is OOB data then it 353 // is discarded and the key is not added to the selected set. 354 if (isExceptFds && 355 (sk.channel() instanceof SocketChannelImpl) && 356 discardUrgentData(desc)) 357 { 358 continue; 359 } 360 346 361 if (selectedKeys.contains(sk)) { // Key in selected set 347 362 if (me.clearedCount != updateCount) { … … 450 465 private native void resetWakeupSocket0(int wakeupSourceFd); 451 466 467 private native boolean discardUrgentData(int fd); 468 452 469 // We increment this counter on each call to updateSelectedKeys() 453 470 // each entry in SubSelector.fdsMap has a memorized value of -
trunk/openjdk/jdk/src/windows/classes/sun/security/provider/NativeSeedGenerator.java
r278 r309 1 1 /* 2 * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 54 54 private static native boolean nativeGenerateSeed(byte[] result); 55 55 56 @Override 56 57 void getSeedBytes(byte[] result) { 57 58 // fill array as a side effect … … 63 64 } 64 65 65 byte getSeedByte() {66 byte[] b = new byte[1];67 getSeedBytes(b);68 return b[0];69 }70 66 } -
trunk/openjdk/jdk/src/windows/native/sun/nio/ch/WindowsSelectorImpl.c
r278 r309 1 1 /* 2 * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 212 212 } 213 213 } 214 215 JNIEXPORT jboolean JNICALL 216 Java_sun_nio_ch_WindowsSelectorImpl_discardUrgentData(JNIEnv* env, jobject this, 217 jint s) 218 { 219 char data[8]; 220 jboolean discarded = JNI_FALSE; 221 int n; 222 do { 223 n = recv(s, data, sizeof(data), MSG_OOB); 224 if (n > 0) { 225 discarded = JNI_TRUE; 226 } 227 } while (n > 0); 228 return discarded; 229 } 230 -
trunk/openjdk/jdk/src/windows/native/sun/windows/awt_Component.cpp
r278 r309 5421 5421 { 5422 5422 sm_suppressFocusAndActivation = TRUE; 5423 5424 if (bEnable && IsTopLevel()) { 5425 // we should not enable blocked toplevels 5426 bEnable = !::IsWindow(AwtWindow::GetModalBlocker(GetHWnd())); 5427 } 5423 5428 ::EnableWindow(GetHWnd(), bEnable); 5429 5424 5430 sm_suppressFocusAndActivation = FALSE; 5425 5431 CriticalSection::Lock l(GetLock()); -
trunk/openjdk/jdk/src/windows/native/sun/windows/awt_Dialog.cpp
r278 r309 274 274 HWND blocker = AwtWindow::GetModalBlocker(AwtComponent::GetTopLevelParentForWindow(hWnd)); 275 275 HWND topMostBlocker = blocker; 276 HWND prevForegroundWindow = ::GetForegroundWindow(); 277 if (::IsWindow(blocker)) { 278 ::BringWindowToTop(hWnd); 279 } 276 280 while (::IsWindow(blocker)) { 277 281 topMostBlocker = blocker; … … 283 287 // or the dialog is currently inactive 284 288 if ((::WindowFromPoint(mhs->pt) == hWnd) && 285 ( ::GetForegroundWindow()== topMostBlocker))289 (prevForegroundWindow == topMostBlocker)) 286 290 { 287 291 ::MessageBeep(MB_OK); … … 293 297 ::SetForegroundWindow(topMostBlocker); 294 298 } 299 return 1; 295 300 } 296 301 } -
trunk/openjdk/jdk/src/windows/native/sun/windows/awt_FileDialog.cpp
r278 r309 246 246 247 247 fileBuffer = new TCHAR[MAX_PATH+1]; 248 memset(fileBuffer, 0, (MAX_PATH+1) * sizeof(TCHAR)); 248 249 249 250 file = (jstring)env->GetObjectField(target, AwtFileDialog::fileID); 250 251 if (file != NULL) { 251 252 LPCTSTR tmp = JNU_GetStringPlatformChars(env, file, NULL); 252 _tcs cpy(fileBuffer, tmp);253 _tcsncpy(fileBuffer, tmp, MAX_PATH-1); // the fileBuffer is double null terminated string 253 254 JNU_ReleaseStringPlatformChars(env, file, tmp); 254 255 } else { -
trunk/openjdk/jdk/src/windows/native/sun/windows/awt_Window.cpp
r278 r309 189 189 190 190 ::RemoveProp(GetHWnd(), ModalBlockerProp); 191 ::RemoveProp(GetHWnd(), ModalSaveWSEXProp);192 191 193 192 if (m_grabbedWindow == this) { … … 1471 1470 return; 1472 1471 } 1473 DWORD exStyle = ::GetWindowLong(window, GWL_EXSTYLE); 1472 1474 1473 if (::IsWindow(blocker)) { 1475 // save WS_EX_NOACTIVATE and WS_EX_APPWINDOW styles1476 DWORD saveStyle = exStyle & (AWT_WS_EX_NOACTIVATE | WS_EX_APPWINDOW);1477 ::SetProp(window, ModalSaveWSEXProp, reinterpret_cast<HANDLE>(saveStyle));1478 ::SetWindowLong(window, GWL_EXSTYLE, (exStyle | AWT_WS_EX_NOACTIVATE) & ~WS_EX_APPWINDOW);1479 1474 ::SetProp(window, ModalBlockerProp, reinterpret_cast<HANDLE>(blocker)); 1475 ::EnableWindow(window, FALSE); 1480 1476 } else { 1481 // restore WS_EX_NOACTIVATE and WS_EX_APPWINDOW styles1482 DWORD saveStyle = reinterpret_cast<DWORD>(::GetProp(window, ModalSaveWSEXProp));1483 ::SetWindowLong(window, GWL_EXSTYLE,1484 (exStyle & ~(AWT_WS_EX_NOACTIVATE | WS_EX_APPWINDOW)) | saveStyle);1485 ::RemoveProp(window, ModalSaveWSEXProp);1486 1477 ::RemoveProp(window, ModalBlockerProp); 1478 AwtComponent *comp = AwtComponent::GetComponent(window); 1479 // we don't expect to be called with non-java HWNDs 1480 DASSERT(comp && comp->IsTopLevel()); 1481 // we should not unblock disabled toplevels 1482 ::EnableWindow(window, comp->isEnabled()); 1487 1483 } 1488 1484 } -
trunk/openjdk/jdk/src/windows/native/sun/windows/awt_Window.h
r278 r309 34 34 // property name tagging windows disabled by modality 35 35 static LPCTSTR ModalBlockerProp = TEXT("SunAwtModalBlockerProp"); 36 static LPCTSTR ModalSaveWSEXProp = TEXT("SunAwtModalSaveWSEXProp");37 36 static LPCTSTR ModalDialogPeerProp = TEXT("SunAwtModalDialogPeerProp"); 38 37
Note:
See TracChangeset
for help on using the changeset viewer.