Changeset 406 for trunk/openjdk/jdk/src
- Timestamp:
- Dec 21, 2012, 10:37:13 AM (13 years ago)
- Location:
- trunk/openjdk
- Files:
-
- 2 deleted
- 125 edited
- 18 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/openjdk
- Property svn:mergeinfo changed
/branches/vendor/oracle/openjdk6/b27 (added) merged: 405 /branches/vendor/oracle/openjdk6/current merged: 404
- Property svn:mergeinfo changed
-
trunk/openjdk/jdk/src/share/classes/com/sun/beans/finder/ClassFinder.java
r278 r406 1 1 /* 2 * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 24 24 */ 25 25 package com.sun.beans.finder; 26 27 import static sun.reflect.misc.ReflectUtil.checkPackageAccess; 26 28 27 29 /** … … 54 56 */ 55 57 public static Class findClass( String name ) throws ClassNotFoundException { 58 checkPackageAccess(name); 56 59 try { 57 60 ClassLoader loader = Thread.currentThread().getContextClassLoader(); … … 94 97 */ 95 98 public static Class findClass( String name, ClassLoader loader ) throws ClassNotFoundException { 99 checkPackageAccess(name); 96 100 if ( loader != null ) { 97 101 try { -
trunk/openjdk/jdk/src/share/classes/com/sun/java/util/jar/pack/Driver.java
r278 r406 1 1 /* 2 * Copyright (c) 2003, 20 05, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 355 355 356 356 357 File f = File.createTempFile(prefix, suffix, where); 358 return f; 357 return sun.misc.IOUtils.createTempFile(prefix, suffix, where); 359 358 } 360 359 -
trunk/openjdk/jdk/src/share/classes/com/sun/script/javascript/RhinoScriptEngine.java
r309 r406 1 1 /* 2 * Copyright (c) 2005, 201 1, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 131 131 132 132 if (System.getSecurityManager() != null) { 133 accCtxt = AccessController.getContext(); 133 try { 134 AccessController.checkPermission(new AllPermission()); 135 } catch (AccessControlException ace) { 136 accCtxt = AccessController.getContext(); 137 } 134 138 } 135 139 -
trunk/openjdk/jdk/src/share/classes/java/awt/AWTEvent.java
r309 r406 269 269 } 270 270 271 public void setPosted(AWTEvent ev) { 272 ev.isPosted = true; 273 } 274 271 275 public AccessControlContext getAccessControlContext(AWTEvent ev) { 272 276 return ev.getAccessControlContext(); 277 } 278 279 public byte[] getBData(AWTEvent ev) { 280 return ev.bdata; 281 } 282 283 public void setBData(AWTEvent ev, byte[] bdata) { 284 ev.bdata = bdata; 273 285 } 274 286 }); -
trunk/openjdk/jdk/src/share/classes/java/awt/CheckboxMenuItem.java
r278 r406 32 32 import java.io.IOException; 33 33 import javax.accessibility.*; 34 import sun.awt.AWTAccessor; 34 35 35 36 … … 69 70 initIDs(); 70 71 } 72 73 AWTAccessor.setCheckboxMenuItemAccessor( 74 new AWTAccessor.CheckboxMenuItemAccessor() { 75 public boolean getState(CheckboxMenuItem cmi) { 76 return cmi.state; 77 } 78 }); 71 79 } 72 80 -
trunk/openjdk/jdk/src/share/classes/java/awt/Component.java
r309 r406 799 799 static { 800 800 AWTAccessor.setComponentAccessor(new AWTAccessor.ComponentAccessor() { 801 public AppContext getAppContext(Component comp) { 802 return comp.appContext; 803 } 804 805 public void setAppContext(Component comp, AppContext appContext) { 806 comp.appContext = appContext; 807 } 808 801 809 public AccessControlContext getAccessControlContext(Component comp) { 802 810 return comp.getAccessControlContext(); 803 811 } 804 812 813 public boolean requestFocusInWindow(Component comp, CausedFocusEvent.Cause cause) { 814 return comp.requestFocusInWindow(cause); 815 } 816 817 public void requestFocus(Component comp, CausedFocusEvent.Cause cause) { 818 comp.requestFocus(cause); 819 } 805 820 }); 806 821 } -
trunk/openjdk/jdk/src/share/classes/java/awt/Cursor.java
r278 r406 39 39 40 40 import java.security.AccessController; 41 import sun.awt.AWTAccessor; 41 42 42 43 /** … … 194 195 initIDs(); 195 196 } 197 198 AWTAccessor.setCursorAccessor( 199 new AWTAccessor.CursorAccessor() { 200 public long getPData(Cursor cursor) { 201 return cursor.pData; 202 } 203 204 public void setPData(Cursor cursor, long pData) { 205 cursor.pData = pData; 206 } 207 208 public int getType(Cursor cursor) { 209 return cursor.type; 210 } 211 }); 196 212 } 197 213 -
trunk/openjdk/jdk/src/share/classes/java/awt/DefaultKeyboardFocusManager.java
r278 r406 41 41 import sun.awt.AppContext; 42 42 import sun.awt.SunToolkit; 43 import sun.awt.AWTAccessor; 43 44 import sun.awt.CausedFocusEvent; 44 45 … … 76 77 typeAheadMarkers = new LinkedList(); 77 78 private boolean consumeNextKeyTyped; 79 80 static { 81 AWTAccessor.setDefaultKeyboardFocusManagerAccessor( 82 new AWTAccessor.DefaultKeyboardFocusManagerAccessor() { 83 public void consumeNextKeyTyped(DefaultKeyboardFocusManager dkfm, 84 KeyEvent e) { 85 dkfm.consumeNextKeyTyped(e); 86 } 87 }); 88 } 78 89 79 90 private static class TypeAheadMarker { -
trunk/openjdk/jdk/src/share/classes/java/awt/EventQueue.java
r309 r406 43 43 import sun.awt.PeerEvent; 44 44 import sun.awt.SunToolkit; 45 import sun.awt.AWTAccessor; 45 46 46 47 import java.security.AccessControlContext; 47 import java.security.ProtectionDomain;48 48 49 49 import sun.misc.SharedSecrets; … … 160 160 private static final Logger eventLog = Logger.getLogger("java.awt.event.EventQueue"); 161 161 162 static { 163 AWTAccessor.setEventQueueAccessor( 164 new AWTAccessor.EventQueueAccessor() { 165 public boolean noEvents(EventQueue eventQueue) { 166 return eventQueue.noEvents(); 167 } 168 public Thread getDispatchThread(EventQueue eventQueue) { 169 return eventQueue.dispatchThread; 170 } 171 public EventQueue getNextQueue(EventQueue eventQueue) { 172 return eventQueue.nextQueue; 173 } 174 public void removeSourceEvents(EventQueue eventQueue, 175 Object source, 176 boolean removeAllEvents) { 177 eventQueue.removeSourceEvents(source, removeAllEvents); 178 } 179 }); 180 } 181 162 182 public EventQueue() { 163 183 for (int i = 0; i < NUM_PRIORITIES; i++) { -
trunk/openjdk/jdk/src/share/classes/java/awt/Font.java
r278 r406 1 1 /* 2 * Copyright (c) 1995, 201 0, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1995, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 810 810 boolean hasPerm = false; 811 811 try { 812 f = File.createTempFile("+~JT", ".tmp", null);812 f = sun.misc.IOUtils.createTempFile("+~JT", ".tmp", null); 813 813 f.delete(); 814 814 f = null; … … 861 861 new PrivilegedExceptionAction<File>() { 862 862 public File run() throws IOException { 863 return File.createTempFile("+~JF", ".tmp", null);863 return sun.misc.IOUtils.createTempFile("+~JF", ".tmp", null); 864 864 } 865 865 } -
trunk/openjdk/jdk/src/share/classes/java/awt/KeyboardFocusManager.java
r390 r406 61 61 import sun.awt.SunToolkit; 62 62 import sun.awt.CausedFocusEvent; 63 import sun.awt.AWTAccessor; 63 64 64 65 /** … … 118 119 initIDs(); 119 120 } 121 AWTAccessor.setKeyboardFocusManagerAccessor( 122 new AWTAccessor.KeyboardFocusManagerAccessor() { 123 public int shouldNativelyFocusHeavyweight(Component heavyweight, 124 Component descendant, 125 boolean temporary, 126 boolean focusedWindowChangeAllowed, 127 long time, 128 CausedFocusEvent.Cause cause) 129 { 130 return KeyboardFocusManager.shouldNativelyFocusHeavyweight( 131 heavyweight, descendant, temporary, focusedWindowChangeAllowed, time, cause); 132 } 133 134 public void removeLastFocusRequest(Component heavyweight) { 135 KeyboardFocusManager.removeLastFocusRequest(heavyweight); 136 } 137 } 138 ); 120 139 } 121 140 -
trunk/openjdk/jdk/src/share/classes/java/awt/Menu.java
r278 r406 32 32 import java.awt.event.KeyEvent; 33 33 import javax.accessibility.*; 34 import sun.awt.AWTAccessor; 34 35 35 36 /** … … 63 64 initIDs(); 64 65 } 66 AWTAccessor.setMenuAccessor( 67 new AWTAccessor.MenuAccessor() { 68 public Vector getItems(Menu menu) { 69 return menu.items; 70 } 71 }); 65 72 } 66 73 -
trunk/openjdk/jdk/src/share/classes/java/awt/MenuBar.java
r278 r406 29 29 import java.util.Vector; 30 30 import java.util.Enumeration; 31 import sun.awt.AWTAccessor; 31 32 import java.awt.peer.MenuBarPeer; 32 33 import java.awt.event.KeyEvent; … … 75 76 initIDs(); 76 77 } 78 AWTAccessor.setMenuBarAccessor( 79 new AWTAccessor.MenuBarAccessor() { 80 public Menu getHelpMenu(MenuBar menuBar) { 81 return menuBar.helpMenu; 82 } 83 84 public Vector getMenus(MenuBar menuBar) { 85 return menuBar.menus; 86 } 87 }); 77 88 } 78 89 -
trunk/openjdk/jdk/src/share/classes/java/awt/MenuComponent.java
r309 r406 30 30 import java.io.ObjectInputStream; 31 31 import sun.awt.AppContext; 32 import sun.awt. SunToolkit;32 import sun.awt.AWTAccessor; 33 33 import javax.accessibility.*; 34 34 … … 56 56 initIDs(); 57 57 } 58 AWTAccessor.setMenuComponentAccessor( 59 new AWTAccessor.MenuComponentAccessor() { 60 public AppContext getAppContext(MenuComponent menuComp) { 61 return menuComp.appContext; 62 } 63 public void setAppContext(MenuComponent menuComp, 64 AppContext appContext) { 65 menuComp.appContext = appContext; 66 } 67 public MenuContainer getParent(MenuComponent menuComp) { 68 return menuComp.parent; 69 } 70 public Font getFont_NoClientCode(MenuComponent menuComp) { 71 return menuComp.getFont_NoClientCode(); 72 } 73 }); 58 74 } 59 75 -
trunk/openjdk/jdk/src/share/classes/java/awt/MenuItem.java
r278 r406 32 32 import java.io.IOException; 33 33 import javax.accessibility.*; 34 34 import sun.awt.AWTAccessor; 35 35 36 36 /** … … 77 77 initIDs(); 78 78 } 79 80 AWTAccessor.setMenuItemAccessor( 81 new AWTAccessor.MenuItemAccessor() { 82 public boolean isEnabled(MenuItem item) { 83 return item.enabled; 84 } 85 86 public String getLabel(MenuItem item) { 87 return item.label; 88 } 89 90 public MenuShortcut getShortcut(MenuItem item) { 91 return item.shortcut; 92 } 93 94 public String getActionCommandImpl(MenuItem item) { 95 return item.getActionCommandImpl(); 96 } 97 98 public boolean isItemEnabled(MenuItem item) { 99 return item.isItemEnabled(); 100 } 101 }); 79 102 } 80 103 -
trunk/openjdk/jdk/src/share/classes/java/awt/PopupMenu.java
r278 r406 29 29 import javax.accessibility.*; 30 30 31 import sun.awt.AWTAccessor; 31 32 32 33 /** … … 48 49 49 50 transient boolean isTrayIconPopup = false; 51 52 static { 53 AWTAccessor.setPopupMenuAccessor( 54 new AWTAccessor.PopupMenuAccessor() { 55 public boolean isTrayIconPopup(PopupMenu popupMenu) { 56 return popupMenu.isTrayIconPopup; 57 } 58 }); 59 } 50 60 51 61 /* -
trunk/openjdk/jdk/src/share/classes/java/awt/ScrollPaneAdjustable.java
r278 r406 25 25 package java.awt; 26 26 27 import sun.awt.AWTAccessor; 28 27 29 import java.awt.event.AdjustmentEvent; 28 30 import java.awt.event.AdjustmentListener; … … 157 159 initIDs(); 158 160 } 161 AWTAccessor.setScrollPaneAdjustableAccessor(new AWTAccessor.ScrollPaneAdjustableAccessor() { 162 public void setTypedValue(final ScrollPaneAdjustable adj, 163 final int v, final int type) { 164 adj.setTypedValue(v, type); 165 } 166 }); 159 167 } 160 168 -
trunk/openjdk/jdk/src/share/classes/java/awt/Window.java
r278 r406 51 51 import java.util.concurrent.atomic.AtomicBoolean; 52 52 import javax.accessibility.*; 53 import sun.awt.AWTAccessor; 53 54 import sun.awt.AppContext; 54 55 import sun.awt.CausedFocusEvent; … … 319 320 new GetPropertyAction("java.awt.Window.locationByPlatform")); 320 321 locationByPlatformProp = (s != null && s.equals("true")); 322 323 AWTAccessor.setWindowAccessor(new AWTAccessor.WindowAccessor() { 324 public void setLWRequestStatus(Window changed, boolean status) { 325 changed.syncLWRequests = status; 326 } 327 }); 321 328 } 322 329 -
trunk/openjdk/jdk/src/share/classes/java/beans/Introspector.java
r278 r406 1 1 /* 2 * Copyright (c) 1996, 20 09, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 140 140 141 141 private final static String DEFAULT_INFO_PATH = "sun.beans.infos"; 142 private final static String DEFAULT_INFO_PATH_NEW = "com.sun.beans.infos"; 142 143 143 144 private static String[] searchPath = { DEFAULT_INFO_PATH }; … … 461 462 462 463 for (int i = 0; i < searchPath.length; i++) { 464 String path = searchPath[i]; 465 if (DEFAULT_INFO_PATH.equals(path)) { 466 path = DEFAULT_INFO_PATH_NEW; 467 } 463 468 // This optimization will only use the BeanInfo search path if is has changed 464 469 // from the original or trying to get the ComponentBeanInfo. 465 if (!DEFAULT_INFO_PATH.equals(searchPath[i]) || 466 DEFAULT_INFO_PATH.equals(searchPath[i]) && "ComponentBeanInfo".equals(name)) { 470 if (!DEFAULT_INFO_PATH_NEW.equals(path) || "ComponentBeanInfo".equals(name)) { 467 471 try { 468 String fullName = searchPath[i]+ "." + name;472 String fullName = path + "." + name; 469 473 java.beans.BeanInfo bi = (java.beans.BeanInfo)instantiate(beanClass, fullName); 470 474 -
trunk/openjdk/jdk/src/share/classes/java/beans/PropertyEditorManager.java
r278 r406 1 1 /* 2 * Copyright (c) 1996, 20 06, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 26 26 package java.beans; 27 27 28 import sun.beans.editors.*;28 import com.sun.beans.editors.*; 29 29 30 30 /** … … 54 54 55 55 public class PropertyEditorManager { 56 57 private static final String DEFAULT_SEARCH_PATH = "sun.beans.editors"; 58 private static final String DEFAULT_SEARCH_PATH_NEW = "com.sun.beans.editors"; 56 59 57 60 /** … … 120 123 } 121 124 for (String path : searchPath) { 122 String name = path+ '.' + editorName;125 String name = (DEFAULT_SEARCH_PATH.equals(path) ? DEFAULT_SEARCH_PATH_NEW : path) + '.' + editorName; 123 126 try { 124 127 return (PropertyEditor) Introspector.instantiate(targetType, name); … … 189 192 } 190 193 191 private static String[] searchPath = { "sun.beans.editors"};194 private static String[] searchPath = { DEFAULT_SEARCH_PATH }; 192 195 private static java.util.Hashtable registry; 193 196 } -
trunk/openjdk/jdk/src/share/classes/java/beans/XMLDecoder.java
r278 r406 1 1 /* 2 * Copyright (c) 2000, 20 05, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 32 32 import java.lang.ref.Reference; 33 33 import java.lang.ref.WeakReference; 34 35 import java.security.AccessControlContext; 36 import java.security.AccessController; 37 import java.security.PrivilegedAction; 34 38 35 39 import org.xml.sax.SAXException; … … 67 71 */ 68 72 public class XMLDecoder { 73 private final AccessControlContext acc = AccessController.getContext(); 69 74 private InputStream in; 70 75 private Object owner; … … 249 254 private ObjectHandler getHandler() { 250 255 if ( handler == null ) { 251 SAXParserFactory factory = SAXParserFactory.newInstance(); 252 try { 253 SAXParser parser = factory.newSAXParser(); 254 handler = new ObjectHandler( this, getClassLoader() ); 255 parser.parse( in, handler ); 256 if ((this.acc == null) && (null != System.getSecurityManager())) { 257 throw new SecurityException("AccessControlContext is not set"); 256 258 } 257 catch ( ParserConfigurationException e ) { 258 getExceptionListener().exceptionThrown( e ); 259 } 260 catch ( SAXException se ) { 261 Exception e = se.getException(); 262 if ( e == null ) { 263 e = se; 259 handler = AccessController.doPrivileged(new PrivilegedAction<ObjectHandler>() { 260 public ObjectHandler run() { 261 ObjectHandler handler = new ObjectHandler(XMLDecoder.this, getClassLoader()); 262 SAXParserFactory factory = SAXParserFactory.newInstance(); 263 try { 264 SAXParser parser = factory.newSAXParser(); 265 parser.parse( in, handler ); 266 } 267 catch ( ParserConfigurationException e ) { 268 getExceptionListener().exceptionThrown( e ); 269 } 270 catch ( SAXException se ) { 271 Exception e = se.getException(); 272 if ( e == null ) { 273 e = se; 274 } 275 getExceptionListener().exceptionThrown( e ); 276 } 277 catch ( IOException ioe ) { 278 getExceptionListener().exceptionThrown( ioe ); 279 } 280 return handler; 264 281 } 265 getExceptionListener().exceptionThrown( e ); 266 } 267 catch ( IOException ioe ) { 268 getExceptionListener().exceptionThrown( ioe ); 269 } 282 }, this.acc); 270 283 } 271 284 return handler; -
trunk/openjdk/jdk/src/share/classes/java/io/File.java
r278 r406 1 1 /* 2 * Copyright (c) 1994, 20 07, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1994, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 898 898 SecurityManager security = System.getSecurityManager(); 899 899 if (security != null) security.checkWrite(path); 900 return fs.createFileExclusively(path );900 return fs.createFileExclusively(path, false); 901 901 } 902 902 … … 1701 1701 } 1702 1702 1703 private static boolean checkAndCreate(String filename, SecurityManager sm) 1703 private static boolean checkAndCreate(String filename, SecurityManager sm, 1704 boolean restrictive) 1704 1705 throws IOException 1705 1706 { … … 1714 1715 } 1715 1716 } 1716 return fs.createFileExclusively(filename); 1717 return fs.createFileExclusively(filename, restrictive); 1718 } 1719 1720 // The resulting temporary file may have more restrictive access permission 1721 // on some platforms, if restrictive is true. 1722 private static File createTempFile0(String prefix, String suffix, 1723 File directory, boolean restrictive) 1724 throws IOException 1725 { 1726 if (prefix == null) throw new NullPointerException(); 1727 if (prefix.length() < 3) 1728 throw new IllegalArgumentException("Prefix string too short"); 1729 String s = (suffix == null) ? ".tmp" : suffix; 1730 if (directory == null) { 1731 String tmpDir = LazyInitialization.temporaryDirectory(); 1732 directory = new File(tmpDir, fs.prefixLength(tmpDir)); 1733 } 1734 SecurityManager sm = System.getSecurityManager(); 1735 File f; 1736 do { 1737 f = generateFile(prefix, s, directory); 1738 } while (!checkAndCreate(f.getPath(), sm, restrictive)); 1739 return f; 1717 1740 } 1718 1741 … … 1790 1813 throws IOException 1791 1814 { 1792 if (prefix == null) throw new NullPointerException(); 1793 if (prefix.length() < 3) 1794 throw new IllegalArgumentException("Prefix string too short"); 1795 String s = (suffix == null) ? ".tmp" : suffix; 1796 if (directory == null) { 1797 String tmpDir = LazyInitialization.temporaryDirectory(); 1798 directory = new File(tmpDir, fs.prefixLength(tmpDir)); 1799 } 1800 SecurityManager sm = System.getSecurityManager(); 1801 File f; 1802 do { 1803 f = generateFile(prefix, s, directory); 1804 } while (!checkAndCreate(f.getPath(), sm)); 1805 return f; 1815 return createTempFile0(prefix, suffix, directory, false); 1806 1816 } 1807 1817 … … 1838 1848 throws IOException 1839 1849 { 1840 return createTempFile (prefix, suffix, null);1850 return createTempFile0(prefix, suffix, null, false); 1841 1851 } 1842 1852 … … 1960 1970 ); 1961 1971 } 1962 1963 1972 1973 // Set up JavaIOAccess in SharedSecrets 1974 static { 1975 sun.misc.SharedSecrets.setJavaIOFileAccess(new sun.misc.JavaIOFileAccess() { 1976 public File createTempFile(String prefix, String suffix, File directory) 1977 throws IOException 1978 { 1979 return createTempFile0(prefix, suffix, directory, true); 1980 } 1981 }); 1982 } 1964 1983 } -
trunk/openjdk/jdk/src/share/classes/java/io/FilePermission.java
r278 r406 400 400 401 401 public int hashCode() { 402 return this.cpath.hashCode();402 return 0; 403 403 } 404 404 -
trunk/openjdk/jdk/src/share/classes/java/io/FileSystem.java
r278 r406 1 1 /* 2 * Copyright (c) 1998, 20 05, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 158 158 * file or directory with the given pathname already exists. Throw an 159 159 * IOException if an I/O error occurs. 160 */ 161 public abstract boolean createFileExclusively(String pathname) 160 * 161 * <p> 162 * The resulting file may have more restrictive access permission 163 * on some platforms, if restrictive is true. 164 */ 165 public abstract boolean createFileExclusively(String pathname, 166 boolean restrictive) 162 167 throws IOException; 163 168 -
trunk/openjdk/jdk/src/share/classes/java/net/URL.java
r278 r406 1 1 /* 2 * Copyright (c) 1995, 20 07, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1995, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 29 29 import java.io.InputStream; 30 30 import java.io.OutputStream; 31 import java.security.AccessController; 32 import java.security.PrivilegedAction; 31 33 import java.util.Hashtable; 32 34 import java.util.StringTokenizer; … … 1111 1113 private static Object streamHandlerLock = new Object(); 1112 1114 1115 // special case the gopher protocol, disabled by default 1116 private static final String GOPHER = "gopher"; 1117 private static final String ENABLE_GOPHER_PROP = "jdk.net.registerGopherProtocol"; 1118 private static final boolean enableGopher = AccessController.doPrivileged( 1119 new PrivilegedAction<Boolean>() { 1120 public Boolean run() { 1121 String prop = System.getProperty(ENABLE_GOPHER_PROP); 1122 return prop == null ? false : 1123 (prop.equalsIgnoreCase("false") ? false : true); 1124 } 1125 }); 1126 1127 // package name of the JDK implementation protocol handlers 1128 private static final String JDK_PACKAGE_PREFIX = "sun.net.www.protocol"; 1129 1113 1130 /** 1114 1131 * Returns the Stream Handler. … … 1142 1159 // REMIND: decide whether to allow the "null" class prefix 1143 1160 // or not. 1144 packagePrefixList += "sun.net.www.protocol";1161 packagePrefixList += JDK_PACKAGE_PREFIX; 1145 1162 1146 1163 StringTokenizer packagePrefixIter = … … 1152 1169 String packagePrefix = 1153 1170 packagePrefixIter.nextToken().trim(); 1171 1172 // do not try to instantiate the JDK gopher handler 1173 // unless the system property had been explicitly set 1174 if (protocol.equalsIgnoreCase(GOPHER) && 1175 packagePrefix.equals(JDK_PACKAGE_PREFIX) && 1176 !enableGopher) { 1177 continue; 1178 } 1179 1154 1180 try { 1155 1181 String clsName = packagePrefix + "." + protocol + -
trunk/openjdk/jdk/src/share/classes/java/security/AccessController.java
r278 r406 1 1 /* 2 * Copyright (c) 1997, 20 07, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 291 291 public static <T> T doPrivilegedWithCombiner(PrivilegedAction<T> action) { 292 292 293 DomainCombiner dc = null;294 293 AccessControlContext acc = getStackAccessControlContext(); 295 if (acc == null || (dc = acc.getAssignedCombiner()) == null) {294 if (acc == null) { 296 295 return AccessController.doPrivileged(action); 297 296 } 297 DomainCombiner dc = acc.getAssignedCombiner(); 298 298 return AccessController.doPrivileged(action, preserveCombiner(dc)); 299 299 } … … 387 387 (PrivilegedExceptionAction<T> action) throws PrivilegedActionException { 388 388 389 DomainCombiner dc = null;390 389 AccessControlContext acc = getStackAccessControlContext(); 391 if (acc == null || (dc = acc.getAssignedCombiner()) == null) {390 if (acc == null) { 392 391 return AccessController.doPrivileged(action); 393 392 } 393 DomainCombiner dc = acc.getAssignedCombiner(); 394 394 return AccessController.doPrivileged(action, preserveCombiner(dc)); 395 395 } … … 418 418 // even if the caller is from the bootclasspath 419 419 ProtectionDomain[] pds = new ProtectionDomain[] {callerPd}; 420 return new AccessControlContext(combiner.combine(pds, null), combiner); 420 if (combiner == null) { 421 return new AccessControlContext(pds); 422 } else { 423 return new AccessControlContext(combiner.combine(pds, null), 424 combiner); 425 } 421 426 } 422 427 -
trunk/openjdk/jdk/src/share/classes/java/util/ServiceLoader.java
r278 r406 359 359 String cn = nextName; 360 360 nextName = null; 361 Class<?> c = null; 361 362 try { 362 S p = service.cast(Class.forName(cn, true, loader) 363 .newInstance()); 364 providers.put(cn, p); 365 return p; 363 c = Class.forName(cn, false, loader); 366 364 } catch (ClassNotFoundException x) { 367 365 fail(service, 368 366 "Provider " + cn + " not found"); 367 } 368 if (!service.isAssignableFrom(c)) { 369 fail(service, 370 "Provider " + cn + " not a subtype"); 371 } 372 try { 373 S p = service.cast(c.newInstance()); 374 providers.put(cn, p); 375 return p; 369 376 } catch (Throwable x) { 370 377 fail(service, -
trunk/openjdk/jdk/src/share/classes/java/util/UUID.java
r278 r406 1 1 /* 2 * Copyright (c) 2003, 20 07, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 123 123 /* 124 124 * The random number generator used by this class to create random 125 * based UUIDs. 126 */ 127 private static volatile SecureRandom numberGenerator = null; 125 * based UUIDs. In a holder class to defer initialization until needed. 126 */ 127 private static class Holder { 128 static final SecureRandom numberGenerator = new SecureRandom(); 129 } 128 130 129 131 // Constructors and Factories … … 170 172 */ 171 173 public static UUID randomUUID() { 172 SecureRandom ng = numberGenerator; 173 if (ng == null) { 174 numberGenerator = ng = new SecureRandom(); 175 } 174 SecureRandom ng = Holder.numberGenerator; 176 175 177 176 byte[] randomBytes = new byte[16]; … … 291 290 * <p><ul> 292 291 * <li>0 Reserved for NCS backward compatibility 293 * <li>2 The Leach-Salz variant (used by this class) 292 * <li>2 <a href="http://www.ietf.org/rfc/rfc4122.txt">IETF RFC 4122</a> 293 * (Leach-Salz), used by this class 294 294 * <li>6 Reserved, Microsoft Corporation backward compatibility 295 295 * <li>7 Reserved for future definition -
trunk/openjdk/jdk/src/share/classes/java/util/concurrent/Executors.java
r278 r406 531 531 new PrivilegedExceptionAction<T>() { 532 532 public T run() throws Exception { 533 ClassLoader savedcl = null;534 533 Thread t = Thread.currentThread(); 535 try { 536 ClassLoader cl = t.getContextClassLoader(); 537 if (ccl != cl) { 538 t.setContextClassLoader(ccl); 539 savedcl = cl; 534 ClassLoader cl = t.getContextClassLoader(); 535 if (ccl == cl) { 536 return task.call(); 537 } else { 538 t.setContextClassLoader(ccl); 539 try { 540 return task.call(); 541 } finally { 542 t.setContextClassLoader(cl); 540 543 } 541 return task.call();542 } finally {543 if (savedcl != null)544 t.setContextClassLoader(savedcl);545 544 } 546 545 } -
trunk/openjdk/jdk/src/share/classes/java/util/logging/FileHandler.java
r278 r406 1 1 /* 2 * Copyright (c) 2000, 20 06, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 221 221 */ 222 222 public FileHandler() throws IOException, SecurityException { 223 check Access();223 checkPermission(); 224 224 configure(); 225 225 openFiles(); … … 247 247 throw new IllegalArgumentException(); 248 248 } 249 check Access();249 checkPermission(); 250 250 configure(); 251 251 this.pattern = pattern; … … 279 279 throw new IllegalArgumentException(); 280 280 } 281 check Access();281 checkPermission(); 282 282 configure(); 283 283 this.pattern = pattern; … … 316 316 throw new IllegalArgumentException(); 317 317 } 318 check Access();318 checkPermission(); 319 319 configure(); 320 320 this.pattern = pattern; … … 355 355 throw new IllegalArgumentException(); 356 356 } 357 check Access();357 checkPermission(); 358 358 configure(); 359 359 this.pattern = pattern; … … 368 368 private void openFiles() throws IOException { 369 369 LogManager manager = LogManager.getLogManager(); 370 manager.check Access();370 manager.checkPermission(); 371 371 if (count < 1) { 372 372 throw new IllegalArgumentException("file count = " + count); -
trunk/openjdk/jdk/src/share/classes/java/util/logging/Handler.java
r278 r406 1 1 /* 2 * Copyright (c) 2000, 20 06, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 112 112 */ 113 113 public void setFormatter(Formatter newFormatter) throws SecurityException { 114 check Access();114 checkPermission(); 115 115 // Check for a null pointer: 116 116 newFormatter.getClass(); … … 141 141 public void setEncoding(String encoding) 142 142 throws SecurityException, java.io.UnsupportedEncodingException { 143 check Access();143 checkPermission(); 144 144 if (encoding != null) { 145 145 try { … … 176 176 */ 177 177 public void setFilter(Filter newFilter) throws SecurityException { 178 check Access();178 checkPermission(); 179 179 filter = newFilter; 180 180 } … … 200 200 */ 201 201 public void setErrorManager(ErrorManager em) { 202 check Access();202 checkPermission(); 203 203 if (em == null) { 204 204 throw new NullPointerException(); … … 214 214 */ 215 215 public ErrorManager getErrorManager() { 216 check Access();216 checkPermission(); 217 217 return errorManager; 218 218 } … … 254 254 throw new NullPointerException(); 255 255 } 256 check Access();256 checkPermission(); 257 257 logLevel = newLevel; 258 258 } … … 297 297 // appropriate security privileges to update Handler 298 298 // state and if not throw a SecurityException. 299 void check Access() throws SecurityException {299 void checkPermission() throws SecurityException { 300 300 if (sealed) { 301 manager.check Access();301 manager.checkPermission(); 302 302 } 303 303 } -
trunk/openjdk/jdk/src/share/classes/java/util/logging/LogManager.java
r278 r406 1 1 /* 2 * Copyright (c) 2000, 201 0, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 304 304 throw new NullPointerException(); 305 305 } 306 check Access();306 checkPermission(); 307 307 changes.addPropertyChangeListener(l); 308 308 } … … 323 323 */ 324 324 public void removePropertyChangeListener(PropertyChangeListener l) throws SecurityException { 325 check Access();325 checkPermission(); 326 326 changes.removePropertyChangeListener(l); 327 327 } … … 741 741 */ 742 742 public void readConfiguration() throws IOException, SecurityException { 743 check Access();743 checkPermission(); 744 744 745 745 // if a configuration class is specified, load it and use it. … … 799 799 800 800 public void reset() throws SecurityException { 801 check Access();801 checkPermission(); 802 802 synchronized (this) { 803 803 props = new Properties(); … … 884 884 */ 885 885 public void readConfiguration(InputStream ins) throws IOException, SecurityException { 886 check Access();886 checkPermission(); 887 887 reset(); 888 888 … … 1046 1046 1047 1047 1048 private Permission ourPermission = new LoggingPermission("control", null); 1048 private final Permission controlPermission = new LoggingPermission("control", null); 1049 1050 void checkPermission() { 1051 SecurityManager sm = System.getSecurityManager(); 1052 if (sm != null) 1053 sm.checkPermission(controlPermission); 1054 } 1049 1055 1050 1056 /** … … 1059 1065 */ 1060 1066 public void checkAccess() throws SecurityException { 1061 SecurityManager sm = System.getSecurityManager(); 1062 if (sm == null) { 1063 return; 1064 } 1065 sm.checkPermission(ourPermission); 1067 checkPermission(); 1066 1068 } 1067 1069 -
trunk/openjdk/jdk/src/share/classes/java/util/logging/Logger.java
r278 r406 1 1 /* 2 * Copyright (c) 2000, 201 0, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 267 267 } 268 268 269 private void check Access() throws SecurityException {269 private void checkPermission() throws SecurityException { 270 270 if (!anonymous) { 271 271 if (manager == null) { … … 273 273 manager = LogManager.getLogManager(); 274 274 } 275 manager.check Access();275 manager.checkPermission(); 276 276 } 277 277 } … … 455 455 */ 456 456 public synchronized void setFilter(Filter newFilter) throws SecurityException { 457 check Access();457 checkPermission(); 458 458 filter = newFilter; 459 459 } … … 1146 1146 */ 1147 1147 public void setLevel(Level newLevel) throws SecurityException { 1148 check Access();1148 checkPermission(); 1149 1149 synchronized (treeLock) { 1150 1150 levelObject = newLevel; … … 1201 1201 // Check for null handler 1202 1202 handler.getClass(); 1203 check Access();1203 checkPermission(); 1204 1204 if (handlers == null) { 1205 1205 handlers = new ArrayList<Handler>(); … … 1218 1218 */ 1219 1219 public synchronized void removeHandler(Handler handler) throws SecurityException { 1220 check Access();1220 checkPermission(); 1221 1221 if (handler == null) { 1222 1222 return; … … 1252 1252 */ 1253 1253 public synchronized void setUseParentHandlers(boolean useParentHandlers) { 1254 check Access();1254 checkPermission(); 1255 1255 this.useParentHandlers = useParentHandlers; 1256 1256 } … … 1389 1389 throw new NullPointerException(); 1390 1390 } 1391 manager.check Access();1391 manager.checkPermission(); 1392 1392 doSetParent(parent); 1393 1393 } -
trunk/openjdk/jdk/src/share/classes/java/util/logging/MemoryHandler.java
r278 r406 1 1 /* 2 * Copyright (c) 2000, 20 04, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 239 239 } 240 240 LogManager manager = LogManager.getLogManager(); 241 check Access();241 checkPermission(); 242 242 pushLevel = newLevel; 243 243 } -
trunk/openjdk/jdk/src/share/classes/java/util/logging/StreamHandler.java
r278 r406 1 1 /* 2 * Copyright (c) 2000, 20 06, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2000, 2012, 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 synchronized void flushAndClose() throws SecurityException { 252 check Access();252 checkPermission(); 253 253 if (writer != null) { 254 254 try { -
trunk/openjdk/jdk/src/share/classes/javax/crypto/CipherSpi.java
r278 r406 1 1 /* 2 * Copyright (c) 1997, 20 07, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 743 743 byte[] inArray = new byte[getTempArraySize(inLen)]; 744 744 int total = 0; 745 while (inLen > 0) {745 do { 746 746 int chunk = Math.min(inLen, inArray.length); 747 747 input.get(inArray, 0, chunk); … … 755 755 outOfs += n; 756 756 inLen -= chunk; 757 } 757 } while (inLen > 0); 758 758 output.position(outPos + total); 759 759 return total; … … 772 772 int total = 0; 773 773 boolean resized = false; 774 while (inLen > 0){774 do { 775 775 int chunk = Math.min(inLen, outSize); 776 776 if ((a1 == false) && (resized == false)) { … … 802 802 outArray = new byte[newOut]; 803 803 } 804 } 804 } while (inLen > 0); 805 805 input.position(inLimit); 806 806 return total; -
trunk/openjdk/jdk/src/share/classes/javax/imageio/stream/FileCacheImageInputStream.java
r278 r406 1 1 /* 2 * Copyright (c) 2000, 20 07, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 99 99 this.stream = stream; 100 100 this.cacheFile = 101 File.createTempFile("imageio", ".tmp", cacheDir);101 sun.misc.IOUtils.createTempFile("imageio", ".tmp", cacheDir); 102 102 this.cache = new RandomAccessFile(cacheFile, "rw"); 103 103 -
trunk/openjdk/jdk/src/share/classes/javax/imageio/stream/FileCacheImageOutputStream.java
r278 r406 1 1 /* 2 * Copyright (c) 2000, 20 07, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 85 85 this.stream = stream; 86 86 this.cacheFile = 87 File.createTempFile("imageio", ".tmp", cacheDir);87 sun.misc.IOUtils.createTempFile("imageio", ".tmp", cacheDir); 88 88 this.cache = new RandomAccessFile(cacheFile, "rw"); 89 89 -
trunk/openjdk/jdk/src/share/classes/javax/management/loading/MLet.java
r278 r406 1 1 /* 2 * Copyright (c) 1999, 20 07, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 1153 1153 File directory = new File(libraryDirectory); 1154 1154 directory.mkdirs(); 1155 File file = File.createTempFile(libname + ".", null, directory);1155 File file = sun.misc.IOUtils.createTempFile(libname + ".", null, directory); 1156 1156 file.deleteOnExit(); 1157 1157 FileOutputStream fileOutput = new FileOutputStream(file); -
trunk/openjdk/jdk/src/share/classes/javax/management/modelmbean/DescriptorSupport.java
r278 r406 1 1 /* 2 * Copyright (c) 2000, 20 07, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 1240 1240 } 1241 1241 final String className = s.substring(1, slash); 1242 1242 1243 final Constructor<?> constr; 1243 1244 try { 1245 ReflectUtil.checkPackageAccess(className); 1244 1246 final ClassLoader contextClassLoader = 1245 1247 Thread.currentThread().getContextClassLoader(); 1246 if (contextClassLoader == null) {1247 ReflectUtil.checkPackageAccess(className);1248 }1249 1248 final Class<?> c = 1250 1249 Class.forName(className, false, contextClassLoader); -
trunk/openjdk/jdk/src/share/classes/javax/management/remote/rmi/RMIConnectionImpl.java
r278 r406 1 1 /* 2 * Copyright (c) 2002, 20 07, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 40 40 import java.rmi.UnmarshalException; 41 41 import java.rmi.server.Unreferenced; 42 42 43 import java.security.AccessControlContext; 43 44 import java.security.AccessController; 45 import java.security.Permission; 46 import java.security.PermissionCollection; 47 import java.security.Permissions; 44 48 import java.security.PrivilegedAction; 45 49 import java.security.PrivilegedActionException; 46 50 import java.security.PrivilegedExceptionAction; 51 import java.security.ProtectionDomain; 52 47 53 import java.util.Arrays; 48 54 import java.util.Collections; … … 61 67 import javax.management.MBeanInfo; 62 68 import javax.management.MBeanRegistrationException; 69 import javax.management.MBeanPermission; 63 70 import javax.management.MBeanServer; 64 71 import javax.management.NotCompliantMBeanException; … … 145 152 146 153 final ClassLoader dcl = defaultClassLoader; 154 147 155 this.classLoaderWithRepository = 148 156 AccessController.doPrivileged( … … 150 158 public ClassLoaderWithRepository run() { 151 159 return new ClassLoaderWithRepository( 152 getClassLoaderRepository(),160 mbeanServer.getClassLoaderRepository(), 153 161 dcl); 154 162 } 163 }, 164 165 withPermissions( new MBeanPermission("*", "getClassLoaderRepository"), 166 new RuntimePermission("createClassLoader")) 167 ); 168 this.defaultContextClassLoader = 169 AccessController.doPrivileged( 170 new PrivilegedAction<ClassLoader>() { 171 @Override 172 public ClassLoader run() { 173 return new CombinedClassLoader(Thread.currentThread().getContextClassLoader(), 174 dcl); 175 } 155 176 }); 156 157 serverCommunicatorAdmin = new 158 RMIServerCommunicatorAdmin(EnvHelp.getServerConnectionTimeout(env)); 177 serverCommunicatorAdmin = new 178 RMIServerCommunicatorAdmin(EnvHelp.getServerConnectionTimeout(env)); 159 179 160 180 this.env = env; 181 } 182 183 private static AccessControlContext withPermissions(Permission ... perms){ 184 Permissions col = new Permissions(); 185 186 for (Permission thePerm : perms ) { 187 col.add(thePerm); 188 } 189 190 final ProtectionDomain pd = new ProtectionDomain(null, col); 191 return new AccessControlContext( new ProtectionDomain[] { pd }); 161 192 } 162 193 … … 507 538 +" unwrapping query with defaultClassLoader."); 508 539 509 queryValue = unwrap(query, defaultClassLoader, QueryExp.class);540 queryValue = unwrap(query, defaultContextClassLoader, QueryExp.class); 510 541 511 542 try { … … 541 572 +" unwrapping query with defaultClassLoader."); 542 573 543 queryValue = unwrap(query, defaultClassLoader, QueryExp.class);574 queryValue = unwrap(query, defaultContextClassLoader, QueryExp.class); 544 575 545 576 try { … … 1315 1346 //------------------------------------------------------------------------ 1316 1347 1317 private ClassLoaderRepository getClassLoaderRepository() {1318 return1319 AccessController.doPrivileged(1320 new PrivilegedAction<ClassLoaderRepository>() {1321 public ClassLoaderRepository run() {1322 return mbeanServer.getClassLoaderRepository();1323 }1324 });1325 }1326 1327 1348 private ClassLoader getClassLoader(final ObjectName name) 1328 1349 throws InstanceNotFoundException { … … 1334 1355 return mbeanServer.getClassLoader(name); 1335 1356 } 1336 }); 1357 }, 1358 withPermissions(new MBeanPermission("*", "getClassLoader")) 1359 ); 1337 1360 } catch (PrivilegedActionException pe) { 1338 1361 throw (InstanceNotFoundException) extractException(pe); … … 1349 1372 return mbeanServer.getClassLoaderFor(name); 1350 1373 } 1351 }); 1374 }, 1375 withPermissions(new MBeanPermission("*", "getClassLoaderFor")) 1376 ); 1352 1377 } catch (PrivilegedActionException pe) { 1353 1378 throw (InstanceNotFoundException) extractException(pe); … … 1576 1601 new PrivilegedExceptionAction<ClassLoader>() { 1577 1602 public ClassLoader run() throws Exception { 1578 return new OrderClassLoaders(cl1, cl2); 1603 return new CombinedClassLoader(Thread.currentThread().getContextClassLoader(), 1604 new OrderClassLoaders(cl1, cl2)); 1579 1605 } 1580 1606 } … … 1668 1694 private final ClassLoader defaultClassLoader; 1669 1695 1696 private final ClassLoader defaultContextClassLoader; 1697 1670 1698 private final ClassLoaderWithRepository classLoaderWithRepository; 1671 1699 … … 1752 1780 private static final ClassLogger logger = 1753 1781 new ClassLogger("javax.management.remote.rmi", "RMIConnectionImpl"); 1782 1783 private static final class CombinedClassLoader extends ClassLoader { 1784 1785 private final static class ClassLoaderWrapper extends ClassLoader { 1786 ClassLoaderWrapper(ClassLoader cl) { 1787 super(cl); 1788 } 1789 1790 @Override 1791 protected Class<?> loadClass(String name, boolean resolve) 1792 throws ClassNotFoundException { 1793 return super.loadClass(name, resolve); 1794 } 1795 }; 1796 1797 final ClassLoaderWrapper defaultCL; 1798 1799 private CombinedClassLoader(ClassLoader parent, ClassLoader defaultCL) { 1800 super(parent); 1801 this.defaultCL = new ClassLoaderWrapper(defaultCL); 1802 } 1803 1804 @Override 1805 protected Class<?> loadClass(String name, boolean resolve) 1806 throws ClassNotFoundException { 1807 try { 1808 super.loadClass(name, resolve); 1809 } catch(Exception e) { 1810 for(Throwable t = e; t != null; t = t.getCause()) { 1811 if(t instanceof SecurityException) { 1812 throw t==e?(SecurityException)t:new SecurityException(t.getMessage(), e); 1813 } 1814 } 1815 } 1816 final Class<?> cl = defaultCL.loadClass(name, resolve); 1817 return cl; 1818 } 1819 1820 } 1754 1821 } -
trunk/openjdk/jdk/src/share/classes/javax/swing/ClientPropertyKey.java
r278 r406 25 25 26 26 package javax.swing; 27 28 import sun.awt.AWTAccessor; 27 29 28 30 /** … … 87 89 private final boolean reportValueNotSerializable; 88 90 91 static { 92 AWTAccessor.setClientPropertyKeyAccessor( 93 new AWTAccessor.ClientPropertyKeyAccessor() { 94 public Object getJComponent_TRANSFER_HANDLER() { 95 return JComponent_TRANSFER_HANDLER; 96 } 97 }); 98 } 99 89 100 /** 90 101 * Constructs a key with the {@code reportValueNotSerializable} property -
trunk/openjdk/jdk/src/share/classes/javax/swing/plaf/synth/SynthButtonUI.java
r278 r406 136 136 state = DISABLED; 137 137 } 138 if (SynthLookAndFeel. selectedUI== this) {139 return SynthLookAndFeel. selectedUIState| SynthConstants.ENABLED;138 if (SynthLookAndFeel.getSelectedUI() == this) { 139 return SynthLookAndFeel.getSelectedUIState() | SynthConstants.ENABLED; 140 140 } 141 141 AbstractButton button = (AbstractButton) c; -
trunk/openjdk/jdk/src/share/classes/javax/swing/plaf/synth/SynthLabelUI.java
r278 r406 95 95 private int getComponentState(JComponent c) { 96 96 int state = SynthLookAndFeel.getComponentState(c); 97 if (SynthLookAndFeel. selectedUI== this &&97 if (SynthLookAndFeel.getSelectedUI() == this && 98 98 state == SynthConstants.ENABLED) { 99 state = SynthLookAndFeel. selectedUIState| SynthConstants.ENABLED;99 state = SynthLookAndFeel.getSelectedUIState() | SynthConstants.ENABLED; 100 100 } 101 101 return state; -
trunk/openjdk/jdk/src/share/classes/javax/swing/plaf/synth/SynthLookAndFeel.java
r278 r406 79 79 80 80 /** 81 * AppContext key to get selectedUI. 82 */ 83 private static final Object SELECTED_UI_KEY = new StringBuilder("selectedUI"); 84 85 /** 86 * AppContext key to get selectedUIState. 87 */ 88 private static final Object SELECTED_UI_STATE_KEY = new StringBuilder("selectedUIState"); 89 90 /** 81 91 * The last SynthStyleFactory that was asked for from AppContext 82 92 * <code>lastContext</code>. … … 84 94 private static SynthStyleFactory lastFactory; 85 95 /** 86 * If this is true it indicates there is more than one AppContext active87 * and that we need to make sure in getStyleCache the requesting88 * AppContext matches that of <code>lastContext</code> before returning89 * it.90 */91 private static boolean multipleApps;92 /**93 96 * AppContext lastLAF came from. 94 97 */ 95 98 private static AppContext lastContext; 96 97 // Refer to setSelectedUI98 static ComponentUI selectedUI;99 // Refer to setSelectedUI100 static int selectedUIState;101 99 102 100 /** … … 112 110 113 111 private Handler _handler; 112 113 static ComponentUI getSelectedUI() { 114 return (ComponentUI) AppContext.getAppContext().get(SELECTED_UI_KEY); 115 } 114 116 115 117 /** … … 124 126 boolean focused, boolean enabled, 125 127 boolean rollover) { 126 selectedUI = uix;127 selectedUIState = 0; 128 int selectedUIState = 0; 129 128 130 if (selected) { 129 131 selectedUIState = SynthConstants.SELECTED; … … 142 144 if (enabled) { 143 145 selectedUIState |= SynthConstants.ENABLED; 144 selectedUIState = SynthConstants.FOCUSED; 146 if (focused) { 147 selectedUIState |= SynthConstants.FOCUSED; 148 } 145 149 } 146 150 else { … … 148 152 } 149 153 } 154 155 AppContext context = AppContext.getAppContext(); 156 157 context.put(SELECTED_UI_KEY, uix); 158 context.put(SELECTED_UI_STATE_KEY, Integer.valueOf(selectedUIState)); 159 } 160 161 static int getSelectedUIState() { 162 Integer result = (Integer) AppContext.getAppContext().get(SELECTED_UI_STATE_KEY); 163 164 return result == null ? 0 : result.intValue(); 150 165 } 151 166 … … 154 169 */ 155 170 static void resetSelectedUI() { 156 selectedUI = null;171 AppContext.getAppContext().remove(SELECTED_UI_KEY); 157 172 } 158 173 … … 169 184 synchronized(SynthLookAndFeel.class) { 170 185 AppContext context = AppContext.getAppContext(); 171 if (!multipleApps && context != lastContext &&172 lastContext != null) {173 multipleApps = true;174 }175 186 lastFactory = cache; 176 187 lastContext = context; … … 186 197 public static SynthStyleFactory getStyleFactory() { 187 198 synchronized(SynthLookAndFeel.class) { 188 if (!multipleApps) {189 return lastFactory;190 }191 199 AppContext context = AppContext.getAppContext(); 192 200 … … 195 203 } 196 204 lastContext = context; 197 lastFactory = (SynthStyleFactory)AppContext.getAppContext().get 198 (STYLE_FACTORY_KEY); 205 lastFactory = (SynthStyleFactory) context.get(STYLE_FACTORY_KEY); 199 206 return lastFactory; 200 207 } -
trunk/openjdk/jdk/src/share/classes/javax/swing/text/DefaultFormatter.java
r278 r406 24 24 */ 25 25 package javax.swing.text; 26 27 import sun.reflect.misc.ConstructorUtil; 26 28 27 29 import java.io.Serializable; … … 246 248 247 249 try { 248 cons = vc.getConstructor(new Class[] { String.class});250 cons = ConstructorUtil.getConstructor(vc, new Class[]{String.class}); 249 251 250 252 } catch (NoSuchMethodException nsme) { -
trunk/openjdk/jdk/src/share/classes/sun/awt/AWTAccessor.java
r278 r406 27 27 28 28 import java.awt.*; 29 import java.awt.event.InputEvent;30 import java.awt.geom.Point2D;31 import java.awt.image.BufferedImage;32 29 33 30 import sun.misc.Unsafe; 34 import java.awt.peer.ComponentPeer; 35 36 import java.security.AccessController; 31 37 32 import java.security.AccessControlContext; 33 34 import java.util.Vector; 35 36 import java.awt.event.KeyEvent; 38 37 39 38 /** … … 56 55 } 57 56 57 /** 58 * An interface of an accessor for java.awt.Window class. 59 */ 60 public interface WindowAccessor { 61 /** 62 * Sets the synchronous status of focus requests on lightweight 63 * components in the specified window to the specified value. 64 */ 65 void setLWRequestStatus(Window changed, boolean status); 66 } 67 58 68 /* 59 69 * An interface of accessor for the java.awt.Component class. 60 70 */ 61 71 public interface ComponentAccessor { 72 /** 73 * Returns the appContext of the component. 74 */ 75 AppContext getAppContext(Component comp); 76 77 /** 78 * Sets the appContext of the component. 79 */ 80 void setAppContext(Component comp, AppContext appContext); 81 62 82 /* 63 83 * Returns the acc this component was constructed with. 64 84 */ 65 85 AccessControlContext getAccessControlContext(Component comp); 86 87 /** 88 * Requests that this Component get the input focus, if this 89 * Component's top-level ancestor is already the focused Window 90 */ 91 boolean requestFocusInWindow(Component comp, CausedFocusEvent.Cause cause); 92 93 /** 94 * Requests that this Component get the input focus, providing the cause 95 */ 96 void requestFocus(Component comp, CausedFocusEvent.Cause cause); 97 } 98 99 /** 100 * An interface of accessor for the KeyboardFocusManager class. 101 */ 102 public interface KeyboardFocusManagerAccessor { 103 /** 104 * Indicates whether the native implementation should 105 * proceed with a pending focus request for the heavyweight. 106 */ 107 int shouldNativelyFocusHeavyweight(Component heavyweight, 108 Component descendant, 109 boolean temporary, 110 boolean focusedWindowChangeAllowed, 111 long time, 112 CausedFocusEvent.Cause cause); 113 114 void removeLastFocusRequest(Component heavyweight); 66 115 } 67 116 … … 70 119 */ 71 120 public interface AWTEventAccessor { 121 /** 122 * Marks the event as posted. 123 */ 124 void setPosted(AWTEvent ev); 125 72 126 /** 73 127 * Sets the flag on this AWTEvent indicating that it was … … 81 135 boolean isSystemGenerated(AWTEvent ev); 82 136 83 84 137 /* 85 138 * Returns the acc this event was constructed with. … … 87 140 AccessControlContext getAccessControlContext(AWTEvent ev); 88 141 142 /** 143 * Returns binary data associated with this event; 144 */ 145 byte[] getBData(AWTEvent ev); 146 147 /** 148 * Associates binary data with this event; 149 */ 150 void setBData(AWTEvent ev, byte[] bdata); 151 } 152 153 /** 154 * An accessor for the MenuComponent class. 155 */ 156 public interface MenuComponentAccessor { 157 /** 158 * Returns the appContext of the menu component. 159 */ 160 AppContext getAppContext(MenuComponent menuComp); 161 162 /** 163 * Sets the appContext of the menu component. 164 */ 165 void setAppContext(MenuComponent menuComp, AppContext appContext); 166 167 /** 168 * Returns the parent container for this menu component. 169 */ 170 MenuContainer getParent(MenuComponent menuComp); 171 172 /** 173 * Gets the font used for this menu component. 174 */ 175 Font getFont_NoClientCode(MenuComponent menuComp); 176 } 177 178 /** An accessor for the EventQueue class 179 */ 180 public interface EventQueueAccessor { 181 /** 182 * Returns whether an event is pending on any of the separate Queues. 183 */ 184 boolean noEvents(EventQueue eventQueue); 185 186 /** 187 * Returns dispatch thread for the given EventQueue which has private access 188 */ 189 Thread getDispatchThread(EventQueue eventQueue); 190 191 /** 192 * Returns next queue for the given EventQueue which has private access 193 */ 194 EventQueue getNextQueue(EventQueue eventQueue); 195 196 /** 197 * Removes any pending events for the specified source object. 198 */ 199 void removeSourceEvents(EventQueue eventQueue, Object source, 200 boolean removeAllEvents); 201 } 202 203 /** 204 * An accessor for the PopupMenu class 205 */ 206 public interface PopupMenuAccessor { 207 /** 208 * Returns whether the popup menu is attached to a tray 209 */ 210 boolean isTrayIconPopup(PopupMenu popupMenu); 211 } 212 213 /** 214 * An accessor for the ScrollPaneAdjustable class. 215 */ 216 public interface ScrollPaneAdjustableAccessor { 217 /** 218 * Sets the value of this scrollbar to the specified value. 219 */ 220 void setTypedValue(final ScrollPaneAdjustable adj, final int v, 221 final int type); 222 } 223 224 /** 225 * An accessor for the CheckboxMenuItem class 226 */ 227 public interface CheckboxMenuItemAccessor { 228 /** 229 * Returns whether menu item is checked 230 */ 231 boolean getState(CheckboxMenuItem cmi); 232 } 233 234 /** 235 * An accessor for the Cursor class 236 */ 237 public interface CursorAccessor { 238 /** 239 * Returns pData of the Cursor class 240 */ 241 long getPData(Cursor cursor); 242 243 /** 244 * Sets pData to the Cursor class 245 */ 246 void setPData(Cursor cursor, long pData); 247 248 /** 249 * Return type of the Cursor class 250 */ 251 int getType(Cursor cursor); 252 } 253 254 /** 255 * An accessor for the MenuBar class 256 */ 257 public interface MenuBarAccessor { 258 /** 259 * Returns help menu 260 */ 261 Menu getHelpMenu(MenuBar menuBar); 262 263 /** 264 * Returns menus 265 */ 266 Vector getMenus(MenuBar menuBar); 267 } 268 269 /** 270 * An accessor for the MenuItem class 271 */ 272 public interface MenuItemAccessor { 273 /** 274 * Returns whether menu item is enabled 275 */ 276 boolean isEnabled(MenuItem item); 277 278 /** 279 * Gets the command name of the action event that is fired 280 * by this menu item. 281 */ 282 String getActionCommandImpl(MenuItem item); 283 284 /** 285 * Returns true if the item and all its ancestors are 286 * enabled, false otherwise 287 */ 288 boolean isItemEnabled(MenuItem item); 289 290 /** 291 * Returns label 292 */ 293 String getLabel(MenuItem item); 294 295 /** 296 * Returns shortcut 297 */ 298 MenuShortcut getShortcut(MenuItem item); 299 } 300 301 /** 302 * An accessor for the Menu class 303 */ 304 public interface MenuAccessor { 305 /** 306 * Returns vector of the items that are part of the Menu 307 */ 308 Vector getItems(Menu menu); 309 } 310 311 /** 312 * An accessor for the ClientPropertyKey class 313 */ 314 public interface ClientPropertyKeyAccessor { 315 /** 316 * Retrieves JComponent_TRANSFER_HANDLER enum object 317 */ 318 Object getJComponent_TRANSFER_HANDLER(); 319 } 320 321 /** 322 * An accessor for the DefaultKeyboardFocusManager class 323 */ 324 public interface DefaultKeyboardFocusManagerAccessor { 325 void consumeNextKeyTyped(DefaultKeyboardFocusManager dkfm, KeyEvent e); 89 326 } 90 327 … … 93 330 * corresponding AWT classes by using setters defined below. 94 331 */ 332 private static WindowAccessor windowAccessor; 95 333 private static ComponentAccessor componentAccessor; 334 private static KeyboardFocusManagerAccessor kfmAccessor; 96 335 private static AWTEventAccessor awtEventAccessor; 336 private static MenuComponentAccessor menuComponentAccessor; 337 private static EventQueueAccessor eventQueueAccessor; 338 private static PopupMenuAccessor popupMenuAccessor; 339 private static ScrollPaneAdjustableAccessor scrollPaneAdjustableAccessor; 340 private static CheckboxMenuItemAccessor checkboxMenuItemAccessor; 341 private static CursorAccessor cursorAccessor; 342 private static MenuBarAccessor menuBarAccessor; 343 private static MenuItemAccessor menuItemAccessor; 344 private static MenuAccessor menuAccessor; 345 private static ClientPropertyKeyAccessor clientPropertyKeyAccessor; 346 private static DefaultKeyboardFocusManagerAccessor defaultKeyboardFocusManagerAccessor; 347 348 /** 349 * Set an accessor object for the java.awt.Window class. 350 */ 351 public static void setWindowAccessor(WindowAccessor wa) { 352 windowAccessor = wa; 353 } 354 355 /** 356 * Retrieve the accessor object for the java.awt.Window class. 357 */ 358 public static WindowAccessor getWindowAccessor() { 359 if (windowAccessor == null) { 360 unsafe.ensureClassInitialized(Window.class); 361 } 362 363 return windowAccessor; 364 } 97 365 98 366 /* … … 114 382 } 115 383 384 /** 385 * Set an accessor object for the java.awt.KeyboardFocusManager class. 386 */ 387 public static void setKeyboardFocusManagerAccessor(KeyboardFocusManagerAccessor kfma) { 388 kfmAccessor = kfma; 389 } 390 391 /** 392 * Retrieve the accessor object for the java.awt.KeyboardFocusManager class. 393 */ 394 public static KeyboardFocusManagerAccessor getKeyboardFocusManagerAccessor() { 395 if (kfmAccessor == null) { 396 unsafe.ensureClassInitialized(KeyboardFocusManager.class); 397 } 398 return kfmAccessor; 399 } 400 116 401 /* 117 402 * Set an accessor object for the java.awt.AWTEvent class. … … 130 415 return awtEventAccessor; 131 416 } 417 418 /** 419 * Set an accessor object for the java.awt.MenuComponent class. 420 */ 421 public static void setMenuComponentAccessor(MenuComponentAccessor mca) { 422 menuComponentAccessor = mca; 423 } 424 425 /** 426 * Retrieve the accessor object for the java.awt.MenuComponent class. 427 */ 428 public static MenuComponentAccessor getMenuComponentAccessor() { 429 if (menuComponentAccessor == null) { 430 unsafe.ensureClassInitialized(MenuComponent.class); 431 } 432 433 return menuComponentAccessor; 434 } 435 436 /** 437 * Set an accessor object for the java.awt.EventQueue class. 438 */ 439 public static void setEventQueueAccessor(EventQueueAccessor eqa) { 440 eventQueueAccessor = eqa; 441 } 442 443 /** 444 * Retrieve the accessor object for the java.awt.EventQueue class. 445 */ 446 public static EventQueueAccessor getEventQueueAccessor() { 447 if (eventQueueAccessor == null) { 448 unsafe.ensureClassInitialized(EventQueue.class); 449 } 450 return eventQueueAccessor; 451 } 452 453 /** 454 * Set an accessor object for the java.awt.PopupMenu class. 455 */ 456 public static void setPopupMenuAccessor(PopupMenuAccessor pma) { 457 popupMenuAccessor = pma; 458 } 459 460 /** 461 * Retrieve the accessor object for the java.awt.PopupMenu class. 462 */ 463 public static PopupMenuAccessor getPopupMenuAccessor() { 464 if (popupMenuAccessor == null) { 465 unsafe.ensureClassInitialized(PopupMenu.class); 466 } 467 return popupMenuAccessor; 468 } 469 470 /** 471 * Set an accessor object for the java.awt.ScrollPaneAdjustable class. 472 */ 473 public static void setScrollPaneAdjustableAccessor(ScrollPaneAdjustableAccessor adj) { 474 scrollPaneAdjustableAccessor = adj; 475 } 476 477 /** 478 * Retrieve the accessor object for the java.awt.ScrollPaneAdjustable 479 * class. 480 */ 481 public static ScrollPaneAdjustableAccessor getScrollPaneAdjustableAccessor() { 482 if (scrollPaneAdjustableAccessor == null) { 483 unsafe.ensureClassInitialized(ScrollPaneAdjustable.class); 484 } 485 return scrollPaneAdjustableAccessor; 486 } 487 488 /** 489 * Set an accessor object for the java.awt.CheckboxMenuItem class. 490 */ 491 public static void setCheckboxMenuItemAccessor(CheckboxMenuItemAccessor cmia) { 492 checkboxMenuItemAccessor = cmia; 493 } 494 495 /** 496 * Retrieve the accessor object for the java.awt.CheckboxMenuItem class. 497 */ 498 public static CheckboxMenuItemAccessor getCheckboxMenuItemAccessor() { 499 if (checkboxMenuItemAccessor == null) { 500 unsafe.ensureClassInitialized(CheckboxMenuItemAccessor.class); 501 } 502 return checkboxMenuItemAccessor; 503 } 504 505 /** 506 * Set an accessor object for the java.awt.Cursor class. 507 */ 508 public static void setCursorAccessor(CursorAccessor ca) { 509 cursorAccessor = ca; 510 } 511 512 /** 513 * Retrieve the accessor object for the java.awt.Cursor class. 514 */ 515 public static CursorAccessor getCursorAccessor() { 516 if (cursorAccessor == null) { 517 unsafe.ensureClassInitialized(CursorAccessor.class); 518 } 519 return cursorAccessor; 520 } 521 522 /** 523 * Set an accessor object for the java.awt.MenuBar class. 524 */ 525 public static void setMenuBarAccessor(MenuBarAccessor mba) { 526 menuBarAccessor = mba; 527 } 528 529 /** 530 * Retrieve the accessor object for the java.awt.MenuBar class. 531 */ 532 public static MenuBarAccessor getMenuBarAccessor() { 533 if (menuBarAccessor == null) { 534 unsafe.ensureClassInitialized(MenuBarAccessor.class); 535 } 536 return menuBarAccessor; 537 } 538 539 /** 540 * Set an accessor object for the java.awt.MenuItem class. 541 */ 542 public static void setMenuItemAccessor(MenuItemAccessor mia) { 543 menuItemAccessor = mia; 544 } 545 546 /** 547 * Retrieve the accessor object for the java.awt.MenuItem class. 548 */ 549 public static MenuItemAccessor getMenuItemAccessor() { 550 if (menuItemAccessor == null) { 551 unsafe.ensureClassInitialized(MenuItemAccessor.class); 552 } 553 return menuItemAccessor; 554 } 555 556 /** 557 * Set an accessor object for the java.awt.Menu class. 558 */ 559 public static void setMenuAccessor(MenuAccessor ma) { 560 menuAccessor = ma; 561 } 562 563 /** 564 * Retrieve the accessor object for the java.awt.Menu class. 565 */ 566 public static MenuAccessor getMenuAccessor() { 567 if (menuAccessor == null) { 568 unsafe.ensureClassInitialized(MenuAccessor.class); 569 } 570 return menuAccessor; 571 } 572 573 /** 574 * Set an accessor object for the javax.swing.ClientPropertyKey class. 575 */ 576 public static void setClientPropertyKeyAccessor(ClientPropertyKeyAccessor cpka) { 577 clientPropertyKeyAccessor = cpka; 578 } 579 580 /** 581 * Retrieve the accessor object for the javax.swing.ClientPropertyKey class. 582 */ 583 public static ClientPropertyKeyAccessor getClientPropertyKeyAccessor() { 584 if (clientPropertyKeyAccessor == null) { 585 unsafe.ensureClassInitialized(ClientPropertyKeyAccessor.class); 586 } 587 return clientPropertyKeyAccessor; 588 } 589 590 /** 591 * Set an accessor object for the java.awt.DefaultKeyboardFocusManager class. 592 */ 593 public static void setDefaultKeyboardFocusManagerAccessor( 594 DefaultKeyboardFocusManagerAccessor dkfma) { 595 defaultKeyboardFocusManagerAccessor = dkfma; 596 } 597 598 /** 599 * Retrieve the accessor object for the java.awt.DefaultKeyboardFocusManager class. 600 */ 601 public static DefaultKeyboardFocusManagerAccessor getDefaultKeyboardFocusManagerAccessor() { 602 if (defaultKeyboardFocusManagerAccessor == null) { 603 unsafe.ensureClassInitialized(DefaultKeyboardFocusManagerAccessor.class); 604 } 605 return defaultKeyboardFocusManagerAccessor; 606 } 132 607 } -
trunk/openjdk/jdk/src/share/classes/sun/awt/KeyboardFocusManagerPeerImpl.java
r278 r406 31 31 import java.awt.peer.KeyboardFocusManagerPeer; 32 32 33 import java.lang.reflect.InvocationTargetException;34 import java.lang.reflect.Method;35 36 37 33 public class KeyboardFocusManagerPeerImpl implements KeyboardFocusManagerPeer { 38 34 static native Window getNativeFocusedWindow(); … … 57 53 } 58 54 59 static Method m_removeLastFocusRequest = null;60 55 public static void removeLastFocusRequest(Component heavyweight) { 61 try { 62 if (m_removeLastFocusRequest == null) { 63 m_removeLastFocusRequest = SunToolkit.getMethod(KeyboardFocusManager.class, "removeLastFocusRequest", 64 new Class[] {Component.class}); 65 } 66 m_removeLastFocusRequest.invoke(null, new Object[]{heavyweight}); 67 } catch (InvocationTargetException ite) { 68 ite.printStackTrace(); 69 } catch (IllegalAccessException ex) { 70 ex.printStackTrace(); 71 } 56 AWTAccessor.getKeyboardFocusManagerAccessor().removeLastFocusRequest(heavyweight); 72 57 } 73 58 } -
trunk/openjdk/jdk/src/share/classes/sun/awt/SunToolkit.java
r390 r406 33 33 import java.awt.event.WindowEvent; 34 34 import java.awt.event.KeyEvent; 35 import java.awt.im.spi.InputMethodDescriptor;36 35 import java.awt.image.*; 37 import java.awt.geom.AffineTransform;38 36 import java.awt.TrayIcon; 39 37 import java.awt.SystemTray; 40 import java.io.*;41 38 import java.net.URL; 42 import java.net.JarURLConnection;43 39 import java.util.*; 44 40 import java.util.concurrent.TimeUnit; … … 50 46 import sun.font.FontDesignMetrics; 51 47 import sun.awt.im.InputContext; 52 import sun.awt.im.SimpleInputMethodWindow;53 48 import sun.awt.image.*; 54 49 import sun.security.action.GetPropertyAction; 55 50 import sun.security.action.GetBooleanAction; 56 import java.lang.reflect.Field;57 51 import java.lang.reflect.Method; 58 52 import java.lang.reflect.Constructor; … … 60 54 import java.security.AccessController; 61 55 import java.security.PrivilegedAction; 62 import java.security.PrivilegedActionException;63 import java.security.PrivilegedExceptionAction;64 56 65 57 public abstract class SunToolkit extends Toolkit … … 83 75 public static final int GRAB_EVENT_MASK = 0x80000000; 84 76 85 private static Field syncLWRequestsField;86 77 private static Method wakeupMethod; 87 private static Field componentKeyField;88 private static Field menuComponentKeyField;89 private static Field trayIconKeyField;90 private static Field componentAppContextField;91 private static Field menuComponentAppContextField;92 private static Field isPostedField;93 78 /* The key to put()/get() the PostEventQueue into/from the AppContext. 94 79 */ … … 327 312 } 328 313 329 public static Field getField(final Class klass, final String fieldName) {330 return AccessController.doPrivileged(new PrivilegedAction<Field>() {331 public Field run() {332 try {333 Field field = klass.getDeclaredField(fieldName);334 assert (field != null);335 field.setAccessible(true);336 return field;337 } catch (SecurityException e) {338 assert false;339 } catch (NoSuchFieldException e) {340 assert false;341 }342 return null;343 }//run344 });345 }346 347 314 static void wakeupEventQueue(EventQueue q, boolean isShutdown){ 348 315 if (wakeupMethod == null){ … … 418 385 private static boolean setAppContext(Object target, AppContext context) 419 386 { 420 if (!(target instanceof Component) && !(target instanceof MenuComponent)) { 387 if (target instanceof Component) { 388 AWTAccessor.getComponentAccessor(). 389 setAppContext((Component)target, context); 390 } else if (target instanceof MenuComponent) { 391 AWTAccessor.getMenuComponentAccessor(). 392 setAppContext((MenuComponent)target, context); 393 } else { 421 394 return false; 422 395 } 423 try{424 if (target instanceof Component){425 if (componentAppContextField == null) {426 componentAppContextField = getField(Component.class, "appContext");427 }428 componentAppContextField.set(target, context);429 } else if (target instanceof MenuComponent) {430 if (menuComponentAppContextField == null) {431 menuComponentAppContextField = getField(MenuComponent.class, "appContext");432 }433 menuComponentAppContextField.set(target, context);434 }435 } catch( IllegalAccessException e){436 assert false;437 }438 439 396 return true; 440 397 } … … 445 402 */ 446 403 private static AppContext getAppContext(Object target) { 447 AppContext retObj = null; 448 try{ 449 if (target instanceof Component){ 450 if (componentAppContextField == null) { 451 componentAppContextField = getField(Component.class, "appContext"); 452 } 453 retObj = (AppContext) componentAppContextField.get(target); 454 } else if (target instanceof MenuComponent) { 455 if (menuComponentAppContextField == null) { 456 menuComponentAppContextField = getField(MenuComponent.class, "appContext"); 457 } 458 retObj = (AppContext) menuComponentAppContextField.get(target); 459 } 460 } catch( IllegalAccessException e){ 461 assert false; 462 } 463 return retObj; 404 if (target instanceof Component) { 405 return AWTAccessor.getComponentAccessor(). 406 getAppContext((Component)target); 407 } else if (target instanceof MenuComponent) { 408 return AWTAccessor.getMenuComponentAccessor(). 409 getAppContext((MenuComponent)target); 410 } else { 411 return null; 412 } 464 413 } 465 414 … … 509 458 510 459 public static void setLWRequestStatus(Window changed,boolean status){ 511 if (syncLWRequestsField == null){ 512 syncLWRequestsField = getField(Window.class, "syncLWRequests"); 513 } 514 try{ 515 if (syncLWRequestsField != null){ 516 syncLWRequestsField.setBoolean(changed, status); 517 } 518 } catch( IllegalAccessException e){ 519 assert false; 520 } 460 AWTAccessor.getWindowAccessor().setLWRequestStatus(changed, status); 521 461 }; 522 462 … … 626 566 */ 627 567 public static void postPriorityEvent(final AWTEvent e) { 628 if (isPostedField == null) {629 isPostedField = getField(AWTEvent.class, "isPosted");630 }631 568 PeerEvent pe = new PeerEvent(Toolkit.getDefaultToolkit(), new Runnable() { 632 569 public void run() { 633 try { 634 isPostedField.setBoolean(e, true); 635 } catch (IllegalArgumentException e) { 636 assert(false); 637 } catch (IllegalAccessException e) { 638 assert(false); 639 } 570 AWTAccessor.getAWTEventAccessor().setPosted(e); 640 571 ((Component)e.getSource()).dispatchEvent(e); 641 572 } … … 746 677 747 678 /* 748 * Returns next queue for the given EventQueue which has private access749 */750 private static EventQueue getNextQueue(final Object o) {751 EventQueue result = null;752 try{753 Field nextQueueField = getField(EventQueue.class,754 "nextQueue");755 result = (EventQueue)nextQueueField.get(o);756 } catch( IllegalAccessException e){757 assert false;758 }759 return result;760 }761 762 /*763 * Returns dispatch thread for the given EventQueue which has private access764 */765 private static Thread getDispatchThread(final Object o) {766 Thread result = null;767 try{768 Field dispatchThreadField = getField(EventQueue.class,769 "dispatchThread");770 result = (Thread)dispatchThreadField.get(o);771 } catch( IllegalAccessException e){772 assert false;773 }774 return result;775 }776 777 /*778 679 * Returns true if the calling thread is the event dispatch thread 779 680 * contained within AppContext which associated with the given target. … … 785 686 EventQueue eq = (EventQueue)appContext.get(AppContext.EVENT_QUEUE_KEY); 786 687 787 EventQueue next = getNextQueue(eq);688 EventQueue next = AWTAccessor.getEventQueueAccessor().getNextQueue(eq); 788 689 while (next != null) { 789 690 eq = next; 790 next = getNextQueue(eq); 791 } 792 793 return (Thread.currentThread() == getDispatchThread(eq)); 691 next = AWTAccessor.getEventQueueAccessor().getNextQueue(eq); 692 } 693 694 return (Thread.currentThread() == AWTAccessor.getEventQueueAccessor() 695 .getDispatchThread(eq)); 794 696 } 795 697 … … 1525 1427 } 1526 1428 1527 public static Method getMethod(final Class clz, final String methodName, final Class[] params) {1528 Method res = null;1529 try {1530 res = AccessController.doPrivileged(new PrivilegedExceptionAction<Method>() {1531 public Method run() throws Exception {1532 Method m = clz.getDeclaredMethod(methodName, params);1533 m.setAccessible(true);1534 return m;1535 }1536 });1537 } catch (PrivilegedActionException ex) {1538 ex.printStackTrace();1539 }1540 return res;1541 }1542 1543 1429 public static class OperationTimedOut extends RuntimeException { 1544 1430 public OperationTimedOut(String msg) { … … 1683 1569 private final Object waitLock = "Wait Lock"; 1684 1570 1685 static Method eqNoEvents;1686 1687 1571 private boolean isEQEmpty() { 1688 1572 EventQueue queue = getSystemEventQueueImpl(); 1689 synchronized(SunToolkit.class) { 1690 if (eqNoEvents == null) { 1691 eqNoEvents = getMethod(java.awt.EventQueue.class, "noEvents", null); 1692 } 1693 } 1694 try { 1695 return (Boolean)eqNoEvents.invoke(queue); 1696 } catch (Exception e) { 1697 e.printStackTrace(); 1698 return false; 1699 } 1573 return AWTAccessor.getEventQueueAccessor().noEvents(queue); 1700 1574 } 1701 1575 … … 1952 1826 * however Swing could use it in the future. 1953 1827 */ 1954 private static Method consumeNextKeyTypedMethod = null;1955 1828 public static synchronized void consumeNextKeyTyped(KeyEvent keyEvent) { 1956 if (consumeNextKeyTypedMethod == null) {1957 consumeNextKeyTypedMethod = getMethod(DefaultKeyboardFocusManager.class,1958 "consumeNextKeyTyped",1959 new Class[] {KeyEvent.class});1960 }1961 1829 try { 1962 consumeNextKeyTypedMethod.invoke(KeyboardFocusManager.getCurrentKeyboardFocusManager(),1963 keyEvent);1964 } catch (IllegalAccessException iae) {1965 iae.printStackTrace();1966 } catch ( InvocationTargetException ite) {1967 ite.printStackTrace();1830 AWTAccessor.getDefaultKeyboardFocusManagerAccessor().consumeNextKeyTyped( 1831 (DefaultKeyboardFocusManager)KeyboardFocusManager. 1832 getCurrentKeyboardFocusManager(), 1833 keyEvent); 1834 } catch (ClassCastException cce) { 1835 cce.printStackTrace(); 1968 1836 } 1969 1837 } -
trunk/openjdk/jdk/src/share/classes/sun/misc/IOUtils.java
r278 r406 1 1 /* 2 * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 31 31 32 32 import java.io.EOFException; 33 import java.io.File; 33 34 import java.io.IOException; 34 35 import java.io.InputStream; … … 78 79 return output; 79 80 } 81 82 /* 83 * <p> Creates a new empty file in the specified directory, using the 84 * given prefix and suffix strings to generate its name. The resulting 85 * temporary file may have more restrictive access permission on some 86 * platforms. 87 * 88 * @param prefix The prefix string to be used in generating the file's 89 * name; must be at least three characters long 90 * 91 * @param suffix The suffix string to be used in generating the file's 92 * name; may be <code>null</code>, in which case the 93 * suffix <code>".tmp"</code> will be used 94 * 95 * @param directory The directory in which the file is to be created, or 96 * <code>null</code> if the default temporary-file 97 * directory is to be used 98 * 99 * @return An abstract pathname denoting a newly-created empty file 100 * 101 * @see java.io.File#createTempFile(String,String,java.io.File) 102 */ 103 public static File createTempFile(String prefix, String suffix, File directory) 104 throws IOException 105 { 106 return SharedSecrets.getJavaIOFileAccess().createTempFile(prefix, suffix, directory); 107 } 108 109 public static File createTempFile(String prefix, String suffix) 110 throws IOException 111 { 112 return SharedSecrets.getJavaIOFileAccess().createTempFile(prefix, suffix, null); 113 } 80 114 } -
trunk/openjdk/jdk/src/share/classes/sun/misc/Service.java
r278 r406 285 285 String cn = nextName; 286 286 nextName = null; 287 Class<?> c = null; 287 288 try { 288 return Class.forName(cn, true, loader).newInstance();289 c = Class.forName(cn, false, loader); 289 290 } catch (ClassNotFoundException x) { 290 291 fail(service, 291 292 "Provider " + cn + " not found"); 292 } catch (Exception x) { 293 } 294 if (!service.isAssignableFrom(c)) { 295 fail(service, 296 "Provider " + cn + " not a subtype"); 297 } 298 try { 299 return service.cast(c.newInstance()); 300 } catch (Throwable x) { 293 301 fail(service, 294 302 "Provider " + cn + " could not be instantiated: " + x, -
trunk/openjdk/jdk/src/share/classes/sun/misc/SharedSecrets.java
r390 r406 1 1 /* 2 * Copyright (c) 2002, 201 1, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2002, 2012, 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 JavaSecurityAccess javaSecurityAccess; 55 55 private static JavaAWTAccess javaAWTAccess; 56 private static JavaIOFileAccess javaIOFileAccess; 56 57 57 58 public static JavaUtilJarAccess javaUtilJarAccess() { … … 150 151 return javaAWTAccess; 151 152 } 153 154 public static void setJavaIOFileAccess(JavaIOFileAccess access) { 155 javaIOFileAccess = access; 156 } 157 158 public static JavaIOFileAccess getJavaIOFileAccess() { 159 return javaIOFileAccess; 160 } 152 161 } -
trunk/openjdk/jdk/src/share/classes/sun/net/www/protocol/jar/URLJarFile.java
r278 r406 1 1 /* 2 * Copyright (c) 2001, 20 06, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 220 220 File tmpFile = null; 221 221 try { 222 tmpFile = File.createTempFile("jar_cache", null);222 tmpFile = sun.misc.IOUtils.createTempFile("jar_cache", null); 223 223 tmpFile.deleteOnExit(); 224 224 out = new FileOutputStream(tmpFile); -
trunk/openjdk/jdk/src/share/classes/sun/print/PSPrinterJob.java
r278 r406 1 1 /* 2 * Copyright (c) 1998, 20 07, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 653 653 * removed when the VM exits. 654 654 */ 655 spoolFile = File.createTempFile("javaprint", ".ps", null);655 spoolFile = sun.misc.IOUtils.createTempFile("javaprint", ".ps", null); 656 656 spoolFile.deleteOnExit(); 657 657 -
trunk/openjdk/jdk/src/share/classes/sun/rmi/registry/RegistryImpl.java
r390 r406 1 1 /* 2 * Copyright (c) 1996, 201 1, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 406 406 perms.add(new SocketPermission("*", "connect,accept")); 407 407 408 perms.add(new RuntimePermission("accessClassInPackage.sun.*")); 408 perms.add(new RuntimePermission("accessClassInPackage.sun.jvmstat.*")); 409 perms.add(new RuntimePermission("accessClassInPackage.sun.jvm.hotspot.*")); 409 410 410 411 perms.add(new FilePermission("<<ALL FILES>>", "read")); -
trunk/openjdk/jdk/src/share/classes/sun/rmi/server/Activation.java
r278 r406 1 1 /* 2 * Copyright (c) 1997, 20 06, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 1917 1917 public Void run() throws IOException { 1918 1918 File file = 1919 File.createTempFile("rmid-err", null, null);1919 sun.misc.IOUtils.createTempFile("rmid-err", null, null); 1920 1920 PrintStream errStream = 1921 1921 new PrintStream(new FileOutputStream(file)); -
trunk/openjdk/jdk/src/share/classes/sun/security/pkcs11/P11Cipher.java
r278 r406 1 1 /* 2 * Copyright (c) 2003, 201 0, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 651 651 protected int engineGetKeySize(Key key) throws InvalidKeyException { 652 652 int n = P11SecretKeyFactory.convertKey 653 (token, key, keyAlgorithm). keyLength();653 (token, key, keyAlgorithm).length(); 654 654 return n; 655 655 } -
trunk/openjdk/jdk/src/share/classes/sun/security/pkcs11/P11Key.java
r278 r406 1 1 /* 2 * Copyright (c) 2003, 201 0, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2003, 2012, 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 48 48 import sun.security.util.DerValue; 49 import sun.security.util.Length; 49 50 50 51 /** … … 62 63 * @since 1.5 63 64 */ 64 abstract class P11Key implements Key {65 abstract class P11Key implements Key, Length { 65 66 66 67 private final static String PUBLIC = "public"; … … 213 214 } 214 215 215 int keyLength() { 216 /** 217 * Return bit length of the key. 218 */ 219 @Override 220 public int length() { 216 221 return keyLength; 217 222 } -
trunk/openjdk/jdk/src/share/classes/sun/security/pkcs11/P11RSACipher.java
r278 r406 1 1 /* 2 * Copyright (c) 2003, 201 0, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 202 202 throw new InvalidKeyException("Unknown key type: " + p11Key); 203 203 } 204 int n = (p11Key. keyLength() + 7) >> 3;204 int n = (p11Key.length() + 7) >> 3; 205 205 outputSize = n; 206 206 buffer = new byte[n]; … … 459 459 // see JCE spec 460 460 protected int engineGetKeySize(Key key) throws InvalidKeyException { 461 int n = P11KeyFactory.convertKey(token, key, algorithm). keyLength();461 int n = P11KeyFactory.convertKey(token, key, algorithm).length(); 462 462 return n; 463 463 } -
trunk/openjdk/jdk/src/share/classes/sun/security/pkcs11/P11Signature.java
r278 r406 1 1 /* 2 * Copyright (c) 2003, 201 0, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 275 275 signature = new byte[40]; 276 276 } else { 277 signature = new byte[(p11Key. keyLength() + 7) >> 3];277 signature = new byte[(p11Key.length() + 7) >> 3]; 278 278 } 279 279 if (type == T_UPDATE) { … … 360 360 int keyLen; 361 361 if (publicKey instanceof P11Key) { 362 keyLen = ((P11Key) publicKey). keyLength();362 keyLen = ((P11Key) publicKey).length(); 363 363 } else { 364 364 keyLen = ((RSAKey) publicKey).getModulus().bitLength(); … … 621 621 private byte[] pkcs1Pad(byte[] data) { 622 622 try { 623 int len = (p11Key. keyLength() + 7) >> 3;623 int len = (p11Key.length() + 7) >> 3; 624 624 RSAPadding padding = RSAPadding.getInstance 625 625 (RSAPadding.PAD_BLOCKTYPE_1, len); -
trunk/openjdk/jdk/src/share/classes/sun/security/provider/SecureRandom.java
r278 r406 1 1 /* 2 * Copyright (c) 1998, 20 03, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 56 56 57 57 private static final long serialVersionUID = 3581829991155417889L; 58 59 /**60 * This static object will be seeded by SeedGenerator, and used61 * to seed future instances of SecureRandom62 */63 private static SecureRandom seeder;64 58 65 59 private static final int DIGEST_SIZE = 20; … … 174 168 175 169 /** 170 * This static object will be seeded by SeedGenerator, and used 171 * to seed future instances of SHA1PRNG SecureRandoms. 172 * 173 * Bloch, Effective Java Second Edition: Item 71 174 */ 175 private static class SeederHolder { 176 177 private static final SecureRandom seeder; 178 179 static { 180 /* 181 * Call to SeedGenerator.generateSeed() to add additional 182 * seed material (likely from the Native implementation). 183 */ 184 seeder = new SecureRandom(SeedGenerator.getSystemEntropy()); 185 byte [] b = new byte[DIGEST_SIZE]; 186 SeedGenerator.generateSeed(b); 187 seeder.engineSetSeed(b); 188 } 189 } 190 191 /** 176 192 * Generates a user-specified number of random bytes. 177 193 * … … 184 200 185 201 if (state == null) { 186 if (seeder == null) {187 seeder = new SecureRandom(SeedGenerator.getSystemEntropy());188 seeder.engineSetSeed(engineGenerateSeed(DIGEST_SIZE));189 }190 191 202 byte[] seed = new byte[DIGEST_SIZE]; 192 seeder.engineNextBytes(seed);203 SeederHolder.seeder.engineNextBytes(seed); 193 204 state = digest.digest(seed); 194 205 } -
trunk/openjdk/jdk/src/share/classes/sun/security/ssl/AppOutputStream.java
r390 r406 1 1 /* 2 * Copyright (c) 1996, 201 11Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 89 89 try { 90 90 do { 91 boolean holdRecord = false; 91 92 int howmuch; 92 93 if (isFirstRecordOfThePayload && c.needToSplitPayload()) { 93 94 howmuch = (len == 0) ? 0 : Math.min( 94 95 0x01, r.availableDataBytes()); 96 /* 97 * Nagle's algorithm (TCP_NODELAY) was coming into 98 * play here when writing short (split) packets. 99 * Signal to the OutputRecord code to internally 100 * buffer this small packet until the next outbound 101 * packet (of any type) is written. 102 */ 103 if ((len != 1) && (howmuch == 1)) { 104 holdRecord = true; 105 } 95 106 } else { 96 107 howmuch = Math.min(len, r.availableDataBytes()); … … 106 117 len -= howmuch; 107 118 } 108 c.writeRecord(r );119 c.writeRecord(r, holdRecord); 109 120 c.checkWrite(); 110 121 } while (len > 0); -
trunk/openjdk/jdk/src/share/classes/sun/security/ssl/EngineOutputRecord.java
r309 r406 1 1 /* 2 * Copyright (c) 2003, 201 1, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 156 156 * generated. 157 157 */ 158 void writeBuffer(OutputStream s, byte [] buf, int off, int len) 159 throws IOException { 158 @Override 159 void writeBuffer(OutputStream s, byte [] buf, int off, int len, 160 int debugOffset) throws IOException { 160 161 /* 161 162 * Copy data out of buffer, it's ready to go. … … 197 198 addMAC(writeMAC); 198 199 encrypt(writeCipher); 199 write((OutputStream)null); // send down for processing 200 write((OutputStream)null, false, // send down for processing 201 (ByteArrayOutputStream)null); 200 202 } 201 203 return; -
trunk/openjdk/jdk/src/share/classes/sun/security/ssl/HandshakeInStream.java
r278 r406 1 1 /* 2 * Copyright (c) 1996, 20 07, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 191 191 byte[] getBytes8() throws IOException { 192 192 int len = getInt8(); 193 verifyLength(len); 193 194 byte b[] = new byte[len]; 194 195 … … 199 200 byte[] getBytes16() throws IOException { 200 201 int len = getInt16(); 202 verifyLength(len); 201 203 byte b[] = new byte[len]; 202 204 … … 207 209 byte[] getBytes24() throws IOException { 208 210 int len = getInt24(); 211 verifyLength(len); 209 212 byte b[] = new byte[len]; 210 213 … … 213 216 } 214 217 218 // Is a length greater than available bytes in the record? 219 private void verifyLength(int len) throws SSLException { 220 if (len > available()) { 221 throw new SSLException( 222 "Not enough data to fill declared vector size"); 223 } 224 } 225 215 226 } -
trunk/openjdk/jdk/src/share/classes/sun/security/ssl/Handshaker.java
r278 r406 1 1 /* 2 * Copyright (c) 1996, 201 0, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 777 777 System.out.println("RSA master secret generation error:"); 778 778 e.printStackTrace(System.out); 779 System.out.println("Generating new random premaster secret");780 779 } 781 preMasterSecret = RSAClientKeyExchange.generateDummySecret(protocolVersion); 780 preMasterSecret = 781 RSAClientKeyExchange.generateDummySecret(protocolVersion); 782 782 // recursive call with new premaster secret 783 783 return calculateMasterSecret(preMasterSecret, null); … … 822 822 + protocolVersion + " or " + requestedVersion + ", decrypted: " 823 823 + premasterVersion); 824 System.out.println("Generating new random premaster secret");825 }826 preMasterSecret =RSAClientKeyExchange.generateDummySecret(protocolVersion);824 } 825 preMasterSecret = 826 RSAClientKeyExchange.generateDummySecret(protocolVersion); 827 827 // recursive call with new premaster secret 828 828 return calculateMasterSecret(preMasterSecret, null); -
trunk/openjdk/jdk/src/share/classes/sun/security/ssl/OutputRecord.java
r278 r406 1 1 /* 2 * Copyright (c) 1996, 201 0, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 29 29 import java.io.*; 30 30 import java.nio.*; 31 import java.util.Arrays; 31 32 32 33 import javax.net.ssl.SSLException; … … 228 229 229 230 /* 231 * Increases the capacity if necessary to ensure that it can hold 232 * at least the number of elements specified by the minimum 233 * capacity argument. 234 * 235 * Note that the increased capacity is only can be used for held 236 * record buffer. Please DO NOT update the availableDataBytes() 237 * according to the expended buffer capacity. 238 * 239 * @see availableDataBytes() 240 */ 241 private void ensureCapacity(int minCapacity) { 242 // overflow-conscious code 243 if (minCapacity > buf.length) { 244 buf = Arrays.copyOf(buf, minCapacity); 245 } 246 } 247 248 /* 230 249 * Return the type of SSL record that's buffered here. 231 250 */ … … 244 263 * in a single low level write, for efficiency. 245 264 */ 246 void write(OutputStream s) throws IOException { 265 void write(OutputStream s, boolean holdRecord, 266 ByteArrayOutputStream heldRecordBuffer) throws IOException { 247 267 /* 248 268 * Don't emit content-free records. (Even change cipher spec … … 301 321 firstMessage = false; 302 322 303 writeBuffer(s, buf, 0, count); 323 /* 324 * The upper levels may want us to delay sending this packet so 325 * multiple TLS Records can be sent in one (or more) TCP packets. 326 * If so, add this packet to the heldRecordBuffer. 327 * 328 * NOTE: all writes have been synchronized by upper levels. 329 */ 330 int debugOffset = 0; 331 if (holdRecord) { 332 /* 333 * If holdRecord is true, we must have a heldRecordBuffer. 334 * 335 * Don't worry about the override of writeBuffer(), because 336 * when holdRecord is true, the implementation in this class 337 * will be used. 338 */ 339 writeBuffer(heldRecordBuffer, buf, 0, count, debugOffset); 340 } else { 341 // It's time to send, do we have buffered data? 342 // May or may not have a heldRecordBuffer. 343 if (heldRecordBuffer != null && heldRecordBuffer.size() > 0) { 344 int heldLen = heldRecordBuffer.size(); 345 346 // Ensure the capacity of this buffer. 347 ensureCapacity(count + heldLen); 348 349 // Slide everything in the buffer to the right. 350 System.arraycopy(buf, 0, buf, heldLen, count); 351 352 // Prepend the held record to the buffer. 353 System.arraycopy( 354 heldRecordBuffer.toByteArray(), 0, buf, 0, heldLen); 355 count += heldLen; 356 357 // Clear the held buffer. 358 heldRecordBuffer.reset(); 359 360 // The held buffer has been dumped, set the debug dump offset. 361 debugOffset = heldLen; 362 } 363 writeBuffer(s, buf, 0, count, debugOffset); 364 } 304 365 reset(); 305 366 } … … 310 371 * action. 311 372 */ 312 void writeBuffer(OutputStream s, byte [] buf, int off, int len )313 throws IOException {373 void writeBuffer(OutputStream s, byte [] buf, int off, int len, 374 int debugOffset) throws IOException { 314 375 s.write(buf, off, len); 315 376 s.flush(); 316 377 378 // Output only the record from the specified debug offset. 317 379 if (debug != null && Debug.isOn("packet")) { 318 380 try { 319 381 HexDumpEncoder hd = new HexDumpEncoder(); 320 ByteBuffer bb = ByteBuffer.wrap(buf, off, len); 382 ByteBuffer bb = ByteBuffer.wrap( 383 buf, off + debugOffset, len - debugOffset); 321 384 322 385 System.out.println("[Raw write]: length = " + -
trunk/openjdk/jdk/src/share/classes/sun/security/ssl/RSAClientKeyExchange.java
r278 r406 1 1 /* 2 * Copyright (c) 1996, 20 07, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 37 37 38 38 import sun.security.internal.spec.TlsRsaPremasterSecretParameterSpec; 39 import sun.security.util.KeyLength; 39 40 40 41 /** … … 86 87 * server's public key, and uses PKCS #1 block format 02. 87 88 */ 88 RSAClientKeyExchange(ProtocolVersion protocolVersion, ProtocolVersion maxVersion, 89 RSAClientKeyExchange(ProtocolVersion protocolVersion, 90 ProtocolVersion maxVersion, 89 91 SecureRandom generator, PublicKey publicKey) throws IOException { 90 92 if (publicKey.getAlgorithm().equals("RSA") == false) { … … 121 123 * it with its private key. 122 124 */ 123 RSAClientKeyExchange(ProtocolVersion currentVersion, HandshakeInStream input, 125 RSAClientKeyExchange(ProtocolVersion currentVersion, 126 ProtocolVersion maxVersion, HandshakeInStream input, 124 127 int messageSize, PrivateKey privateKey) throws IOException { 125 128 … … 144 147 preMaster = (SecretKey)cipher.unwrap(encrypted, 145 148 "TlsRsaPremasterSecret", Cipher.SECRET_KEY); 149 150 // polish the premaster secret 151 preMaster = polishPreMasterSecretKey( 152 currentVersion, maxVersion, preMaster, null); 146 153 } catch (Exception e) { 147 /* 148 * Bogus decrypted ClientKeyExchange? If so, conjure a 149 * a random preMaster secret that will fail later during 150 * Finished message processing. This is a countermeasure against 151 * the "interactive RSA PKCS#1 encryption envelop attack" reported 152 * in June 1998. Preserving the executation path will 153 * mitigate timing attacks and force consistent error handling 154 * that will prevent an attacking client from differentiating 155 * different kinds of decrypted ClientKeyExchange bogosities. 156 */ 157 if (debug != null && Debug.isOn("handshake")) { 158 System.out.println("Error decrypting premaster secret:"); 159 e.printStackTrace(System.out); 160 System.out.println("Generating random secret"); 154 // polish the premaster secret 155 preMaster = polishPreMasterSecretKey( 156 currentVersion, maxVersion, preMaster, e); 157 } 158 } 159 160 /** 161 * To avoid vulnerabilities described by section 7.4.7.1, RFC 5246, 162 * treating incorrectly formatted message blocks and/or mismatched 163 * version numbers in a manner indistinguishable from correctly 164 * formatted RSA blocks. 165 * 166 * RFC 5246 describes the approach as : 167 * 168 * 1. Generate a string R of 46 random bytes 169 * 170 * 2. Decrypt the message to recover the plaintext M 171 * 172 * 3. If the PKCS#1 padding is not correct, or the length of message 173 * M is not exactly 48 bytes: 174 * pre_master_secret = ClientHello.client_version || R 175 * else If ClientHello.client_version <= TLS 1.0, and version 176 * number check is explicitly disabled: 177 * pre_master_secret = M 178 * else: 179 * pre_master_secret = ClientHello.client_version || M[2..47] 180 * 181 * Note that although TLS 1.2 is not supported in this release, we still 182 * want to make use of the above approach to provide better protection. 183 */ 184 private SecretKey polishPreMasterSecretKey( 185 ProtocolVersion currentVersion, ProtocolVersion clientHelloVersion, 186 SecretKey secretKey, Exception failoverException) { 187 188 if (failoverException == null && secretKey != null) { 189 // check the length 190 byte[] encoded = secretKey.getEncoded(); 191 if (encoded == null) { // unable to get the encoded key 192 if (debug != null && Debug.isOn("handshake")) { 193 System.out.println( 194 "unable to get the plaintext of the premaster secret"); 195 } 196 197 int keySize = KeyLength.getKeySize(secretKey); 198 if (keySize > 0 && keySize != 384) { // 384 = 48 * 8 199 if (debug != null && Debug.isOn("handshake")) { 200 System.out.println( 201 "incorrect length of premaster secret: " + 202 (keySize/8)); 203 } 204 205 return generateDummySecret(currentVersion); 206 } 207 208 // The key size is exactly 48 bytes or not accessible. 209 // 210 // Conservatively, pass the checking to master secret 211 // calculation. 212 return secretKey; 213 } else if (encoded.length == 48) { 214 // check the version 215 if (clientHelloVersion.major == encoded[0] && 216 clientHelloVersion.minor == encoded[1]) { 217 218 return secretKey; 219 } else if (clientHelloVersion.v <= ProtocolVersion.TLS10.v && 220 currentVersion.major == encoded[0] && 221 currentVersion.minor == encoded[1]) { 222 /* 223 * For compatibility, we maintain the behavior that the 224 * version in pre_master_secret can be the negotiated 225 * version for TLS v1.0 and SSL v3.0. 226 */ 227 return secretKey; 228 } 229 230 if (debug != null && Debug.isOn("handshake")) { 231 System.out.println("Mismatching Protocol Versions, " + 232 "ClientHello.client_version is " + clientHelloVersion + 233 ", while PreMasterSecret.client_version is " + 234 ProtocolVersion.valueOf(encoded[0], encoded[1])); 235 } 236 return generateDummySecret(currentVersion); 237 } else { 238 if (debug != null && Debug.isOn("handshake")) { 239 System.out.println( 240 "incorrect length of premaster secret: " + 241 encoded.length); 242 } 243 return generateDummySecret(currentVersion); 161 244 } 162 preMaster = generateDummySecret(currentVersion); 163 } 245 } 246 247 if (debug != null && Debug.isOn("handshake") && 248 failoverException != null) { 249 System.out.println("Error decrypting premaster secret:"); 250 failoverException.printStackTrace(System.out); 251 } 252 253 return generateDummySecret(currentVersion); 164 254 } 165 255 166 256 // generate a premaster secret with the specified version number 167 257 static SecretKey generateDummySecret(ProtocolVersion version) { 258 if (debug != null && Debug.isOn("handshake")) { 259 System.out.println("Generating a random fake premaster secret"); 260 } 261 168 262 try { 169 263 KeyGenerator kg = -
trunk/openjdk/jdk/src/share/classes/sun/security/ssl/SSLSocketImpl.java
r309 r406 1 1 /* 2 * Copyright (c) 1996, 201 1, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 364 364 private boolean isFirstAppOutputRecord = true; 365 365 366 /* 367 * If AppOutputStream needs to delay writes of small packets, we 368 * will use this to store the data until we actually do the write. 369 */ 370 private ByteArrayOutputStream heldRecordBuffer = null; 371 366 372 // 367 373 // CONSTRUCTORS AND INITIALIZATION CODE … … 629 635 630 636 /* 637 * AppOutputStream calls may need to buffer multiple outbound 638 * application packets. 639 * 640 * All other writeRecord() calls will not buffer, so do not hold 641 * these records. 642 */ 643 void writeRecord(OutputRecord r) throws IOException { 644 writeRecord(r, false); 645 } 646 647 /* 631 648 * Record Output. Application data can't be sent until the first 632 649 * handshake establishes a session. … … 635 652 * TCP-level activity, notably handshaking, to occur. 636 653 */ 637 void writeRecord(OutputRecord r ) throws IOException {654 void writeRecord(OutputRecord r, boolean holdRecord) throws IOException { 638 655 /* 639 656 * The loop is in case of HANDSHAKE --> ERROR transitions, etc … … 706 723 if (writeLock.tryLock(getSoLinger(), TimeUnit.SECONDS)) { 707 724 try { 708 writeRecordInternal(r );725 writeRecordInternal(r, holdRecord); 709 726 } finally { 710 727 writeLock.unlock(); … … 754 771 writeLock.lock(); 755 772 try { 756 writeRecordInternal(r );773 writeRecordInternal(r, holdRecord); 757 774 } finally { 758 775 writeLock.unlock(); … … 762 779 } 763 780 764 private void writeRecordInternal(OutputRecord r) throws IOException { 781 private void writeRecordInternal(OutputRecord r, 782 boolean holdRecord) throws IOException { 765 783 // r.compress(c); 766 784 r.addMAC(writeMAC); 767 785 r.encrypt(writeCipher); 768 r.write(sockOutput); 786 if (holdRecord) { 787 // If we were requested to delay the record due to possibility 788 // of Nagle's being active when finally got to writing, and 789 // it's actually not, we don't really need to delay it. 790 if (getTcpNoDelay()) { 791 holdRecord = false; 792 } else { 793 // We need to hold the record, so let's provide 794 // a per-socket place to do it. 795 if (heldRecordBuffer == null) { 796 // Likely only need 37 bytes. 797 heldRecordBuffer = new ByteArrayOutputStream(40); 798 } 799 } 800 } 801 r.write(sockOutput, holdRecord, heldRecordBuffer); 769 802 770 803 // turn off the flag of the first application record -
trunk/openjdk/jdk/src/share/classes/sun/security/ssl/ServerHandshaker.java
r278 r406 1 1 /* 2 * Copyright (c) 1996, 201 0, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 191 191 * certificates/keys. 192 192 */ 193 RSAClientKeyExchange pms = new RSAClientKeyExchange 194 (protocolVersion, input, message_len, privateKey); 193 RSAClientKeyExchange pms = new RSAClientKeyExchange( 194 protocolVersion, clientRequestedVersion, 195 input, message_len, privateKey); 195 196 preMasterSecret = this.clientKeyExchange(pms); 196 197 break; -
trunk/openjdk/jdk/src/share/classes/sun/security/x509/CRLExtensions.java
r278 r406 33 33 import java.security.cert.CertificateException; 34 34 import java.util.Collection; 35 import java.util.Collections; 35 36 import java.util.Enumeration; 36 import java.util.Hashtable; 37 import java.util.Map; 38 import java.util.TreeMap; 37 39 38 40 import sun.security.util.*; … … 63 65 public class CRLExtensions { 64 66 65 private Hashtable<String,Extension> map = new Hashtable<String,Extension>(); 67 private Map<String,Extension> map = Collections.synchronizedMap( 68 new TreeMap<String,Extension>()); 66 69 private boolean unsupportedCritExt = false; 67 70 … … 216 219 */ 217 220 public Enumeration<Extension> getElements() { 218 return map.elements();221 return Collections.enumeration(map.values()); 219 222 } 220 223 -
trunk/openjdk/jdk/src/share/classes/sun/security/x509/CertificateExtensions.java
r278 r406 58 58 private static final Debug debug = Debug.getInstance("x509"); 59 59 60 private Hashtable<String,Extension> map = new Hashtable<String,Extension>(); 60 private Map<String,Extension> map = Collections.synchronizedMap( 61 new TreeMap<String,Extension>()); 61 62 private boolean unsupportedCritExt = false; 62 63 … … 118 119 // ignore errors parsing non-critical extensions 119 120 if (unparseableExtensions == null) { 120 unparseableExtensions = new HashMap<String,Extension>();121 unparseableExtensions = new TreeMap<String,Extension>(); 121 122 } 122 123 unparseableExtensions.put(ext.getExtensionId().toString(), … … 219 220 } 220 221 222 // Similar to get(String), but throw no exception, might return null. 223 // Used in X509CertImpl::getExtension(OID). 224 Extension getExtension(String name) { 225 return map.get(name); 226 } 227 221 228 /** 222 229 * Delete the attribute value. … … 237 244 */ 238 245 public Enumeration<Extension> getElements() { 239 return map.elements();246 return Collections.enumeration(map.values()); 240 247 } 241 248 -
trunk/openjdk/jdk/src/share/classes/sun/security/x509/X509CRLEntryImpl.java
r278 r406 32 32 import java.security.cert.X509CRLEntry; 33 33 import java.math.BigInteger; 34 import java.util.Collection; 35 import java.util.Date; 36 import java.util.Enumeration; 37 import java.util.Set; 38 import java.util.HashSet; 34 import java.util.*; 39 35 40 36 import javax.security.auth.x500.X500Principal; … … 73 69 */ 74 70 75 public class X509CRLEntryImpl extends X509CRLEntry { 71 public class X509CRLEntryImpl extends X509CRLEntry 72 implements Comparable<X509CRLEntryImpl> { 76 73 77 74 private SerialNumber serialNumber = null; … … 194 191 */ 195 192 public byte[] getEncoded() throws CRLException { 193 return getEncoded0().clone(); 194 } 195 196 // Called internally to avoid clone 197 private byte[] getEncoded0() throws CRLException { 196 198 if (revokedCert == null) 197 199 this.encode(new DerOutputStream()); 198 return revokedCert .clone();200 return revokedCert; 199 201 } 200 202 … … 314 316 return null; 315 317 } 316 Set<String> extSet = new HashSet<String>();318 Set<String> extSet = new TreeSet<String>(); 317 319 for (Extension ex : extensions.getAllExtensions()) { 318 320 if (ex.isCritical()) { … … 335 337 return null; 336 338 } 337 Set<String> extSet = new HashSet<String>();339 Set<String> extSet = new TreeSet<String>(); 338 340 for (Extension ex : extensions.getAllExtensions()) { 339 341 if (!ex.isCritical()) { … … 462 464 getExtension(PKIXExtensions.CertificateIssuer_Id); 463 465 } 466 @Override 467 public int compareTo(X509CRLEntryImpl that) { 468 int compSerial = getSerialNumber().compareTo(that.getSerialNumber()); 469 if (compSerial != 0) { 470 return compSerial; 471 } 472 try { 473 byte[] thisEncoded = this.getEncoded0(); 474 byte[] thatEncoded = that.getEncoded0(); 475 for (int i=0; i<thisEncoded.length && i<thatEncoded.length; i++) { 476 int a = thisEncoded[i] & 0xff; 477 int b = thatEncoded[i] & 0xff; 478 if (a != b) return a-b; 479 } 480 return thisEncoded.length -thatEncoded.length; 481 } catch (CRLException ce) { 482 return -1; 483 } 484 } 464 485 } -
trunk/openjdk/jdk/src/share/classes/sun/security/x509/X509CRLImpl.java
r278 r406 54 54 /** 55 55 * <p> 56 * An impl mentation for X509 CRL (Certificate Revocation List).56 * An implementation for X509 CRL (Certificate Revocation List). 57 57 * <p> 58 58 * The X.509 v2 CRL format is described below in ASN.1: … … 105 105 private Date thisUpdate = null; 106 106 private Date nextUpdate = null; 107 private Map<X509IssuerSerial,X509CRLEntry> revokedCerts = new LinkedHashMap<X509IssuerSerial,X509CRLEntry>(); 107 private Map<X509IssuerSerial,X509CRLEntry> revokedMap 108 = new TreeMap<X509IssuerSerial,X509CRLEntry>(); 109 private List<X509CRLEntry> revokedList = new LinkedList<X509CRLEntry>(); 108 110 private CRLExtensions extensions = null; 109 111 private final static boolean isExplicit = true; … … 224 226 X509IssuerSerial issuerSerial = new X509IssuerSerial 225 227 (badCertIssuer, badCert.getSerialNumber()); 226 this.revokedCerts.put(issuerSerial, badCert); 228 this.revokedMap.put(issuerSerial, badCert); 229 this.revokedList.add(badCert); 227 230 if (badCert.hasExtensions()) { 228 231 this.version = 1; … … 306 309 } 307 310 308 if (!revoked Certs.isEmpty()) {309 for (X509CRLEntry entry : revoked Certs.values()) {311 if (!revokedList.isEmpty()) { 312 for (X509CRLEntry entry : revokedList) { 310 313 ((X509CRLEntryImpl)entry).encode(rCerts); 311 314 } … … 491 494 if (nextUpdate != null) 492 495 sb.append("Next Update: " + nextUpdate.toString() + "\n"); 493 if (revoked Certs.isEmpty())496 if (revokedList.isEmpty()) 494 497 sb.append("\nNO certificates have been revoked\n"); 495 498 else { 496 sb.append("\nRevoked Certificates: " + revoked Certs.size());499 sb.append("\nRevoked Certificates: " + revokedList.size()); 497 500 int i = 1; 498 for ( Iterator<X509CRLEntry> iter = revokedCerts.values().iterator();499 iter.hasNext(); i++)500 sb.append("\n[" + i + "] " + iter.next().toString());501 for (X509CRLEntry entry: revokedList) { 502 sb.append("\n[" + i++ + "] " + entry.toString()); 503 } 501 504 } 502 505 if (extensions != null) { … … 544 547 */ 545 548 public boolean isRevoked(Certificate cert) { 546 if (revoked Certs.isEmpty() || (!(cert instanceof X509Certificate))) {549 if (revokedMap.isEmpty() || (!(cert instanceof X509Certificate))) { 547 550 return false; 548 551 } 549 552 X509Certificate xcert = (X509Certificate) cert; 550 553 X509IssuerSerial issuerSerial = new X509IssuerSerial(xcert); 551 return revoked Certs.containsKey(issuerSerial);554 return revokedMap.containsKey(issuerSerial); 552 555 } 553 556 … … 639 642 */ 640 643 public X509CRLEntry getRevokedCertificate(BigInteger serialNumber) { 641 if (revoked Certs.isEmpty()) {644 if (revokedMap.isEmpty()) { 642 645 return null; 643 646 } … … 645 648 X509IssuerSerial issuerSerial = new X509IssuerSerial 646 649 (getIssuerX500Principal(), serialNumber); 647 return revoked Certs.get(issuerSerial);650 return revokedMap.get(issuerSerial); 648 651 } 649 652 … … 652 655 */ 653 656 public X509CRLEntry getRevokedCertificate(X509Certificate cert) { 654 if (revoked Certs.isEmpty()) {657 if (revokedMap.isEmpty()) { 655 658 return null; 656 659 } 657 660 X509IssuerSerial issuerSerial = new X509IssuerSerial(cert); 658 return revoked Certs.get(issuerSerial);661 return revokedMap.get(issuerSerial); 659 662 } 660 663 … … 668 671 */ 669 672 public Set<X509CRLEntry> getRevokedCertificates() { 670 if (revoked Certs.isEmpty()) {673 if (revokedList.isEmpty()) { 671 674 return null; 672 675 } else { 673 return new HashSet<X509CRLEntry>(revokedCerts.values());676 return new TreeSet<X509CRLEntry>(revokedList); 674 677 } 675 678 } … … 897 900 return null; 898 901 } 899 Set<String> extSet = new HashSet<String>();902 Set<String> extSet = new TreeSet<String>(); 900 903 for (Extension ex : extensions.getAllExtensions()) { 901 904 if (ex.isCritical()) { … … 918 921 return null; 919 922 } 920 Set<String> extSet = new HashSet<String>();923 Set<String> extSet = new TreeSet<String>(); 921 924 for (Extension ex : extensions.getAllExtensions()) { 922 925 if (!ex.isCritical()) { … … 1095 1098 X509IssuerSerial issuerSerial = new X509IssuerSerial 1096 1099 (badCertIssuer, entry.getSerialNumber()); 1097 revokedCerts.put(issuerSerial, entry); 1100 revokedMap.put(issuerSerial, entry); 1101 revokedList.add(entry); 1098 1102 } 1099 1103 } … … 1193 1197 * Immutable X.509 Certificate Issuer DN and serial number pair 1194 1198 */ 1195 private final static class X509IssuerSerial { 1199 private final static class X509IssuerSerial 1200 implements Comparable<X509IssuerSerial> { 1196 1201 final X500Principal issuer; 1197 1202 final BigInteger serial; … … 1272 1277 return hashcode; 1273 1278 } 1279 1280 @Override 1281 public int compareTo(X509IssuerSerial another) { 1282 int cissuer = issuer.toString() 1283 .compareTo(another.issuer.toString()); 1284 if (cissuer != 0) return cissuer; 1285 return this.serial.compareTo(another.serial); 1286 } 1274 1287 } 1275 1288 } -
trunk/openjdk/jdk/src/share/classes/sun/security/x509/X509CertImpl.java
r278 r406 1215 1215 return null; 1216 1216 } 1217 Set<String> extSet = new HashSet<String>();1217 Set<String> extSet = new TreeSet<String>(); 1218 1218 for (Extension ex : exts.getAllExtensions()) { 1219 1219 if (ex.isCritical()) { … … 1245 1245 return null; 1246 1246 } 1247 Set<String> extSet = new HashSet<String>();1247 Set<String> extSet = new TreeSet<String>(); 1248 1248 for (Extension ex : exts.getAllExtensions()) { 1249 1249 if (!ex.isCritical()) { … … 1279 1279 return null; 1280 1280 } else { 1281 for (Extension ex : extensions.getAllExtensions()) { 1282 if (ex.getExtensionId().equals(oid)) { 1281 Extension ex = extensions.getExtension(oid.toString()); 1282 if (ex != null) { 1283 return ex; 1284 } 1285 for (Extension ex2: extensions.getAllExtensions()) { 1286 if (ex2.getExtensionId().equals((Object)oid)) { 1283 1287 //XXXX May want to consider cloning this 1284 return ex ;1288 return ex2; 1285 1289 } 1286 1290 } … … 1481 1485 return Collections.<List<?>>emptySet(); 1482 1486 } 1483 Set<List<?>> newNames = new HashSet<List<?>>();1487 List<List<?>> newNames = new ArrayList<List<?>>(); 1484 1488 for (GeneralName gname : names.names()) { 1485 1489 GeneralNameInterface name = gname.getName(); … … 1542 1546 } 1543 1547 if (mustClone) { 1544 Set<List<?>> namesCopy = new HashSet<List<?>>();1548 List<List<?>> namesCopy = new ArrayList<List<?>>(); 1545 1549 for (List<?> nameEntry : altNames) { 1546 1550 Object nameObject = nameEntry.get(1); -
trunk/openjdk/jdk/src/share/classes/sun/tools/jar/Main.java
r278 r406 1 1 /* 2 * Copyright (c) 1996, 20 07, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 128 128 /** 129 129 * Creates a new empty temporary file in the same directory as the 130 * specified file. A variant of File.createTempFile.130 * specified file. A variant of sun.misc.IOUtils.createTempFile. 131 131 */ 132 132 private static File createTempFileInSameDirectoryAs(File file) -
trunk/openjdk/jdk/src/share/classes/sun/tools/native2ascii/Main.java
r278 r406 1 1 /* 2 * Copyright (c) 1996, 20 07, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 238 238 tempDir = new File(System.getProperty("user.dir")); 239 239 240 tempFile = File.createTempFile("_N2A", 241 ".TMP", 242 tempDir); 240 tempFile = File.createTempFile("_N2A", ".TMP", tempDir); 243 241 tempFile.deleteOnExit(); 244 242 -
trunk/openjdk/jdk/src/share/demo/jvmti/compiledMethodLoad/sample.makefile.txt
r278 r406 91 91 # Library name and options needed to build it 92 92 LIBRARY=lib$(LIBNAME).so 93 LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc -mimpure-text93 LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc 94 94 # Libraries we are dependent on 95 95 LIBRARIES=-lc -
trunk/openjdk/jdk/src/share/demo/jvmti/gctest/sample.makefile.txt
r278 r406 91 91 # Library name and options needed to build it 92 92 LIBRARY=lib$(LIBNAME).so 93 LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc -mimpure-text93 LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc 94 94 # Libraries we are dependent on 95 95 LIBRARIES=-lc -
trunk/openjdk/jdk/src/share/demo/jvmti/heapTracker/sample.makefile.txt
r278 r406 95 95 # Library name and options needed to build it 96 96 LIBRARY=lib$(LIBNAME).so 97 LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc -mimpure-text97 LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc 98 98 # Libraries we are dependent on 99 99 LIBRARIES=-L $(JDK)/jre/lib/$(LIBARCH) -ljava_crw_demo -lc -
trunk/openjdk/jdk/src/share/demo/jvmti/heapViewer/sample.makefile.txt
r278 r406 91 91 # Library name and options needed to build it 92 92 LIBRARY=lib$(LIBNAME).so 93 LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc -mimpure-text93 LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc 94 94 # Libraries we are dependent on 95 95 LIBRARIES=-lc -
trunk/openjdk/jdk/src/share/demo/jvmti/hprof/sample.makefile.txt
r278 r406 131 131 # Library name and options needed to build it 132 132 LIBRARY=lib$(LIBNAME).so 133 LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc -mimpure-text133 LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc 134 134 # Libraries we are dependent on 135 135 LIBRARIES= -lnsl -ldl -lc -
trunk/openjdk/jdk/src/share/demo/jvmti/index.html
r2 r406 309 309 gcc -O2 -fPIC -pthread -DLINUX -c <i>*.c</i> 310 310 <br> 311 gcc -z defs -static-libgcc -shared - mimpure-text -o <i>libXXX.so *.o</i> -lc311 gcc -z defs -static-libgcc -shared -o <i>libXXX.so *.o</i> -lc 312 312 </code></ul> 313 313 <br> … … 317 317 gcc -O2 -fPIC -pthread -DLINUX -D_LP64=1 -c <i>*.c</i> 318 318 <br> 319 gcc -z defs -static-libgcc -shared - mimpure-text -o <i>libXXX.so *.o</i> -lc319 gcc -z defs -static-libgcc -shared -o <i>libXXX.so *.o</i> -lc 320 320 </code></ul> 321 321 <br> … … 340 340 341 341 <li> 342 Library: Use -static-libgcc -mimpure-text.342 Library: Use -static-libgcc. 343 343 <br> 344 344 When building the shared library (-shared option), this option -
trunk/openjdk/jdk/src/share/demo/jvmti/java_crw_demo/sample.makefile.txt
r278 r406 91 91 # Library name and options needed to build it 92 92 LIBRARY=lib$(LIBNAME).so 93 LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc -mimpure-text93 LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc 94 94 # Libraries we are dependent on 95 95 LIBRARIES=-lc -
trunk/openjdk/jdk/src/share/demo/jvmti/minst/sample.makefile.txt
r278 r406 95 95 # Library name and options needed to build it 96 96 LIBRARY=lib$(LIBNAME).so 97 LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc -mimpure-text97 LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc 98 98 # Libraries we are dependent on 99 99 LIBRARIES=-L $(JDK)/jre/lib/$(LIBARCH) -ljava_crw_demo -lc -
trunk/openjdk/jdk/src/share/demo/jvmti/mtrace/sample.makefile.txt
r278 r406 95 95 # Library name and options needed to build it 96 96 LIBRARY=lib$(LIBNAME).so 97 LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc -mimpure-text97 LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc 98 98 # Libraries we are dependent on 99 99 LIBRARIES=-L $(JDK)/jre/lib/$(LIBARCH) -ljava_crw_demo -lc -
trunk/openjdk/jdk/src/share/demo/jvmti/versionCheck/sample.makefile.txt
r278 r406 91 91 # Library name and options needed to build it 92 92 LIBRARY=lib$(LIBNAME).so 93 LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc -mimpure-text93 LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc 94 94 # Libraries we are dependent on 95 95 LIBRARIES=-lc -
trunk/openjdk/jdk/src/share/lib/security/java.security
r2 r406 137 137 # been granted. 138 138 # 139 # by default, no packages are restricted for definition, and none of140 # the class loaders supplied with the JDK callcheckPackageDefinition.141 # 142 #package.definition= 139 # by default, none of the class loaders supplied with the JDK call 140 # checkPackageDefinition. 141 # 142 package.definition=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio. 143 143 144 144 # -
trunk/openjdk/jdk/src/share/lib/security/java.security-solaris
r2 r406 138 138 # been granted. 139 139 # 140 # by default, no packages are restricted for definition, and none of141 # the class loaders supplied with the JDK callcheckPackageDefinition.142 # 143 #package.definition= 140 # by default, none of the class loaders supplied with the JDK call 141 # checkPackageDefinition. 142 # 143 package.definition=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio. 144 144 145 145 # -
trunk/openjdk/jdk/src/share/lib/security/java.security-windows
r2 r406 138 138 # been granted. 139 139 # 140 # by default, no packages are restricted for definition, and none of141 # the class loaders supplied with the JDK callcheckPackageDefinition.142 # 143 #package.definition= 140 # by default, none of the class loaders supplied with the JDK call 141 # checkPackageDefinition. 142 # 143 package.definition=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio. 144 144 145 145 # -
trunk/openjdk/jdk/src/share/native/java/net/net_util.c
r278 r406 1 1 /* 2 * Copyright (c) 1998, 20 05, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 69 69 IPv6_available = IPv6_supported() & (!preferIPv4Stack); 70 70 initLocalAddrTable (); 71 parseExclusiveBindProperty(env); 72 71 73 return JNI_VERSION_1_2; 72 74 } -
trunk/openjdk/jdk/src/share/native/java/net/net_util.h
r278 r406 1 1 /* 2 * Copyright (c) 1997, 20 07, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 121 121 122 122 void initLocalAddrTable (); 123 void parseExclusiveBindProperty(JNIEnv *env); 123 124 124 125 void -
trunk/openjdk/jdk/src/share/native/sun/font/layout/LookupProcessor.cpp
r278 r406 87 87 if (selectMask != 0) { 88 88 const LookupTable *lookupTable = lookupListTable->getLookupTable(lookup); 89 90 if (!lookupTable) 91 continue; 92 89 93 le_uint16 lookupFlags = SWAPW(lookupTable->lookupFlags); 90 94 … … 125 129 le_uint16 lookupListIndex = SWAPW(featureTable->lookupListIndexArray[lookup]); 126 130 131 if (lookupListIndex >= lookupSelectCount) 132 continue; 133 127 134 lookupSelectArray[lookupListIndex] |= featureMask; 128 135 lookupOrderArray[store++] = lookupListIndex; … … 136 143 LETag scriptTag, LETag languageTag, const FeatureMap *featureMap, 137 144 le_int32 featureMapCount, le_bool orderFeatures) 138 : lookupListTable(NULL), featureListTable(NULL), lookupSelectArray(NULL), 145 : lookupListTable(NULL), featureListTable(NULL), lookupSelectArray(NULL), lookupSelectCount(0), 139 146 lookupOrderArray(NULL), lookupOrderCount(0) 140 147 { … … 175 182 lookupSelectArray[i] = 0; 176 183 } 184 185 lookupSelectCount = lookupListCount; 177 186 178 187 le_int32 count, order = 0; … … 192 201 193 202 featureTable = featureListTable->getFeatureTable(featureIndex, &featureTag); 203 204 if (!featureTable) 205 continue; 206 194 207 featureReferences += SWAPW(featureTable->lookupCount); 195 208 } -
trunk/openjdk/jdk/src/share/native/sun/font/layout/LookupProcessor.h
r278 r406 78 78 79 79 FeatureMask *lookupSelectArray; 80 le_uint32 lookupSelectCount; 80 81 81 82 le_uint16 *lookupOrderArray; -
trunk/openjdk/jdk/src/solaris/classes/java/io/UnixFileSystem.java
r278 r406 1 1 /* 2 * Copyright (c) 1998, 20 05, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 254 254 /* -- File operations -- */ 255 255 256 public native boolean createFileExclusively(String path )256 public native boolean createFileExclusively(String path, boolean restrictive) 257 257 throws IOException; 258 258 public boolean delete(File f) { -
trunk/openjdk/jdk/src/solaris/classes/sun/awt/X11/XCheckboxMenuItemPeer.java
r278 r406 30 30 import java.awt.event.*; 31 31 32 import java.lang.reflect.Field; 33 import sun.awt.SunToolkit; 32 import sun.awt.AWTAccessor; 34 33 35 34 class XCheckboxMenuItemPeer extends XMenuItemPeer implements CheckboxMenuItemPeer { 36 37 /************************************************38 *39 * Data members40 *41 ************************************************/42 43 /*44 * CheckboxMenuItem's fields45 */46 private final static Field f_state;47 static {48 f_state = SunToolkit.getField(CheckboxMenuItem.class, "state");49 }50 35 51 36 /************************************************ … … 75 60 ************************************************/ 76 61 boolean getTargetState() { 77 MenuItem target = getTarget(); 78 if (target == null) { 79 return false; 80 } 81 try { 82 return f_state.getBoolean(target); 83 } catch (IllegalAccessException e) { 84 e.printStackTrace(); 85 } 86 return false; 62 return AWTAccessor.getCheckboxMenuItemAccessor() 63 .getState((CheckboxMenuItem)getTarget()); 87 64 } 88 65 -
trunk/openjdk/jdk/src/solaris/classes/sun/awt/X11/XComponentPeer.java
r278 r406 32 32 import java.awt.Container; 33 33 import java.awt.Cursor; 34 import java.awt.DefaultKeyboardFocusManager;35 34 import java.awt.Dimension; 36 import java.awt.Event;37 35 import java.awt.Font; 38 36 import java.awt.FontMetrics; … … 41 39 import java.awt.Insets; 42 40 import java.awt.KeyboardFocusManager; 43 import java.awt.MenuBar;44 import java.awt.Point;45 41 import java.awt.Rectangle; 46 42 import java.awt.SystemColor; … … 61 57 import java.awt.image.ImageProducer; 62 58 import java.awt.image.VolatileImage; 63 import java.awt.peer.CanvasPeer;64 59 import java.awt.peer.ComponentPeer; 65 60 import java.awt.peer.ContainerPeer; 66 61 import java.awt.peer.LightweightPeer; 67 import java.awt.peer.PanelPeer;68 import java.awt.peer.WindowPeer;69 62 import java.lang.reflect.*; 70 63 import java.security.*; … … 398 391 } 399 392 400 static Method requestFocusWithCause;401 402 393 static void callRequestFocus(Component target, CausedFocusEvent.Cause cause) { 403 if (requestFocusWithCause == null) { 404 requestFocusWithCause = SunToolkit.getMethod(Component.class, "requestFocus", new Class[] {CausedFocusEvent.Cause.class}); 405 } 406 if (requestFocusWithCause != null) { 407 try { 408 requestFocusWithCause.invoke(target, new Object[] {cause}); 409 } catch (Exception e) { 410 e.printStackTrace(); 411 } 412 } 394 AWTAccessor.getComponentAccessor().requestFocus(target, cause); 413 395 } 414 396 -
trunk/openjdk/jdk/src/solaris/classes/sun/awt/X11/XEmbedCanvasPeer.java
r278 r406 30 30 import java.awt.dnd.DropTargetListener; 31 31 import java.awt.event.*; 32 import java.awt.image.ColorModel;33 import java.awt.image.ImageObserver;34 import java.awt.image.ImageProducer;35 import java.awt.image.VolatileImage;36 import java.awt.peer.*;37 32 import sun.awt.*; 38 import sun.awt.motif.X11FontMetrics;39 import java.lang.reflect.*;40 33 import java.util.logging.*; 41 34 import java.util.*; … … 456 449 } 457 450 458 static Field bdataField;459 451 static byte[] getBData(KeyEvent e) { 460 try { 461 if (bdataField == null) { 462 bdataField = SunToolkit.getField(java.awt.AWTEvent.class, "bdata"); 463 } 464 return (byte[])bdataField.get(e); 465 } catch (IllegalAccessException ex) { 466 return null; 467 } 452 return AWTAccessor.getAWTEventAccessor().getBData(e); 468 453 } 469 454 -
trunk/openjdk/jdk/src/solaris/classes/sun/awt/X11/XEmbeddingContainer.java
r278 r406 29 29 import java.util.HashMap; 30 30 import java.awt.event.KeyEvent; 31 import java.lang.reflect.*; 32 import sun.awt.SunToolkit; 31 import sun.awt.AWTAccessor; 33 32 34 33 public class XEmbeddingContainer extends XEmbedHelper implements XEventDispatcher { … … 128 127 } 129 128 130 static Field bdata;131 byte[] getBData(KeyEvent e) {132 try {133 if (bdata == null) {134 bdata = SunToolkit.getField(java.awt.AWTEvent.class, "bdata");135 }136 return (byte[])bdata.get(e);137 } catch (IllegalAccessException ex) {138 return null;139 }140 }141 142 129 void forwardKeyEvent(long child, KeyEvent e) { 143 byte[] bdata = getBData(e);130 byte[] bdata = AWTAccessor.getAWTEventAccessor().getBData(e); 144 131 long data = Native.toData(bdata); 145 132 if (data == 0) { -
trunk/openjdk/jdk/src/solaris/classes/sun/awt/X11/XGlobalCursorManager.java
r278 r406 30 30 import java.awt.peer.LightweightPeer; 31 31 import java.lang.ref.WeakReference; 32 import java.lang.reflect.Field;33 import java.lang.reflect.Method;34 32 import sun.awt.ComponentAccessor; 35 33 36 34 import sun.awt.GlobalCursorManager; 37 import sun.awt. SunToolkit;35 import sun.awt.AWTAccessor; 38 36 39 37 public final class XGlobalCursorManager extends GlobalCursorManager { 40 41 private static Field field_pData;42 private static Field field_type;43 private static Class cursorClass;44 private static Method method_setPData;45 static {46 cursorClass = java.awt.Cursor.class;47 field_pData = SunToolkit.getField(cursorClass, "pData");48 field_type = SunToolkit.getField(cursorClass, "type");49 method_setPData = SunToolkit.getMethod(cursorClass, "setPData", new Class[] {long.class});50 if (field_pData == null || field_type == null || method_setPData == null) {51 System.out.println("Unable to initialize XGlobalCursorManager: ");52 Thread.dumpStack();53 54 }55 }56 57 38 58 39 // cached nativeContainer … … 217 198 int type = 0; 218 199 try { 219 pData = field_pData.getLong(c);220 type = field_type.getInt(c);200 pData = AWTAccessor.getCursorAccessor().getPData(c); 201 type = AWTAccessor.getCursorAccessor().getType(c); 221 202 } 222 203 catch (Exception e) … … 288 269 static void setPData(Cursor c, long pData) { 289 270 try { 290 method_setPData.invoke(c, pData);271 AWTAccessor.getCursorAccessor().setPData(c, pData); 291 272 } 292 273 catch (Exception e) -
trunk/openjdk/jdk/src/solaris/classes/sun/awt/X11/XKeyboardFocusManagerPeer.java
r278 r406 33 33 import java.awt.peer.KeyboardFocusManagerPeer; 34 34 35 import java.lang.reflect.InvocationTargetException;36 import java.lang.reflect.Method;37 38 35 import java.util.logging.Level; 39 36 import java.util.logging.Logger; 40 37 41 38 import sun.awt.CausedFocusEvent; 42 import sun.awt. SunToolkit;39 import sun.awt.AWTAccessor; 43 40 44 41 public class XKeyboardFocusManagerPeer implements KeyboardFocusManagerPeer { … … 131 128 } 132 129 133 static Method shouldNativelyFocusHeavyweightMethod;134 135 130 static int shouldNativelyFocusHeavyweight(Component heavyweight, 136 131 Component descendant, boolean temporary, 137 132 boolean focusedWindowChangeAllowed, long time, CausedFocusEvent.Cause cause) 138 133 { 139 if (shouldNativelyFocusHeavyweightMethod == null) { 140 Class[] arg_types = 141 new Class[] { Component.class, 142 Component.class, 143 Boolean.TYPE, 144 Boolean.TYPE, 145 Long.TYPE, 146 CausedFocusEvent.Cause.class 147 }; 148 149 shouldNativelyFocusHeavyweightMethod = 150 SunToolkit.getMethod(KeyboardFocusManager.class, 151 "shouldNativelyFocusHeavyweight", 152 arg_types); 153 } 154 Object[] args = new Object[] { heavyweight, 155 descendant, 156 Boolean.valueOf(temporary), 157 Boolean.valueOf(focusedWindowChangeAllowed), 158 Long.valueOf(time), cause}; 159 160 int result = XComponentPeer.SNFH_FAILURE; 161 if (shouldNativelyFocusHeavyweightMethod != null) { 162 try { 163 result = ((Integer) shouldNativelyFocusHeavyweightMethod.invoke(null, args)).intValue(); 164 } 165 catch (IllegalAccessException e) { 166 assert false; 167 } 168 catch (InvocationTargetException e) { 169 assert false; 170 } 171 } 172 173 return result; 134 return AWTAccessor.getKeyboardFocusManagerAccessor() 135 .shouldNativelyFocusHeavyweight(heavyweight, 136 descendant, 137 temporary, 138 focusedWindowChangeAllowed, 139 time, 140 cause); 174 141 } 175 142 } -
trunk/openjdk/jdk/src/solaris/classes/sun/awt/X11/XMenuBarPeer.java
r278 r406 29 29 import java.awt.event.*; 30 30 31 import java.lang.reflect.Field;32 31 import java.util.Vector; 33 32 import java.util.logging.*; 34 import sun.awt. SunToolkit;33 import sun.awt.AWTAccessor; 35 34 36 35 public class XMenuBarPeer extends XBaseMenuWindow implements MenuBarPeer { … … 67 66 private final static int BAR_ITEM_MARGIN_TOP = 2; 68 67 private final static int BAR_ITEM_MARGIN_BOTTOM = 2; 69 70 //fields71 private static Field f_helpMenu;72 private static Field f_menus;73 74 static {75 f_helpMenu = SunToolkit.getField(MenuBar.class, "helpMenu");76 f_menus = SunToolkit.getField(MenuBar.class, "menus");77 }78 68 79 69 /************************************************ … … 205 195 void postInit(XCreateWindowParams params) { 206 196 super.postInit(params); 207 Vector targetMenuVector = null; 208 Menu targetHelpMenu = null; 209 try { 210 // Get menus from the target. 211 targetMenuVector = (Vector)f_menus.get(menuBarTarget); 212 targetHelpMenu = (Menu)f_helpMenu.get(menuBarTarget); 213 reloadItems(targetMenuVector); 214 } catch (IllegalAccessException iae) { 215 iae.printStackTrace(); 216 } 217 if (targetHelpMenu != null) { 218 addHelpMenu(targetHelpMenu); 219 } 197 // Get menus from the target. 198 Vector targetMenuVector = AWTAccessor.getMenuBarAccessor() 199 .getMenus(menuBarTarget); 200 Menu targetHelpMenu = AWTAccessor.getMenuBarAccessor() 201 .getHelpMenu(menuBarTarget); 202 reloadItems(targetMenuVector); 220 203 xSetVisible(true); 221 204 toFront(); -
trunk/openjdk/jdk/src/solaris/classes/sun/awt/X11/XMenuItemPeer.java
r278 r406 29 29 import java.awt.event.*; 30 30 31 import java.util.logging.*; 32 33 import java.lang.reflect.Field; 34 import java.lang.reflect.Method; 35 import java.lang.reflect.InvocationTargetException; 36 import sun.awt.SunToolkit; 31 import sun.awt.AWTAccessor; 37 32 38 33 public class XMenuItemPeer implements MenuItemPeer { … … 84 79 private final static int SEPARATOR_HEIGHT = 5; 85 80 86 /*87 * MenuItem's fields & methods88 */89 private final static Field f_enabled;90 private final static Field f_label;91 private final static Field f_shortcut;92 private final static Method m_getFont;93 private final static Method m_isItemEnabled;94 private final static Method m_getActionCommand;95 static {96 f_enabled = SunToolkit.getField(MenuItem.class, "enabled");97 f_label = SunToolkit.getField(MenuItem.class, "label");98 f_shortcut = SunToolkit.getField(MenuItem.class, "shortcut");99 100 m_getFont = SunToolkit.getMethod(MenuComponent.class, "getFont_NoClientCode", null);101 m_getActionCommand = SunToolkit.getMethod(MenuItem.class, "getActionCommandImpl", null);102 m_isItemEnabled = SunToolkit.getMethod(MenuItem.class, "isItemEnabled", null);103 }104 81 /************************************************ 105 82 * … … 219 196 return XWindow.defaultFont; 220 197 } 221 try { 222 return (Font)m_getFont.invoke(target, new Object[0]); 223 } catch (IllegalAccessException e) { 224 e.printStackTrace(); 225 } catch (InvocationTargetException e) { 226 e.printStackTrace(); 227 } 228 return XWindow.defaultFont; 198 return AWTAccessor.getMenuComponentAccessor().getFont_NoClientCode(target); 229 199 } 230 200 … … 233 203 return ""; 234 204 } 235 try { 236 String label = (String)f_label.get(target); 237 return (label == null) ? "" : label; 238 } catch (IllegalAccessException e) { 239 e.printStackTrace(); 240 } 241 return ""; 205 String label = AWTAccessor.getMenuItemAccessor().getLabel(target); 206 return (label == null) ? "" : label; 242 207 } 243 208 … … 246 211 return false; 247 212 } 248 try { 249 return f_enabled.getBoolean(target); 250 } catch (IllegalAccessException e) { 251 e.printStackTrace(); 252 } 253 return false; 213 return AWTAccessor.getMenuItemAccessor().isEnabled(target); 254 214 } 255 215 … … 263 223 return false; 264 224 } 265 try { 266 return ((Boolean)m_isItemEnabled.invoke(target, new Object[0])).booleanValue(); 267 } catch (IllegalAccessException e) { 268 e.printStackTrace(); 269 } catch (InvocationTargetException e) { 270 e.printStackTrace(); 271 } 272 return false; 225 return AWTAccessor.getMenuItemAccessor().isItemEnabled(target); 273 226 } 274 227 … … 277 230 return ""; 278 231 } 279 try { 280 return (String) m_getActionCommand.invoke(target,(Object[]) null); 281 } catch (IllegalAccessException e) { 282 e.printStackTrace(); 283 } catch (InvocationTargetException e) { 284 e.printStackTrace(); 285 } 286 return ""; 232 return AWTAccessor.getMenuItemAccessor().getActionCommandImpl(target); 287 233 } 288 234 … … 291 237 return null; 292 238 } 293 try { 294 return (MenuShortcut)f_shortcut.get(target); 295 } catch (IllegalAccessException e) { 296 e.printStackTrace(); 297 } 298 return null; 239 return AWTAccessor.getMenuItemAccessor().getShortcut(target); 299 240 } 300 241 -
trunk/openjdk/jdk/src/solaris/classes/sun/awt/X11/XMenuPeer.java
r278 r406 28 28 import java.awt.peer.*; 29 29 30 import java.lang.reflect.Field;31 30 import java.util.Vector; 32 31 import java.util.logging.*; 33 import sun.awt. SunToolkit;32 import sun.awt.AWTAccessor; 34 33 35 34 public class XMenuPeer extends XMenuItemPeer implements MenuPeer { … … 46 45 */ 47 46 XMenuWindow menuWindow; 48 49 50 /*51 * Menu's fields & methods52 */53 private final static Field f_items;54 55 static {56 f_items = SunToolkit.getField(Menu.class, "items");57 }58 47 59 48 /************************************************ … … 154 143 ************************************************/ 155 144 Vector getTargetItems() { 156 try { 157 return (Vector)f_items.get(getTarget()); 158 } catch (IllegalAccessException iae) { 159 iae.printStackTrace(); 160 return null; 161 } 145 return AWTAccessor.getMenuAccessor().getItems((Menu)getTarget()); 162 146 } 163 147 -
trunk/openjdk/jdk/src/solaris/classes/sun/awt/X11/XPopupMenuPeer.java
r278 r406 29 29 import java.awt.event.*; 30 30 31 import java.lang.reflect.Field;32 import java.lang.reflect.Method;33 import java.lang.reflect.InvocationTargetException;34 35 31 import java.util.Vector; 32 import sun.awt.AWTAccessor; 36 33 import java.util.logging.*; 37 38 import sun.awt.SunToolkit;39 34 40 35 public class XPopupMenuPeer extends XMenuWindow implements PopupMenuPeer { … … 66 61 private final static int CAPTION_MARGIN_TOP = 4; 67 62 private final static int CAPTION_SEPARATOR_HEIGHT = 6; 68 69 /*70 * Menu's fields & methods71 */72 //Fix for 6184485: Popup menu is not disabled on XToolkit even when calling setEnabled (false)73 private final static Field f_enabled;74 //Fix for 6267144: PIT: Popup menu label is not shown, XToolkit75 private final static Field f_label;76 private final static Method m_getFont;77 private final static Field f_items;78 79 static {80 f_enabled = SunToolkit.getField(MenuItem.class, "enabled");81 f_label = SunToolkit.getField(MenuItem.class, "label");82 f_items = SunToolkit.getField(Menu.class, "items");83 m_getFont = SunToolkit.getMethod(MenuComponent.class, "getFont_NoClientCode", null);84 }85 86 63 87 64 /************************************************ … … 190 167 return XWindow.defaultFont; 191 168 } 192 try { 193 return (Font)m_getFont.invoke(popupMenuTarget, new Object[0]); 194 } catch (IllegalAccessException e) { 195 e.printStackTrace(); 196 } catch (InvocationTargetException e) { 197 e.printStackTrace(); 198 } 199 return XWindow.defaultFont; 200 } 201 169 return AWTAccessor.getMenuComponentAccessor() 170 .getFont_NoClientCode(popupMenuTarget); 171 } 172 173 //Fix for 6267144: PIT: Popup menu label is not shown, XToolkit 202 174 String getTargetLabel() { 203 175 if (target == null) { 204 176 return ""; 205 177 } 206 try { 207 String label = (String)f_label.get(popupMenuTarget); 208 return (label == null) ? "" : label; 209 } catch (IllegalAccessException e) { 210 e.printStackTrace(); 211 } 212 return ""; 178 return AWTAccessor.getMenuItemAccessor().getLabel(popupMenuTarget); 213 179 } 214 180 … … 218 184 return false; 219 185 } 220 try { 221 return f_enabled.getBoolean(popupMenuTarget); 222 } catch (IllegalAccessException e) { 223 e.printStackTrace(); 224 } 225 return false; 186 return AWTAccessor.getMenuItemAccessor().isEnabled(popupMenuTarget); 226 187 } 227 188 228 189 Vector getMenuTargetItems() { 229 try { 230 return (Vector)f_items.get(popupMenuTarget); 231 } catch (IllegalAccessException iae) { 232 iae.printStackTrace(); 190 if (popupMenuTarget == null) { 233 191 return null; 234 192 } 193 return AWTAccessor.getMenuAccessor().getItems(popupMenuTarget); 235 194 } 236 195 -
trunk/openjdk/jdk/src/solaris/classes/sun/awt/X11/XScrollPanePeer.java
r278 r406 29 29 import java.awt.event.*; 30 30 import java.awt.peer.*; 31 import java.lang.reflect.*; 32 import sun.awt. SunToolkit;31 32 import sun.awt.AWTAccessor; 33 33 34 34 class XScrollPanePeer extends XComponentPeer implements ScrollPanePeer, XScrollbarClient { … … 42 42 public final static int HORIZONTAL = 1 << 1; 43 43 44 private static Method m_setValue;45 44 static { 46 m_setValue = SunToolkit.getMethod(ScrollPaneAdjustable.class, "setTypedValue", new Class[] {Integer.TYPE, Integer.TYPE});47 45 SCROLLBAR = XToolkit.getUIDefaults().getInt("ScrollBar.defaultWidth"); 48 46 } … … 317 315 318 316 void setAdjustableValue(ScrollPaneAdjustable adj, int value, int type) { 319 try { 320 m_setValue.invoke(adj, new Object[] {Integer.valueOf(value), Integer.valueOf(type)}); 321 } catch (IllegalAccessException iae) { 322 adj.setValue(value); 323 } catch (IllegalArgumentException iae2) { 324 adj.setValue(value); 325 } catch (InvocationTargetException ite) { 326 adj.setValue(value); 327 ite.getCause().printStackTrace(); 328 } 317 AWTAccessor.getScrollPaneAdjustableAccessor().setTypedValue(adj, value, 318 type); 329 319 } 330 320 -
trunk/openjdk/jdk/src/solaris/classes/sun/awt/X11/XTextAreaPeer.java
r278 r406 62 62 import sun.awt.CausedFocusEvent; 63 63 import sun.awt.ComponentAccessor; 64 import sun.awt.AWTAccessor; 64 65 65 66 … … 986 987 public void setTransferHandler(TransferHandler newHandler) { 987 988 TransferHandler oldHandler = (TransferHandler) 988 getClientProperty(XTextTransferHelper.getTransferHandlerKey()); 989 putClientProperty(XTextTransferHelper.getTransferHandlerKey(), 989 getClientProperty(AWTAccessor.getClientPropertyKeyAccessor() 990 .getJComponent_TRANSFER_HANDLER()); 991 putClientProperty(AWTAccessor.getClientPropertyKeyAccessor() 992 .getJComponent_TRANSFER_HANDLER(), 990 993 newHandler); 991 994 -
trunk/openjdk/jdk/src/solaris/classes/sun/awt/X11/XTextFieldPeer.java
r278 r406 56 56 import sun.awt.CausedFocusEvent; 57 57 import sun.awt.ComponentAccessor; 58 import sun.awt.AWTAccessor; 58 59 59 60 public class XTextFieldPeer extends XComponentPeer implements TextFieldPeer { … … 715 716 public void setTransferHandler(TransferHandler newHandler) { 716 717 TransferHandler oldHandler = (TransferHandler) 717 getClientProperty(XTextTransferHelper.getTransferHandlerKey()); 718 putClientProperty(XTextTransferHelper.getTransferHandlerKey(), 718 getClientProperty(AWTAccessor.getClientPropertyKeyAccessor() 719 .getJComponent_TRANSFER_HANDLER()); 720 putClientProperty(AWTAccessor.getClientPropertyKeyAccessor() 721 .getJComponent_TRANSFER_HANDLER(), 719 722 newHandler); 720 723 -
trunk/openjdk/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java
r278 r406 50 50 import sun.print.PrintJob2D; 51 51 import sun.security.action.GetBooleanAction; 52 import java.lang.reflect.*;52 import sun.security.action.GetPropertyAction; 53 53 54 54 public class XToolkit extends UNIXToolkit implements Runnable, XConstants { … … 103 103 static long awt_defaultFg; // Pixel 104 104 private static XMouseInfoPeer xPeer; 105 private static Method m_removeSourceEvents;106 105 107 106 static { … … 121 120 setBackingStoreType(); 122 121 } 123 m_removeSourceEvents = SunToolkit.getMethod(EventQueue.class, "removeSourceEvents", new Class[] {Object.class, Boolean.TYPE}) ; 124 125 noisyAwtHandler = AccessController.doPrivileged(new GetBooleanAction("sun.awt.noisyerrorhandler"));122 123 noisyAwtHandler = AccessController.doPrivileged( 124 new GetBooleanAction("sun.awt.noisyerrorhandler")); 126 125 } 127 126 … … 204 203 static void initSecurityWarning() { 205 204 // Enable warning only for internal builds 206 String runtime = getSystemProperty("java.runtime.version"); 205 String runtime = AccessController.doPrivileged( 206 new GetPropertyAction("java.runtime.version")); 207 207 securityWarningEnabled = (runtime != null && runtime.contains("internal")); 208 208 } … … 1125 1125 awtUnlock(); 1126 1126 } 1127 }1128 1129 static String getSystemProperty(final String name) {1130 return (String)AccessController.doPrivileged(new PrivilegedAction() {1131 public Object run() {1132 return System.getProperty(name);1133 }1134 });1135 1127 } 1136 1128 … … 1895 1887 1896 1888 static void removeSourceEvents(EventQueue queue, Object source, boolean removeAllEvents) { 1897 try { 1898 m_removeSourceEvents.invoke(queue, source, removeAllEvents); 1899 } 1900 catch (IllegalAccessException e) 1901 { 1902 e.printStackTrace(); 1903 } 1904 catch (InvocationTargetException e) { 1905 e.printStackTrace(); 1906 } 1889 AWTAccessor.getEventQueueAccessor().removeSourceEvents(queue, source, removeAllEvents); 1907 1890 } 1908 1891 … … 1938 1921 1939 1922 private static void setBackingStoreType() { 1940 String prop = (String)AccessController.doPrivileged(1941 new sun.security.action.GetPropertyAction("sun.awt.backingStore"));1923 String prop = AccessController.doPrivileged( 1924 new GetPropertyAction("sun.awt.backingStore")); 1942 1925 1943 1926 if (prop == null) { -
trunk/openjdk/jdk/src/solaris/classes/sun/awt/X11/XWindow.java
r278 r406 34 34 35 35 import java.lang.reflect.Field; 36 import java.lang.reflect.Method;37 36 38 37 import java.util.logging.Level; … … 109 108 private native static void initIDs(); 110 109 111 private static Field isPostedField;112 110 static { 113 111 initIDs(); … … 362 360 } 363 361 364 static Method m_sendMessage;365 362 static void sendEvent(final AWTEvent e) { 366 if (isPostedField == null) {367 isPostedField = SunToolkit.getField(AWTEvent.class, "isPosted");368 }369 363 PeerEvent pe = new PeerEvent(Toolkit.getDefaultToolkit(), new Runnable() { 370 364 public void run() { 371 try { 372 isPostedField.setBoolean(e, true); 373 } catch (IllegalArgumentException e) { 374 assert(false); 375 } catch (IllegalAccessException e) { 376 assert(false); 377 } 365 AWTAccessor.getAWTEventAccessor().setPosted(e); 378 366 ((Component)e.getSource()).dispatchEvent(e); 379 367 } … … 1251 1239 1252 1240 1253 static Field bdata;1254 1241 static void setBData(KeyEvent e, byte[] data) { 1255 try { 1256 if (bdata == null) { 1257 bdata = SunToolkit.getField(java.awt.AWTEvent.class, "bdata"); 1258 } 1259 bdata.set(e, data); 1260 } catch (IllegalAccessException ex) { 1261 assert false; 1262 } 1242 AWTAccessor.getAWTEventAccessor().setBData(e, data); 1263 1243 } 1264 1244 -
trunk/openjdk/jdk/src/solaris/classes/sun/awt/X11/XlibWrapper.java
r278 r406 27 27 28 28 import java.security.AccessController; 29 import java.security.PrivilegedAction;29 import sun.security.action.GetPropertyAction; 30 30 import sun.misc.*; 31 31 … … 563 563 564 564 static { 565 String dataModelProp = (String)AccessController.doPrivileged( 566 new PrivilegedAction() { 567 public Object run() { 568 return System.getProperty("sun.arch.data.model"); 569 } 570 }); 565 String dataModelProp = AccessController.doPrivileged(new GetPropertyAction("sun.arch.data.model")); 571 566 try { 572 567 dataModel = Integer.parseInt(dataModelProp); … … 611 606 612 607 private static boolean getBuildInternal() { 613 String javaVersion = XToolkit.getSystemProperty("java.version");608 String javaVersion = AccessController.doPrivileged(new GetPropertyAction("java.version")); 614 609 return javaVersion != null && javaVersion.contains("internal"); 615 610 } -
trunk/openjdk/jdk/src/solaris/classes/sun/awt/motif/MComponentPeer.java
r278 r406 401 401 402 402 static void callRequestFocusInWindow(Component target, CausedFocusEvent.Cause cause) { 403 if (requestFocusWithCause == null) { 404 requestFocusWithCause = SunToolkit.getMethod(Component.class, "requestFocusInWindow", new Class[] {CausedFocusEvent.Cause.class}); 405 } 406 if (requestFocusWithCause != null) { 407 try { 408 requestFocusWithCause.invoke(target, new Object[] {cause}); 409 } catch (Exception e) { 410 e.printStackTrace(); 411 } 412 } 403 AWTAccessor.getComponentAccessor().requestFocusInWindow(target, cause); 413 404 } 414 405 -
trunk/openjdk/jdk/src/solaris/classes/sun/print/UnixPrintJob.java
r278 r406 1 1 /* 2 * Copyright (c) 2000, 20 04, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 938 938 * removed when the VM exits. 939 939 */ 940 spoolFile = File.createTempFile("javaprint", ".ps", null);940 spoolFile = sun.misc.IOUtils.createTempFile("javaprint", ".ps", null); 941 941 spoolFile.deleteOnExit(); 942 942 } -
trunk/openjdk/jdk/src/solaris/classes/sun/print/UnixPrintServiceLookup.java
r278 r406 1 1 /* 2 * Copyright (c) 2000, 20 06, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 713 713 Process proc; 714 714 BufferedReader bufferedReader = null; 715 File f = File.createTempFile("prn","xc");715 File f = sun.misc.IOUtils.createTempFile("prn","xc"); 716 716 cmd[2] = cmd[2]+">"+f.getAbsolutePath(); 717 717 -
trunk/openjdk/jdk/src/solaris/native/java/io/UnixFileSystem_md.c
r278 r406 1 1 /* 2 * Copyright (c) 1998, 20 06, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 311 311 JNIEXPORT jboolean JNICALL 312 312 Java_java_io_UnixFileSystem_createFileExclusively(JNIEnv *env, jclass cls, 313 jstring pathname) 313 jstring pathname, 314 jboolean restrictive) 314 315 { 315 316 jboolean rv = JNI_FALSE; … … 320 321 fd = JVM_EEXIST; /* The root directory always exists */ 321 322 } else { 322 fd = JVM_Open(path, JVM_O_RDWR | JVM_O_CREAT | JVM_O_EXCL, 0666); 323 jint mode = (restrictive == JNI_TRUE) ? 0600 : 0666; 324 fd = JVM_Open(path, JVM_O_RDWR | JVM_O_CREAT | JVM_O_EXCL, mode); 323 325 } 324 326 if (fd < 0) { -
trunk/openjdk/jdk/src/solaris/native/java/net/net_util_md.c
r278 r406 1 1 /* 2 * Copyright (c) 1997, 20 07, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 65 65 66 66 /* 67 * EXCLBIND socket options only on Solaris 8 & 9.67 * EXCLBIND socket options only on Solaris 68 68 */ 69 69 #if defined(__solaris__) && !defined(TCP_EXCLBIND) … … 78 78 static int tcp_max_buf; 79 79 static int udp_max_buf; 80 static int useExclBind = 0; 80 81 81 82 /* … … 646 647 647 648 #endif 649 650 void parseExclusiveBindProperty(JNIEnv *env) { 651 #ifdef __solaris__ 652 jstring s, flagSet; 653 jclass iCls; 654 jmethodID mid; 655 656 s = (*env)->NewStringUTF(env, "sun.net.useExclusiveBind"); 657 CHECK_NULL(s); 658 iCls = (*env)->FindClass(env, "java/lang/System"); 659 CHECK_NULL(iCls); 660 mid = (*env)->GetStaticMethodID(env, iCls, "getProperty", 661 "(Ljava/lang/String;)Ljava/lang/String;"); 662 CHECK_NULL(mid); 663 flagSet = (*env)->CallStaticObjectMethod(env, iCls, mid, s); 664 if (flagSet != NULL) { 665 useExclBind = 1; 666 } 667 #endif 668 } 648 669 649 670 /* In the case of an IPv4 Inetaddress this method will return an … … 1223 1244 * caught. 1224 1245 * 1225 * On Solaris 8/9with IPv6 enabled we must use an exclusive1226 * bind to guarantee da unique port number across the IPv4 and1246 * On Solaris with IPv6 enabled we must use an exclusive 1247 * bind to guarantee a unique port number across the IPv4 and 1227 1248 * IPv6 port spaces. 1228 1249 * … … 1254 1275 #if defined(__solaris__) && defined(AF_INET6) 1255 1276 /* 1256 * Solaris 8/9 have seperate IPv4 and IPv6 port spaces so we1277 * Solaris has separate IPv4 and IPv6 port spaces so we 1257 1278 * use an exclusive bind when SO_REUSEADDR is not used to 1258 1279 * give the illusion of a unified port space. 1259 * This also avoid problems with IPv6 sockets connecting1280 * This also avoids problems with IPv6 sockets connecting 1260 1281 * to IPv4 mapped addresses whereby the socket conversion 1261 1282 * results in a late bind that fails because the … … 1266 1287 1267 1288 len = sizeof(arg); 1268 if ( getsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *)&arg,1269 &len) == 0) {1270 if ( arg == 0) {1289 if (useExclBind || getsockopt(fd, SOL_SOCKET, SO_REUSEADDR, 1290 (char *)&arg, &len) == 0) { 1291 if (useExclBind || arg == 0) { 1271 1292 /* 1272 * SO_REUSEADDR is disabled so enable TCP_EXCLBIND or 1293 * SO_REUSEADDR is disabled or sun.net.useExclusiveBind 1294 * property is true so enable TCP_EXCLBIND or 1273 1295 * UDP_EXCLBIND 1274 1296 */ -
trunk/openjdk/jdk/src/windows/classes/java/io/Win32FileSystem.java
r278 r406 1 1 /* 2 * Copyright (c) 1998, 20 05, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 511 511 /* -- File operations -- */ 512 512 513 public native boolean createFileExclusively(String path )513 public native boolean createFileExclusively(String path, boolean restrictive) 514 514 throws IOException; 515 515 public boolean delete(File f) { -
trunk/openjdk/jdk/src/windows/classes/java/io/WinNTFileSystem.java
r278 r406 1 1 /* 2 * Copyright (c) 2001, 20 06, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 62 62 /* -- File operations -- */ 63 63 64 public native boolean createFileExclusively(String path )64 public native boolean createFileExclusively(String path, boolean restrictive) 65 65 throws IOException; 66 66 protected native boolean delete0(File f); -
trunk/openjdk/jdk/src/windows/classes/sun/awt/windows/WPopupMenuPeer.java
r278 r406 27 27 import java.awt.*; 28 28 import java.awt.peer.*; 29 import java.lang.reflect.Field;30 29 31 import sun.awt. SunToolkit;30 import sun.awt.AWTAccessor; 32 31 33 32 public class WPopupMenuPeer extends WMenuPeer implements PopupMenuPeer { … … 35 34 // because this method should return null for the TrayIcon 36 35 // popup regardless of that whether it has parent or not. 37 private static Field f_parent;38 private static Field f_isTrayIconPopup;39 40 static {41 f_parent = SunToolkit.getField(MenuComponent.class, "parent");42 f_isTrayIconPopup = SunToolkit.getField(PopupMenu.class, "isTrayIconPopup");43 }44 36 45 37 public WPopupMenuPeer(PopupMenu target) { … … 47 39 MenuContainer parent = null; 48 40 boolean isTrayIconPopup = false; 49 try { 50 isTrayIconPopup = ((Boolean)f_isTrayIconPopup.get(target)).booleanValue(); 51 if (isTrayIconPopup) { 52 parent = (MenuContainer)f_parent.get(target); 53 } else { 54 parent = target.getParent(); 55 } 56 } catch (IllegalAccessException iae) { 57 iae.printStackTrace(); 58 return; 41 isTrayIconPopup = AWTAccessor.getPopupMenuAccessor().isTrayIconPopup(target); 42 if (isTrayIconPopup) { 43 parent = AWTAccessor.getMenuComponentAccessor().getParent(target); 44 } else { 45 parent = target.getParent(); 59 46 } 60 47 -
trunk/openjdk/jdk/src/windows/native/java/io/Win32FileSystem_md.c
r330 r406 1 1 /* 2 * Copyright (c) 1998, 20 06, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 274 274 JNIEXPORT jboolean JNICALL 275 275 Java_java_io_Win32FileSystem_createFileExclusively(JNIEnv *env, jclass cls, 276 jstring pathname) 276 jstring pathname, 277 jboolean restrictive) 277 278 { 278 279 jboolean rv = JNI_FALSE; -
trunk/openjdk/jdk/src/windows/native/java/io/WinNTFileSystem_md.c
r330 r406 1 1 /* 2 * Copyright (c) 2001, 20 06, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 366 366 JNIEXPORT jboolean JNICALL 367 367 Java_java_io_WinNTFileSystem_createFileExclusively(JNIEnv *env, jclass cls, 368 jstring path) 368 jstring path, 369 jboolean restrictive) 369 370 { 370 371 HANDLE h = NULL; -
trunk/openjdk/jdk/src/windows/native/java/net/net_util_md.c
r333 r406 1 1 /* 2 * Copyright (c) 1997, 20 07, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 133 133 134 134 void initLocalAddrTable () {} 135 void parseExclusiveBindProperty (JNIEnv *env) {} 135 136 136 137 /* -
trunk/openjdk/jdk/src/windows/native/sun/windows/awt_Dialog.cpp
r309 r406 429 429 JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); 430 430 431 jlongArray windows = (jlongArray)(env->CallStaticObjectMethod(AwtWindow::wwindowPeerCls, 432 AwtWindow::getActiveWindowsMID)); 431 jclass wwindowPeerCls = env->FindClass("sun/awt/windows/WWindowPeer"); 432 jmethodID getActiveWindowsMID = env->GetStaticMethodID(wwindowPeerCls, 433 "getActiveWindowHandles", "()[J"); 434 DASSERT(getActiveWindowsMID != NULL); 435 jlongArray windows = (jlongArray)(env->CallStaticObjectMethod(wwindowPeerCls, 436 getActiveWindowsMID)); 433 437 if (windows == NULL) { 434 438 return; -
trunk/openjdk/jdk/src/windows/native/sun/windows/awt_Window.cpp
r309 r406 1 1 /* 2 * Copyright (c) 1996, 20 07, Oracle and/or its affiliates. All rights reserved.2 * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. 3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 4 * … … 125 125 jfieldID AwtWindow::locationByPlatformID; 126 126 jfieldID AwtWindow::autoRequestFocusID; 127 128 jclass AwtWindow::wwindowPeerCls;129 jmethodID AwtWindow::getActiveWindowsMID;130 127 131 128 jfieldID AwtWindow::sysXID; … … 2169 2166 AwtWindow::sysHID = env->GetFieldID(cls, "sysH", "I"); 2170 2167 2171 AwtWindow::wwindowPeerCls = cls;2172 AwtWindow::getActiveWindowsMID =2173 env->GetStaticMethodID(cls, "getActiveWindowHandles", "()[J");2174 DASSERT(AwtWindow::getActiveWindowsMID != NULL);2175 2176 2168 CATCH_BAD_ALLOC; 2177 2169 } -
trunk/openjdk/jdk/src/windows/native/sun/windows/awt_Window.h
r309 r406 57 57 static jfieldID screenID; /* screen number passed over from WindowPeer */ 58 58 static jfieldID autoRequestFocusID; 59 60 /* WWindowPeer class */61 static jclass wwindowPeerCls;62 /* long[] getActiveWindowHandles() method in WWindowPeer */63 static jmethodID getActiveWindowsMID;64 59 65 60 // The coordinates at the peer.
Note:
See TracChangeset
for help on using the changeset viewer.