Changeset 406 for trunk/openjdk/jdk/src


Ignore:
Timestamp:
Dec 21, 2012, 10:37:13 AM (13 years ago)
Author:
dmik
Message:

trunk: Merged in openjdk6 b27 from branches/vendor/oracle.

Location:
trunk/openjdk
Files:
2 deleted
125 edited
18 copied

Legend:

Unmodified
Added
Removed
  • trunk/openjdk

  • trunk/openjdk/jdk/src/share/classes/com/sun/beans/finder/ClassFinder.java

    r278 r406  
    11/*
    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.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    2424 */
    2525package com.sun.beans.finder;
     26
     27import static sun.reflect.misc.ReflectUtil.checkPackageAccess;
    2628
    2729/**
     
    5456     */
    5557    public static Class findClass( String name ) throws ClassNotFoundException {
     58        checkPackageAccess(name);
    5659        try {
    5760            ClassLoader loader = Thread.currentThread().getContextClassLoader();
     
    9497     */
    9598    public static Class findClass( String name, ClassLoader loader ) throws ClassNotFoundException {
     99        checkPackageAccess(name);
    96100        if ( loader != null ) {
    97101            try {
  • trunk/openjdk/jdk/src/share/classes/com/sun/java/util/jar/pack/Driver.java

    r278 r406  
    11/*
    2  * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    355355
    356356
    357         File f = File.createTempFile(prefix, suffix, where);
    358         return f;
     357        return sun.misc.IOUtils.createTempFile(prefix, suffix, where);
    359358    }
    360359
  • trunk/openjdk/jdk/src/share/classes/com/sun/script/javascript/RhinoScriptEngine.java

    r309 r406  
    11/*
    2  * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    131131
    132132        if (System.getSecurityManager() != null) {
    133             accCtxt = AccessController.getContext();
     133            try {
     134                AccessController.checkPermission(new AllPermission());
     135            } catch (AccessControlException ace) {
     136                accCtxt = AccessController.getContext();
     137            }
    134138        }
    135139
  • trunk/openjdk/jdk/src/share/classes/java/awt/AWTEvent.java

    r309 r406  
    269269                }
    270270
     271                public void setPosted(AWTEvent ev) {
     272                    ev.isPosted = true;
     273                }
     274
    271275                public AccessControlContext getAccessControlContext(AWTEvent ev) {
    272276                    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;
    273285                }
    274286        });
  • trunk/openjdk/jdk/src/share/classes/java/awt/CheckboxMenuItem.java

    r278 r406  
    3232import java.io.IOException;
    3333import javax.accessibility.*;
     34import sun.awt.AWTAccessor;
    3435
    3536
     
    6970            initIDs();
    7071        }
     72       
     73        AWTAccessor.setCheckboxMenuItemAccessor(
     74            new AWTAccessor.CheckboxMenuItemAccessor() {
     75                public boolean getState(CheckboxMenuItem cmi) {
     76                    return cmi.state;
     77                }
     78            });
    7179    }
    7280
  • trunk/openjdk/jdk/src/share/classes/java/awt/Component.java

    r309 r406  
    799799    static {
    800800        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
    801809                public AccessControlContext getAccessControlContext(Component comp) {
    802810                    return comp.getAccessControlContext();
    803811                }
    804812
     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                }
    805820            });
    806821    }
  • trunk/openjdk/jdk/src/share/classes/java/awt/Cursor.java

    r278 r406  
    3939
    4040import java.security.AccessController;
     41import sun.awt.AWTAccessor;
    4142
    4243/**
     
    194195            initIDs();
    195196        }
     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            });
    196212    }
    197213
  • trunk/openjdk/jdk/src/share/classes/java/awt/DefaultKeyboardFocusManager.java

    r278 r406  
    4141import sun.awt.AppContext;
    4242import sun.awt.SunToolkit;
     43import sun.awt.AWTAccessor;
    4344import sun.awt.CausedFocusEvent;
    4445
     
    7677        typeAheadMarkers = new LinkedList();
    7778    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    }
    7889
    7990    private static class TypeAheadMarker {
  • trunk/openjdk/jdk/src/share/classes/java/awt/EventQueue.java

    r309 r406  
    4343import sun.awt.PeerEvent;
    4444import sun.awt.SunToolkit;
     45import sun.awt.AWTAccessor;
    4546
    4647import java.security.AccessControlContext;
    47 import java.security.ProtectionDomain;
    4848
    4949import sun.misc.SharedSecrets;
     
    160160    private static final Logger eventLog = Logger.getLogger("java.awt.event.EventQueue");
    161161
     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
    162182    public EventQueue() {
    163183        for (int i = 0; i < NUM_PRIORITIES; i++) {
  • trunk/openjdk/jdk/src/share/classes/java/awt/Font.java

    r278 r406  
    11/*
    2  * Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1995, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    810810        boolean hasPerm = false;
    811811        try {
    812             f = File.createTempFile("+~JT", ".tmp", null);
     812            f = sun.misc.IOUtils.createTempFile("+~JT", ".tmp", null);
    813813            f.delete();
    814814            f = null;
     
    861861                new PrivilegedExceptionAction<File>() {
    862862                    public File run() throws IOException {
    863                         return File.createTempFile("+~JF", ".tmp", null);
     863                        return sun.misc.IOUtils.createTempFile("+~JF", ".tmp", null);
    864864                    }
    865865                }
  • trunk/openjdk/jdk/src/share/classes/java/awt/KeyboardFocusManager.java

    r390 r406  
    6161import sun.awt.SunToolkit;
    6262import sun.awt.CausedFocusEvent;
     63import sun.awt.AWTAccessor;
    6364
    6465/**
     
    118119            initIDs();
    119120        }
     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        );
    120139    }
    121140
  • trunk/openjdk/jdk/src/share/classes/java/awt/Menu.java

    r278 r406  
    3232import java.awt.event.KeyEvent;
    3333import javax.accessibility.*;
     34import sun.awt.AWTAccessor;
    3435
    3536/**
     
    6364            initIDs();
    6465        }
     66        AWTAccessor.setMenuAccessor(
     67            new AWTAccessor.MenuAccessor() {
     68                public Vector getItems(Menu menu) {
     69                    return menu.items;
     70                }
     71            });
    6572    }
    6673
  • trunk/openjdk/jdk/src/share/classes/java/awt/MenuBar.java

    r278 r406  
    2929import java.util.Vector;
    3030import java.util.Enumeration;
     31import sun.awt.AWTAccessor;
    3132import java.awt.peer.MenuBarPeer;
    3233import java.awt.event.KeyEvent;
     
    7576            initIDs();
    7677        }
     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            });
    7788    }
    7889
  • trunk/openjdk/jdk/src/share/classes/java/awt/MenuComponent.java

    r309 r406  
    3030import java.io.ObjectInputStream;
    3131import sun.awt.AppContext;
    32 import sun.awt.SunToolkit;
     32import sun.awt.AWTAccessor;
    3333import javax.accessibility.*;
    3434
     
    5656            initIDs();
    5757        }
     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            });
    5874    }
    5975
  • trunk/openjdk/jdk/src/share/classes/java/awt/MenuItem.java

    r278 r406  
    3232import java.io.IOException;
    3333import javax.accessibility.*;
    34 
     34import sun.awt.AWTAccessor;
    3535
    3636/**
     
    7777            initIDs();
    7878        }
     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            });
    79102    }
    80103
  • trunk/openjdk/jdk/src/share/classes/java/awt/PopupMenu.java

    r278 r406  
    2929import javax.accessibility.*;
    3030
     31import sun.awt.AWTAccessor;
    3132
    3233/**
     
    4849
    4950    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    }
    5060
    5161    /*
  • trunk/openjdk/jdk/src/share/classes/java/awt/ScrollPaneAdjustable.java

    r278 r406  
    2525package java.awt;
    2626
     27import sun.awt.AWTAccessor;
     28
    2729import java.awt.event.AdjustmentEvent;
    2830import java.awt.event.AdjustmentListener;
     
    157159            initIDs();
    158160        }
     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        });
    159167    }
    160168
  • trunk/openjdk/jdk/src/share/classes/java/awt/Window.java

    r278 r406  
    5151import java.util.concurrent.atomic.AtomicBoolean;
    5252import javax.accessibility.*;
     53import sun.awt.AWTAccessor;
    5354import sun.awt.AppContext;
    5455import sun.awt.CausedFocusEvent;
     
    319320            new GetPropertyAction("java.awt.Window.locationByPlatform"));
    320321        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        });
    321328    }
    322329
  • trunk/openjdk/jdk/src/share/classes/java/beans/Introspector.java

    r278 r406  
    11/*
    2  * Copyright (c) 1996, 2009, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    140140
    141141    private final static String DEFAULT_INFO_PATH = "sun.beans.infos";
     142    private final static String DEFAULT_INFO_PATH_NEW = "com.sun.beans.infos";
    142143
    143144    private static String[] searchPath = { DEFAULT_INFO_PATH };
     
    461462
    462463        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            }
    463468            // This optimization will only use the BeanInfo search path if is has changed
    464469            // 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)) {
    467471                try {
    468                     String fullName = searchPath[i] + "." + name;
     472                    String fullName = path + "." + name;
    469473                    java.beans.BeanInfo bi = (java.beans.BeanInfo)instantiate(beanClass, fullName);
    470474
  • trunk/openjdk/jdk/src/share/classes/java/beans/PropertyEditorManager.java

    r278 r406  
    11/*
    2  * Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    2626package java.beans;
    2727
    28 import sun.beans.editors.*;
     28import com.sun.beans.editors.*;
    2929
    3030/**
     
    5454
    5555public 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";
    5659
    5760    /**
     
    120123        }
    121124        for (String path : searchPath) {
    122             String name = path + '.' + editorName;
     125            String name = (DEFAULT_SEARCH_PATH.equals(path) ? DEFAULT_SEARCH_PATH_NEW : path) + '.' + editorName;
    123126            try {
    124127                return (PropertyEditor) Introspector.instantiate(targetType, name);
     
    189192    }
    190193
    191     private static String[] searchPath = { "sun.beans.editors" };
     194    private static String[] searchPath = { DEFAULT_SEARCH_PATH };
    192195    private static java.util.Hashtable registry;
    193196}
  • trunk/openjdk/jdk/src/share/classes/java/beans/XMLDecoder.java

    r278 r406  
    11/*
    2  * Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    3232import java.lang.ref.Reference;
    3333import java.lang.ref.WeakReference;
     34
     35import java.security.AccessControlContext;
     36import java.security.AccessController;
     37import java.security.PrivilegedAction;
    3438
    3539import org.xml.sax.SAXException;
     
    6771 */
    6872public class XMLDecoder {
     73    private final AccessControlContext acc = AccessController.getContext();
    6974    private InputStream in;
    7075    private Object owner;
     
    249254    private ObjectHandler getHandler() {
    250255        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");
    256258            }
    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;
    264281                }
    265                 getExceptionListener().exceptionThrown( e );
    266             }
    267             catch ( IOException ioe ) {
    268                 getExceptionListener().exceptionThrown( ioe );
    269             }
     282            }, this.acc);
    270283        }
    271284        return handler;
  • trunk/openjdk/jdk/src/share/classes/java/io/File.java

    r278 r406  
    11/*
    2  * Copyright (c) 1994, 2007, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1994, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    898898        SecurityManager security = System.getSecurityManager();
    899899        if (security != null) security.checkWrite(path);
    900         return fs.createFileExclusively(path);
     900        return fs.createFileExclusively(path, false);
    901901    }
    902902
     
    17011701    }
    17021702
    1703     private static boolean checkAndCreate(String filename, SecurityManager sm)
     1703    private static boolean checkAndCreate(String filename, SecurityManager sm,
     1704                                          boolean restrictive)
    17041705        throws IOException
    17051706    {
     
    17141715            }
    17151716        }
    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;
    17171740    }
    17181741
     
    17901813        throws IOException
    17911814    {
    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);
    18061816    }
    18071817
     
    18381848        throws IOException
    18391849    {
    1840         return createTempFile(prefix, suffix, null);
     1850        return createTempFile0(prefix, suffix, null, false);
    18411851    }
    18421852
     
    19601970        );
    19611971    }
    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    }
    19641983}
  • trunk/openjdk/jdk/src/share/classes/java/io/FilePermission.java

    r278 r406  
    400400
    401401    public int hashCode() {
    402         return this.cpath.hashCode();
     402        return 0;
    403403    }
    404404
  • trunk/openjdk/jdk/src/share/classes/java/io/FileSystem.java

    r278 r406  
    11/*
    2  * Copyright (c) 1998, 2005, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    158158     * file or directory with the given pathname already exists.  Throw an
    159159     * 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)
    162167        throws IOException;
    163168
  • trunk/openjdk/jdk/src/share/classes/java/net/URL.java

    r278 r406  
    11/*
    2  * Copyright (c) 1995, 2007, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1995, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    2929import java.io.InputStream;
    3030import java.io.OutputStream;
     31import java.security.AccessController;
     32import java.security.PrivilegedAction;
    3133import java.util.Hashtable;
    3234import java.util.StringTokenizer;
     
    11111113    private static Object streamHandlerLock = new Object();
    11121114
     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
    11131130    /**
    11141131     * Returns the Stream Handler.
     
    11421159                // REMIND: decide whether to allow the "null" class prefix
    11431160                // or not.
    1144                 packagePrefixList += "sun.net.www.protocol";
     1161                packagePrefixList += JDK_PACKAGE_PREFIX;
    11451162
    11461163                StringTokenizer packagePrefixIter =
     
    11521169                    String packagePrefix =
    11531170                      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
    11541180                    try {
    11551181                        String clsName = packagePrefix + "." + protocol +
  • trunk/openjdk/jdk/src/share/classes/java/security/AccessController.java

    r278 r406  
    11/*
    2  * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    291291    public static <T> T doPrivilegedWithCombiner(PrivilegedAction<T> action) {
    292292
    293         DomainCombiner dc = null;
    294293        AccessControlContext acc = getStackAccessControlContext();
    295         if (acc == null || (dc = acc.getAssignedCombiner()) == null) {
     294        if (acc == null) {
    296295            return AccessController.doPrivileged(action);
    297296        }
     297        DomainCombiner dc = acc.getAssignedCombiner();
    298298        return AccessController.doPrivileged(action, preserveCombiner(dc));
    299299    }
     
    387387        (PrivilegedExceptionAction<T> action) throws PrivilegedActionException {
    388388
    389         DomainCombiner dc = null;
    390389        AccessControlContext acc = getStackAccessControlContext();
    391         if (acc == null || (dc = acc.getAssignedCombiner()) == null) {
     390        if (acc == null) {
    392391            return AccessController.doPrivileged(action);
    393392        }
     393        DomainCombiner dc = acc.getAssignedCombiner();
    394394        return AccessController.doPrivileged(action, preserveCombiner(dc));
    395395    }
     
    418418        // even if the caller is from the bootclasspath
    419419        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        }
    421426    }
    422427
  • trunk/openjdk/jdk/src/share/classes/java/util/ServiceLoader.java

    r278 r406  
    359359            String cn = nextName;
    360360            nextName = null;
     361            Class<?> c = null;
    361362            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);
    366364            } catch (ClassNotFoundException x) {
    367365                fail(service,
    368366                     "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;
    369376            } catch (Throwable x) {
    370377                fail(service,
  • trunk/openjdk/jdk/src/share/classes/java/util/UUID.java

    r278 r406  
    11/*
    2  * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    123123    /*
    124124     * 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    }
    128130
    129131    // Constructors and Factories
     
    170172     */
    171173    public static UUID randomUUID() {
    172         SecureRandom ng = numberGenerator;
    173         if (ng == null) {
    174             numberGenerator = ng = new SecureRandom();
    175         }
     174        SecureRandom ng = Holder.numberGenerator;
    176175
    177176        byte[] randomBytes = new byte[16];
     
    291290     * <p><ul>
    292291     * <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&nbsp;RFC&nbsp;4122</a>
     293     * (Leach-Salz), used by this class
    294294     * <li>6    Reserved, Microsoft Corporation backward compatibility
    295295     * <li>7    Reserved for future definition
  • trunk/openjdk/jdk/src/share/classes/java/util/concurrent/Executors.java

    r278 r406  
    531531                    new PrivilegedExceptionAction<T>() {
    532532                        public T run() throws Exception {
    533                             ClassLoader savedcl = null;
    534533                            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);
    540543                                }
    541                                 return task.call();
    542                             } finally {
    543                                 if (savedcl != null)
    544                                     t.setContextClassLoader(savedcl);
    545544                            }
    546545                        }
  • trunk/openjdk/jdk/src/share/classes/java/util/logging/FileHandler.java

    r278 r406  
    11/*
    2  * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    221221     */
    222222    public FileHandler() throws IOException, SecurityException {
    223         checkAccess();
     223        checkPermission();
    224224        configure();
    225225        openFiles();
     
    247247            throw new IllegalArgumentException();
    248248        }
    249         checkAccess();
     249        checkPermission();
    250250        configure();
    251251        this.pattern = pattern;
     
    279279            throw new IllegalArgumentException();
    280280        }
    281         checkAccess();
     281        checkPermission();
    282282        configure();
    283283        this.pattern = pattern;
     
    316316            throw new IllegalArgumentException();
    317317        }
    318         checkAccess();
     318        checkPermission();
    319319        configure();
    320320        this.pattern = pattern;
     
    355355            throw new IllegalArgumentException();
    356356        }
    357         checkAccess();
     357        checkPermission();
    358358        configure();
    359359        this.pattern = pattern;
     
    368368    private void openFiles() throws IOException {
    369369        LogManager manager = LogManager.getLogManager();
    370         manager.checkAccess();
     370        manager.checkPermission();
    371371        if (count < 1) {
    372372           throw new IllegalArgumentException("file count = " + count);
  • trunk/openjdk/jdk/src/share/classes/java/util/logging/Handler.java

    r278 r406  
    11/*
    2  * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    112112     */
    113113    public void setFormatter(Formatter newFormatter) throws SecurityException {
    114         checkAccess();
     114        checkPermission();
    115115        // Check for a null pointer:
    116116        newFormatter.getClass();
     
    141141    public void setEncoding(String encoding)
    142142                        throws SecurityException, java.io.UnsupportedEncodingException {
    143         checkAccess();
     143        checkPermission();
    144144        if (encoding != null) {
    145145            try {
     
    176176     */
    177177    public void setFilter(Filter newFilter) throws SecurityException {
    178         checkAccess();
     178        checkPermission();
    179179        filter = newFilter;
    180180    }
     
    200200     */
    201201    public void setErrorManager(ErrorManager em) {
    202         checkAccess();
     202        checkPermission();
    203203        if (em == null) {
    204204           throw new NullPointerException();
     
    214214     */
    215215    public ErrorManager getErrorManager() {
    216         checkAccess();
     216        checkPermission();
    217217        return errorManager;
    218218    }
     
    254254            throw new NullPointerException();
    255255        }
    256         checkAccess();
     256        checkPermission();
    257257        logLevel = newLevel;
    258258    }
     
    297297    // appropriate security privileges to update Handler
    298298    // state and if not throw a SecurityException.
    299     void checkAccess() throws SecurityException {
     299    void checkPermission() throws SecurityException {
    300300        if (sealed) {
    301             manager.checkAccess();
     301            manager.checkPermission();
    302302        }
    303303    }
  • trunk/openjdk/jdk/src/share/classes/java/util/logging/LogManager.java

    r278 r406  
    11/*
    2  * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    304304            throw new NullPointerException();
    305305        }
    306         checkAccess();
     306        checkPermission();
    307307        changes.addPropertyChangeListener(l);
    308308    }
     
    323323     */
    324324    public void removePropertyChangeListener(PropertyChangeListener l) throws SecurityException {
    325         checkAccess();
     325        checkPermission();
    326326        changes.removePropertyChangeListener(l);
    327327    }
     
    741741     */
    742742    public void readConfiguration() throws IOException, SecurityException {
    743         checkAccess();
     743        checkPermission();
    744744
    745745        // if a configuration class is specified, load it and use it.
     
    799799
    800800    public void reset() throws SecurityException {
    801         checkAccess();
     801        checkPermission();
    802802        synchronized (this) {
    803803            props = new Properties();
     
    884884     */
    885885    public void readConfiguration(InputStream ins) throws IOException, SecurityException {
    886         checkAccess();
     886        checkPermission();
    887887        reset();
    888888
     
    10461046
    10471047
    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    }
    10491055
    10501056    /**
     
    10591065     */
    10601066    public void checkAccess() throws SecurityException {
    1061         SecurityManager sm = System.getSecurityManager();
    1062         if (sm == null) {
    1063             return;
    1064         }
    1065         sm.checkPermission(ourPermission);
     1067        checkPermission();
    10661068    }
    10671069
  • trunk/openjdk/jdk/src/share/classes/java/util/logging/Logger.java

    r278 r406  
    11/*
    2  * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    267267    }
    268268
    269     private void checkAccess() throws SecurityException {
     269    private void checkPermission() throws SecurityException {
    270270        if (!anonymous) {
    271271            if (manager == null) {
     
    273273                manager = LogManager.getLogManager();
    274274            }
    275             manager.checkAccess();
     275            manager.checkPermission();
    276276        }
    277277    }
     
    455455     */
    456456    public synchronized void setFilter(Filter newFilter) throws SecurityException {
    457         checkAccess();
     457        checkPermission();
    458458        filter = newFilter;
    459459    }
     
    11461146     */
    11471147    public void setLevel(Level newLevel) throws SecurityException {
    1148         checkAccess();
     1148        checkPermission();
    11491149        synchronized (treeLock) {
    11501150            levelObject = newLevel;
     
    12011201        // Check for null handler
    12021202        handler.getClass();
    1203         checkAccess();
     1203        checkPermission();
    12041204        if (handlers == null) {
    12051205            handlers = new ArrayList<Handler>();
     
    12181218     */
    12191219    public synchronized void removeHandler(Handler handler) throws SecurityException {
    1220         checkAccess();
     1220        checkPermission();
    12211221        if (handler == null) {
    12221222            return;
     
    12521252     */
    12531253    public synchronized void setUseParentHandlers(boolean useParentHandlers) {
    1254         checkAccess();
     1254        checkPermission();
    12551255        this.useParentHandlers = useParentHandlers;
    12561256    }
     
    13891389            throw new NullPointerException();
    13901390        }
    1391         manager.checkAccess();
     1391        manager.checkPermission();
    13921392        doSetParent(parent);
    13931393    }
  • trunk/openjdk/jdk/src/share/classes/java/util/logging/MemoryHandler.java

    r278 r406  
    11/*
    2  * Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    239239        }
    240240        LogManager manager = LogManager.getLogManager();
    241         checkAccess();
     241        checkPermission();
    242242        pushLevel = newLevel;
    243243    }
  • trunk/openjdk/jdk/src/share/classes/java/util/logging/StreamHandler.java

    r278 r406  
    11/*
    2  * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    250250
    251251    private synchronized void flushAndClose() throws SecurityException {
    252         checkAccess();
     252        checkPermission();
    253253        if (writer != null) {
    254254            try {
  • trunk/openjdk/jdk/src/share/classes/javax/crypto/CipherSpi.java

    r278 r406  
    11/*
    2  * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    743743            byte[] inArray = new byte[getTempArraySize(inLen)];
    744744            int total = 0;
    745             while (inLen > 0) {
     745            do {
    746746                int chunk = Math.min(inLen, inArray.length);
    747747                input.get(inArray, 0, chunk);
     
    755755                outOfs += n;
    756756                inLen -= chunk;
    757             }
     757            } while (inLen > 0);
    758758            output.position(outPos + total);
    759759            return total;
     
    772772            int total = 0;
    773773            boolean resized = false;
    774             while (inLen > 0) {
     774            do {
    775775                int chunk = Math.min(inLen, outSize);
    776776                if ((a1 == false) && (resized == false)) {
     
    802802                    outArray = new byte[newOut];
    803803                }
    804             }
     804            } while (inLen > 0);
    805805            input.position(inLimit);
    806806            return total;
  • trunk/openjdk/jdk/src/share/classes/javax/imageio/stream/FileCacheImageInputStream.java

    r278 r406  
    11/*
    2  * Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    9999        this.stream = stream;
    100100        this.cacheFile =
    101             File.createTempFile("imageio", ".tmp", cacheDir);
     101            sun.misc.IOUtils.createTempFile("imageio", ".tmp", cacheDir);
    102102        this.cache = new RandomAccessFile(cacheFile, "rw");
    103103
  • trunk/openjdk/jdk/src/share/classes/javax/imageio/stream/FileCacheImageOutputStream.java

    r278 r406  
    11/*
    2  * Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    8585        this.stream = stream;
    8686        this.cacheFile =
    87             File.createTempFile("imageio", ".tmp", cacheDir);
     87            sun.misc.IOUtils.createTempFile("imageio", ".tmp", cacheDir);
    8888        this.cache = new RandomAccessFile(cacheFile, "rw");
    8989
  • trunk/openjdk/jdk/src/share/classes/javax/management/loading/MLet.java

    r278 r406  
    11/*
    2  * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    11531153                 File directory = new File(libraryDirectory);
    11541154                 directory.mkdirs();
    1155                  File file = File.createTempFile(libname + ".", null, directory);
     1155                 File file = sun.misc.IOUtils.createTempFile(libname + ".", null, directory);
    11561156                 file.deleteOnExit();
    11571157                 FileOutputStream fileOutput = new FileOutputStream(file);
  • trunk/openjdk/jdk/src/share/classes/javax/management/modelmbean/DescriptorSupport.java

    r278 r406  
    11/*
    2  * Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    12401240        }
    12411241        final String className = s.substring(1, slash);
     1242       
    12421243        final Constructor<?> constr;
    12431244        try {
     1245            ReflectUtil.checkPackageAccess(className);
    12441246            final ClassLoader contextClassLoader =
    12451247                Thread.currentThread().getContextClassLoader();
    1246             if (contextClassLoader == null) {
    1247                 ReflectUtil.checkPackageAccess(className);
    1248             }
    12491248            final Class<?> c =
    12501249                Class.forName(className, false, contextClassLoader);
  • trunk/openjdk/jdk/src/share/classes/javax/management/remote/rmi/RMIConnectionImpl.java

    r278 r406  
    11/*
    2  * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    4040import java.rmi.UnmarshalException;
    4141import java.rmi.server.Unreferenced;
     42
    4243import java.security.AccessControlContext;
    4344import java.security.AccessController;
     45import java.security.Permission;
     46import java.security.PermissionCollection;
     47import java.security.Permissions;
    4448import java.security.PrivilegedAction;
    4549import java.security.PrivilegedActionException;
    4650import java.security.PrivilegedExceptionAction;
     51import java.security.ProtectionDomain;
     52
    4753import java.util.Arrays;
    4854import java.util.Collections;
     
    6167import javax.management.MBeanInfo;
    6268import javax.management.MBeanRegistrationException;
     69import javax.management.MBeanPermission;
    6370import javax.management.MBeanServer;
    6471import javax.management.NotCompliantMBeanException;
     
    145152
    146153        final ClassLoader dcl = defaultClassLoader;
     154
    147155        this.classLoaderWithRepository =
    148156            AccessController.doPrivileged(
     
    150158                    public ClassLoaderWithRepository run() {
    151159                        return new ClassLoaderWithRepository(
    152                                               getClassLoaderRepository(),
     160                                              mbeanServer.getClassLoaderRepository(),
    153161                                              dcl);
    154162                    }
     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                    }
    155176                });
    156 
    157         serverCommunicatorAdmin = new
    158           RMIServerCommunicatorAdmin(EnvHelp.getServerConnectionTimeout(env));
     177        serverCommunicatorAdmin = new
     178            RMIServerCommunicatorAdmin(EnvHelp.getServerConnectionTimeout(env));
    159179
    160180        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 });
    161192    }
    162193
     
    507538                 +" unwrapping query with defaultClassLoader.");
    508539
    509         queryValue = unwrap(query, defaultClassLoader, QueryExp.class);
     540        queryValue = unwrap(query, defaultContextClassLoader, QueryExp.class);
    510541
    511542        try {
     
    541572                 +" unwrapping query with defaultClassLoader.");
    542573
    543         queryValue = unwrap(query, defaultClassLoader, QueryExp.class);
     574        queryValue = unwrap(query, defaultContextClassLoader, QueryExp.class);
    544575
    545576        try {
     
    13151346    //------------------------------------------------------------------------
    13161347
    1317     private ClassLoaderRepository getClassLoaderRepository() {
    1318         return
    1319             AccessController.doPrivileged(
    1320                 new PrivilegedAction<ClassLoaderRepository>() {
    1321                     public ClassLoaderRepository run() {
    1322                         return mbeanServer.getClassLoaderRepository();
    1323                     }
    1324                 });
    1325     }
    1326 
    13271348    private ClassLoader getClassLoader(final ObjectName name)
    13281349        throws InstanceNotFoundException {
     
    13341355                            return mbeanServer.getClassLoader(name);
    13351356                        }
    1336                     });
     1357                    },
     1358                    withPermissions(new MBeanPermission("*", "getClassLoader"))
     1359            );
    13371360        } catch (PrivilegedActionException pe) {
    13381361            throw (InstanceNotFoundException) extractException(pe);
     
    13491372                            return mbeanServer.getClassLoaderFor(name);
    13501373                        }
    1351                     });
     1374                    },
     1375                    withPermissions(new MBeanPermission("*", "getClassLoaderFor"))
     1376            );
    13521377        } catch (PrivilegedActionException pe) {
    13531378            throw (InstanceNotFoundException) extractException(pe);
     
    15761601                new PrivilegedExceptionAction<ClassLoader>() {
    15771602                    public ClassLoader run() throws Exception {
    1578                         return new OrderClassLoaders(cl1, cl2);
     1603                        return new CombinedClassLoader(Thread.currentThread().getContextClassLoader(),
     1604                                new OrderClassLoaders(cl1, cl2));
    15791605                    }
    15801606                }
     
    16681694    private final ClassLoader defaultClassLoader;
    16691695
     1696    private final ClassLoader defaultContextClassLoader;
     1697
    16701698    private final ClassLoaderWithRepository classLoaderWithRepository;
    16711699
     
    17521780    private static final ClassLogger logger =
    17531781        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    }
    17541821}
  • trunk/openjdk/jdk/src/share/classes/javax/swing/ClientPropertyKey.java

    r278 r406  
    2525
    2626package javax.swing;
     27
     28import sun.awt.AWTAccessor;
    2729
    2830/**
     
    8789    private final boolean reportValueNotSerializable;
    8890
     91    static {
     92        AWTAccessor.setClientPropertyKeyAccessor(
     93            new AWTAccessor.ClientPropertyKeyAccessor() {
     94                public Object getJComponent_TRANSFER_HANDLER() {
     95                    return JComponent_TRANSFER_HANDLER;
     96                }
     97            });
     98    }
     99
    89100    /**
    90101     * Constructs a key with the {@code reportValueNotSerializable} property
  • trunk/openjdk/jdk/src/share/classes/javax/swing/plaf/synth/SynthButtonUI.java

    r278 r406  
    136136            state = DISABLED;
    137137        }
    138         if (SynthLookAndFeel.selectedUI == this) {
    139             return SynthLookAndFeel.selectedUIState | SynthConstants.ENABLED;
     138        if (SynthLookAndFeel.getSelectedUI() == this) {
     139            return SynthLookAndFeel.getSelectedUIState() | SynthConstants.ENABLED;
    140140        }
    141141        AbstractButton button = (AbstractButton) c;
  • trunk/openjdk/jdk/src/share/classes/javax/swing/plaf/synth/SynthLabelUI.java

    r278 r406  
    9595    private int getComponentState(JComponent c) {
    9696        int state = SynthLookAndFeel.getComponentState(c);
    97         if (SynthLookAndFeel.selectedUI == this &&
     97        if (SynthLookAndFeel.getSelectedUI() == this &&
    9898                        state == SynthConstants.ENABLED) {
    99             state = SynthLookAndFeel.selectedUIState | SynthConstants.ENABLED;
     99            state = SynthLookAndFeel.getSelectedUIState() | SynthConstants.ENABLED;
    100100        }
    101101        return state;
  • trunk/openjdk/jdk/src/share/classes/javax/swing/plaf/synth/SynthLookAndFeel.java

    r278 r406  
    7979
    8080    /**
     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    /**
    8191     * The last SynthStyleFactory that was asked for from AppContext
    8292     * <code>lastContext</code>.
     
    8494    private static SynthStyleFactory lastFactory;
    8595    /**
    86      * If this is true it indicates there is more than one AppContext active
    87      * and that we need to make sure in getStyleCache the requesting
    88      * AppContext matches that of <code>lastContext</code> before returning
    89      * it.
    90      */
    91     private static boolean multipleApps;
    92     /**
    9396     * AppContext lastLAF came from.
    9497     */
    9598    private static AppContext lastContext;
    96 
    97     // Refer to setSelectedUI
    98     static ComponentUI selectedUI;
    99     // Refer to setSelectedUI
    100     static int selectedUIState;
    10199
    102100    /**
     
    112110
    113111    private Handler _handler;
     112
     113    static ComponentUI getSelectedUI() {
     114        return (ComponentUI) AppContext.getAppContext().get(SELECTED_UI_KEY);
     115    }
    114116
    115117    /**
     
    124126                              boolean focused, boolean enabled,
    125127                              boolean rollover) {
    126         selectedUI = uix;
    127         selectedUIState = 0;
     128        int selectedUIState = 0;
     129
    128130        if (selected) {
    129131            selectedUIState = SynthConstants.SELECTED;
     
    142144            if (enabled) {
    143145                selectedUIState |= SynthConstants.ENABLED;
    144                 selectedUIState = SynthConstants.FOCUSED;
     146                if (focused) {
     147                    selectedUIState |= SynthConstants.FOCUSED;
     148                }
    145149            }
    146150            else {
     
    148152            }
    149153        }
     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();
    150165    }
    151166
     
    154169     */
    155170    static void resetSelectedUI() {
    156         selectedUI = null;
     171        AppContext.getAppContext().remove(SELECTED_UI_KEY);
    157172    }
    158173
     
    169184        synchronized(SynthLookAndFeel.class) {
    170185            AppContext context = AppContext.getAppContext();
    171             if (!multipleApps && context != lastContext &&
    172                                  lastContext != null) {
    173                 multipleApps = true;
    174             }
    175186            lastFactory = cache;
    176187            lastContext = context;
     
    186197    public static SynthStyleFactory getStyleFactory() {
    187198        synchronized(SynthLookAndFeel.class) {
    188             if (!multipleApps) {
    189                 return lastFactory;
    190             }
    191199            AppContext context = AppContext.getAppContext();
    192200
     
    195203            }
    196204            lastContext = context;
    197             lastFactory = (SynthStyleFactory)AppContext.getAppContext().get
    198                                            (STYLE_FACTORY_KEY);
     205            lastFactory = (SynthStyleFactory) context.get(STYLE_FACTORY_KEY);
    199206            return lastFactory;
    200207        }
  • trunk/openjdk/jdk/src/share/classes/javax/swing/text/DefaultFormatter.java

    r278 r406  
    2424 */
    2525package javax.swing.text;
     26
     27import sun.reflect.misc.ConstructorUtil;
    2628
    2729import java.io.Serializable;
     
    246248
    247249            try {
    248                 cons = vc.getConstructor(new Class[] { String.class });
     250                cons = ConstructorUtil.getConstructor(vc, new Class[]{String.class});
    249251
    250252            } catch (NoSuchMethodException nsme) {
  • trunk/openjdk/jdk/src/share/classes/sun/awt/AWTAccessor.java

    r278 r406  
    2727
    2828import java.awt.*;
    29 import java.awt.event.InputEvent;
    30 import java.awt.geom.Point2D;
    31 import java.awt.image.BufferedImage;
    3229
    3330import sun.misc.Unsafe;
    34 import java.awt.peer.ComponentPeer;
    35 
    36 import java.security.AccessController;
     31
    3732import java.security.AccessControlContext;
     33
     34import java.util.Vector;
     35
     36import java.awt.event.KeyEvent;
    3837
    3938/**
     
    5655    }
    5756
     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
    5868    /*
    5969     * An interface of accessor for the java.awt.Component class.
    6070     */
    6171    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
    6282        /*
    6383         * Returns the acc this component was constructed with.
    6484         */
    6585        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);
    66115    }
    67116
     
    70119     */
    71120    public interface AWTEventAccessor {
     121        /**
     122         * Marks the event as posted.
     123         */
     124        void setPosted(AWTEvent ev);
     125
    72126        /**
    73127         * Sets the flag on this AWTEvent indicating that it was
     
    81135        boolean isSystemGenerated(AWTEvent ev);
    82136
    83 
    84137        /*
    85138         * Returns the acc this event was constructed with.
     
    87140        AccessControlContext getAccessControlContext(AWTEvent ev);
    88141
     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);
    89326    }
    90327
     
    93330     * corresponding AWT classes by using setters defined below.
    94331     */
     332    private static WindowAccessor windowAccessor;
    95333    private static ComponentAccessor componentAccessor;
     334    private static KeyboardFocusManagerAccessor kfmAccessor;
    96335    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    }
    97365
    98366    /*
     
    114382    }
    115383
     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
    116401    /*
    117402     * Set an accessor object for the java.awt.AWTEvent class.
     
    130415        return awtEventAccessor;
    131416    }
     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    }
    132607}
  • trunk/openjdk/jdk/src/share/classes/sun/awt/KeyboardFocusManagerPeerImpl.java

    r278 r406  
    3131import java.awt.peer.KeyboardFocusManagerPeer;
    3232
    33 import java.lang.reflect.InvocationTargetException;
    34 import java.lang.reflect.Method;
    35 
    36 
    3733public class KeyboardFocusManagerPeerImpl implements KeyboardFocusManagerPeer {
    3834    static native Window getNativeFocusedWindow();
     
    5753    }
    5854
    59     static Method m_removeLastFocusRequest = null;
    6055    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);
    7257    }
    7358}
  • trunk/openjdk/jdk/src/share/classes/sun/awt/SunToolkit.java

    r390 r406  
    3333import java.awt.event.WindowEvent;
    3434import java.awt.event.KeyEvent;
    35 import java.awt.im.spi.InputMethodDescriptor;
    3635import java.awt.image.*;
    37 import java.awt.geom.AffineTransform;
    3836import java.awt.TrayIcon;
    3937import java.awt.SystemTray;
    40 import java.io.*;
    4138import java.net.URL;
    42 import java.net.JarURLConnection;
    4339import java.util.*;
    4440import java.util.concurrent.TimeUnit;
     
    5046import sun.font.FontDesignMetrics;
    5147import sun.awt.im.InputContext;
    52 import sun.awt.im.SimpleInputMethodWindow;
    5348import sun.awt.image.*;
    5449import sun.security.action.GetPropertyAction;
    5550import sun.security.action.GetBooleanAction;
    56 import java.lang.reflect.Field;
    5751import java.lang.reflect.Method;
    5852import java.lang.reflect.Constructor;
     
    6054import java.security.AccessController;
    6155import java.security.PrivilegedAction;
    62 import java.security.PrivilegedActionException;
    63 import java.security.PrivilegedExceptionAction;
    6456
    6557public abstract class SunToolkit extends Toolkit
     
    8375    public static final int GRAB_EVENT_MASK = 0x80000000;
    8476
    85     private static Field syncLWRequestsField;
    8677    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;
    9378    /* The key to put()/get() the PostEventQueue into/from the AppContext.
    9479     */
     
    327312    }
    328313
    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             }//run
    344         });
    345     }
    346 
    347314    static void wakeupEventQueue(EventQueue q, boolean isShutdown){
    348315        if (wakeupMethod == null){
     
    418385    private static boolean setAppContext(Object target, AppContext context)
    419386    {
    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 {
    421394            return false;
    422395        }
    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 
    439396        return true;
    440397    }
     
    445402     */
    446403    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        }
    464413    }
    465414
     
    509458
    510459    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);
    521461    };
    522462
     
    626566     */
    627567    public static void postPriorityEvent(final AWTEvent e) {
    628         if (isPostedField == null) {
    629             isPostedField = getField(AWTEvent.class, "isPosted");
    630         }
    631568        PeerEvent pe = new PeerEvent(Toolkit.getDefaultToolkit(), new Runnable() {
    632569                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);
    640571                    ((Component)e.getSource()).dispatchEvent(e);
    641572                }
     
    746677
    747678    /*
    748      * Returns next queue for the given EventQueue which has private access
    749      */
    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 access
    764      */
    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     /*
    778679     * Returns true if the calling thread is the event dispatch thread
    779680     * contained within AppContext which associated with the given target.
     
    785686        EventQueue eq = (EventQueue)appContext.get(AppContext.EVENT_QUEUE_KEY);
    786687
    787         EventQueue next = getNextQueue(eq);
     688        EventQueue next = AWTAccessor.getEventQueueAccessor().getNextQueue(eq);
    788689        while (next != null) {
    789690            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));
    794696    }
    795697
     
    15251427    }
    15261428
    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 
    15431429    public static class OperationTimedOut extends RuntimeException {
    15441430        public OperationTimedOut(String msg) {
     
    16831569    private final Object waitLock = "Wait Lock";
    16841570
    1685     static Method eqNoEvents;
    1686 
    16871571    private boolean isEQEmpty() {
    16881572        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);
    17001574    }
    17011575
     
    19521826     * however Swing could use it in the future.
    19531827     */
    1954     private static Method consumeNextKeyTypedMethod = null;
    19551828    public static synchronized void consumeNextKeyTyped(KeyEvent keyEvent) {
    1956         if (consumeNextKeyTypedMethod == null) {
    1957             consumeNextKeyTypedMethod = getMethod(DefaultKeyboardFocusManager.class,
    1958                                                   "consumeNextKeyTyped",
    1959                                                   new Class[] {KeyEvent.class});
    1960         }
    19611829        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();
    19681836        }
    19691837    }
  • trunk/openjdk/jdk/src/share/classes/sun/misc/IOUtils.java

    r278 r406  
    11/*
    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.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    3131
    3232import java.io.EOFException;
     33import java.io.File;
    3334import java.io.IOException;
    3435import java.io.InputStream;
     
    7879        return output;
    7980    }
     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    }
    80114}
  • trunk/openjdk/jdk/src/share/classes/sun/misc/Service.java

    r278 r406  
    285285            String cn = nextName;
    286286            nextName = null;
     287            Class<?> c = null;
    287288            try {
    288                 return Class.forName(cn, true, loader).newInstance();
     289                c = Class.forName(cn, false, loader);
    289290            } catch (ClassNotFoundException x) {
    290291                fail(service,
    291292                     "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) {
    293301                fail(service,
    294302                     "Provider " + cn + " could not be instantiated: " + x,
  • trunk/openjdk/jdk/src/share/classes/sun/misc/SharedSecrets.java

    r390 r406  
    11/*
    2  * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    5454    private static JavaSecurityAccess javaSecurityAccess;
    5555    private static JavaAWTAccess javaAWTAccess;
     56    private static JavaIOFileAccess javaIOFileAccess;
    5657
    5758    public static JavaUtilJarAccess javaUtilJarAccess() {
     
    150151        return javaAWTAccess;
    151152    }
     153   
     154    public static void setJavaIOFileAccess(JavaIOFileAccess access) {
     155        javaIOFileAccess = access;
     156    }
     157
     158    public static JavaIOFileAccess getJavaIOFileAccess() {
     159        return javaIOFileAccess;
     160    }
    152161}
  • trunk/openjdk/jdk/src/share/classes/sun/net/www/protocol/jar/URLJarFile.java

    r278 r406  
    11/*
    2  * Copyright (c) 2001, 2006, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    220220                            File tmpFile = null;
    221221                            try {
    222                                 tmpFile = File.createTempFile("jar_cache", null);
     222                                tmpFile = sun.misc.IOUtils.createTempFile("jar_cache", null);
    223223                                tmpFile.deleteOnExit();
    224224                                out  = new FileOutputStream(tmpFile);
  • trunk/openjdk/jdk/src/share/classes/sun/print/PSPrinterJob.java

    r278 r406  
    11/*
    2  * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    653653                     * removed when the VM exits.
    654654                     */
    655                     spoolFile = File.createTempFile("javaprint", ".ps", null);
     655                    spoolFile = sun.misc.IOUtils.createTempFile("javaprint", ".ps", null);
    656656                    spoolFile.deleteOnExit();
    657657
  • trunk/openjdk/jdk/src/share/classes/sun/rmi/registry/RegistryImpl.java

    r390 r406  
    11/*
    2  * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    406406        perms.add(new SocketPermission("*", "connect,accept"));
    407407
    408         perms.add(new RuntimePermission("accessClassInPackage.sun.*"));
     408        perms.add(new RuntimePermission("accessClassInPackage.sun.jvmstat.*"));
     409        perms.add(new RuntimePermission("accessClassInPackage.sun.jvm.hotspot.*"));
    409410
    410411        perms.add(new FilePermission("<<ALL FILES>>", "read"));
  • trunk/openjdk/jdk/src/share/classes/sun/rmi/server/Activation.java

    r278 r406  
    11/*
    2  * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    19171917                        public Void run() throws IOException {
    19181918                            File file =
    1919                                 File.createTempFile("rmid-err", null, null);
     1919                                sun.misc.IOUtils.createTempFile("rmid-err", null, null);
    19201920                            PrintStream errStream =
    19211921                                new PrintStream(new FileOutputStream(file));
  • trunk/openjdk/jdk/src/share/classes/sun/security/pkcs11/P11Cipher.java

    r278 r406  
    11/*
    2  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    651651    protected int engineGetKeySize(Key key) throws InvalidKeyException {
    652652        int n = P11SecretKeyFactory.convertKey
    653                                 (token, key, keyAlgorithm).keyLength();
     653                                (token, key, keyAlgorithm).length();
    654654        return n;
    655655    }
  • trunk/openjdk/jdk/src/share/classes/sun/security/pkcs11/P11Key.java

    r278 r406  
    11/*
    2  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    4747
    4848import sun.security.util.DerValue;
     49import sun.security.util.Length;
    4950
    5051/**
     
    6263 * @since   1.5
    6364 */
    64 abstract class P11Key implements Key {
     65abstract class P11Key implements Key, Length {
    6566
    6667    private final static String PUBLIC = "public";
     
    213214    }
    214215
    215     int keyLength() {
     216    /**
     217     * Return bit length of the key.
     218     */
     219    @Override
     220    public int length() {
    216221        return keyLength;
    217222    }
  • trunk/openjdk/jdk/src/share/classes/sun/security/pkcs11/P11RSACipher.java

    r278 r406  
    11/*
    2  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    202202            throw new InvalidKeyException("Unknown key type: " + p11Key);
    203203        }
    204         int n = (p11Key.keyLength() + 7) >> 3;
     204        int n = (p11Key.length() + 7) >> 3;
    205205        outputSize = n;
    206206        buffer = new byte[n];
     
    459459    // see JCE spec
    460460    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();
    462462        return n;
    463463    }
  • trunk/openjdk/jdk/src/share/classes/sun/security/pkcs11/P11Signature.java

    r278 r406  
    11/*
    2  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    275275                    signature = new byte[40];
    276276                } else {
    277                     signature = new byte[(p11Key.keyLength() + 7) >> 3];
     277                    signature = new byte[(p11Key.length() + 7) >> 3];
    278278                }
    279279                if (type == T_UPDATE) {
     
    360360            int keyLen;
    361361            if (publicKey instanceof P11Key) {
    362                 keyLen = ((P11Key) publicKey).keyLength();
     362                keyLen = ((P11Key) publicKey).length();
    363363            } else {
    364364                keyLen = ((RSAKey) publicKey).getModulus().bitLength();
     
    621621    private byte[] pkcs1Pad(byte[] data) {
    622622        try {
    623             int len = (p11Key.keyLength() + 7) >> 3;
     623            int len = (p11Key.length() + 7) >> 3;
    624624            RSAPadding padding = RSAPadding.getInstance
    625625                                        (RSAPadding.PAD_BLOCKTYPE_1, len);
  • trunk/openjdk/jdk/src/share/classes/sun/security/provider/SecureRandom.java

    r278 r406  
    11/*
    2  * Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    5656
    5757    private static final long serialVersionUID = 3581829991155417889L;
    58 
    59     /**
    60      * This static object will be seeded by SeedGenerator, and used
    61      * to seed future instances of SecureRandom
    62      */
    63     private static SecureRandom seeder;
    6458
    6559    private static final int DIGEST_SIZE = 20;
     
    174168
    175169    /**
     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    /**
    176192     * Generates a user-specified number of random bytes.
    177193     *
     
    184200
    185201        if (state == null) {
    186             if (seeder == null) {
    187                 seeder = new SecureRandom(SeedGenerator.getSystemEntropy());
    188                 seeder.engineSetSeed(engineGenerateSeed(DIGEST_SIZE));
    189             }
    190 
    191202            byte[] seed = new byte[DIGEST_SIZE];
    192             seeder.engineNextBytes(seed);
     203            SeederHolder.seeder.engineNextBytes(seed);
    193204            state = digest.digest(seed);
    194205        }
  • trunk/openjdk/jdk/src/share/classes/sun/security/ssl/AppOutputStream.java

    r390 r406  
    11/*
    2  * Copyright (c) 1996, 20111 Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    8989        try {
    9090            do {
     91                boolean holdRecord = false;
    9192                int howmuch;
    9293                if (isFirstRecordOfThePayload && c.needToSplitPayload()) {
    9394                    howmuch = (len == 0) ? 0 : Math.min(
    9495                        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                    }
    95106                } else {
    96107                    howmuch = Math.min(len, r.availableDataBytes());
     
    106117                    len -= howmuch;
    107118                }
    108                 c.writeRecord(r);
     119                c.writeRecord(r, holdRecord);
    109120                c.checkWrite();
    110121            } while (len > 0);
  • trunk/openjdk/jdk/src/share/classes/sun/security/ssl/EngineOutputRecord.java

    r309 r406  
    11/*
    2  * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    156156     * generated.
    157157     */
    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 {
    160161        /*
    161162         * Copy data out of buffer, it's ready to go.
     
    197198            addMAC(writeMAC);
    198199            encrypt(writeCipher);
    199             write((OutputStream)null);  // send down for processing
     200            write((OutputStream)null, false,   // send down for processing
     201                (ByteArrayOutputStream)null); 
    200202        }
    201203        return;
  • trunk/openjdk/jdk/src/share/classes/sun/security/ssl/HandshakeInStream.java

    r278 r406  
    11/*
    2  * Copyright (c) 1996, 2007, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    191191    byte[] getBytes8() throws IOException {
    192192        int len = getInt8();
     193        verifyLength(len);
    193194        byte b[] = new byte[len];
    194195
     
    199200    byte[] getBytes16() throws IOException {
    200201        int len = getInt16();
     202        verifyLength(len);
    201203        byte b[] = new byte[len];
    202204
     
    207209    byte[] getBytes24() throws IOException {
    208210        int len = getInt24();
     211        verifyLength(len);
    209212        byte b[] = new byte[len];
    210213
     
    213216    }
    214217
     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
    215226}
  • trunk/openjdk/jdk/src/share/classes/sun/security/ssl/Handshaker.java

    r278 r406  
    11/*
    2  * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    777777                System.out.println("RSA master secret generation error:");
    778778                e.printStackTrace(System.out);
    779                 System.out.println("Generating new random premaster secret");
    780779            }
    781             preMasterSecret = RSAClientKeyExchange.generateDummySecret(protocolVersion);
     780            preMasterSecret =
     781                    RSAClientKeyExchange.generateDummySecret(protocolVersion);
    782782            // recursive call with new premaster secret
    783783            return calculateMasterSecret(preMasterSecret, null);
     
    822822                + protocolVersion + " or " + requestedVersion + ", decrypted: "
    823823                + premasterVersion);
    824             System.out.println("Generating new random premaster secret");
    825         }
    826         preMasterSecret = RSAClientKeyExchange.generateDummySecret(protocolVersion);
     824        }
     825        preMasterSecret =
     826                RSAClientKeyExchange.generateDummySecret(protocolVersion);
    827827        // recursive call with new premaster secret
    828828        return calculateMasterSecret(preMasterSecret, null);
  • trunk/openjdk/jdk/src/share/classes/sun/security/ssl/OutputRecord.java

    r278 r406  
    11/*
    2  * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    2929import java.io.*;
    3030import java.nio.*;
     31import java.util.Arrays;
    3132
    3233import javax.net.ssl.SSLException;
     
    228229
    229230    /*
     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    /*
    230249     * Return the type of SSL record that's buffered here.
    231250     */
     
    244263     * in a single low level write, for efficiency.
    245264     */
    246     void write(OutputStream s) throws IOException {
     265    void write(OutputStream s, boolean holdRecord,
     266            ByteArrayOutputStream heldRecordBuffer) throws IOException {
    247267        /*
    248268         * Don't emit content-free records.  (Even change cipher spec
     
    301321        firstMessage = false;
    302322
    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        }
    304365        reset();
    305366    }
     
    310371     * action.
    311372     */
    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 {
    314375        s.write(buf, off, len);
    315376        s.flush();
    316377
     378        // Output only the record from the specified debug offset.
    317379        if (debug != null && Debug.isOn("packet")) {
    318380            try {
    319381                HexDumpEncoder hd = new HexDumpEncoder();
    320                 ByteBuffer bb = ByteBuffer.wrap(buf, off, len);
     382                ByteBuffer bb = ByteBuffer.wrap(
     383                        buf, off + debugOffset, len - debugOffset);
    321384
    322385                System.out.println("[Raw write]: length = " +
  • trunk/openjdk/jdk/src/share/classes/sun/security/ssl/RSAClientKeyExchange.java

    r278 r406  
    11/*
    2  * Copyright (c) 1996, 2007, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    3737
    3838import sun.security.internal.spec.TlsRsaPremasterSecretParameterSpec;
     39import sun.security.util.KeyLength;
    3940
    4041/**
     
    8687     * server's public key, and uses PKCS #1 block format 02.
    8788     */
    88     RSAClientKeyExchange(ProtocolVersion protocolVersion, ProtocolVersion maxVersion,
     89    RSAClientKeyExchange(ProtocolVersion protocolVersion,
     90            ProtocolVersion maxVersion,
    8991            SecureRandom generator, PublicKey publicKey) throws IOException {
    9092        if (publicKey.getAlgorithm().equals("RSA") == false) {
     
    121123     * it with its private key.
    122124     */
    123     RSAClientKeyExchange(ProtocolVersion currentVersion, HandshakeInStream input,
     125    RSAClientKeyExchange(ProtocolVersion currentVersion,
     126            ProtocolVersion maxVersion, HandshakeInStream input,
    124127            int messageSize, PrivateKey privateKey) throws IOException {
    125128
     
    144147            preMaster = (SecretKey)cipher.unwrap(encrypted,
    145148                                "TlsRsaPremasterSecret", Cipher.SECRET_KEY);
     149
     150            // polish the premaster secret
     151            preMaster = polishPreMasterSecretKey(
     152                                currentVersion, maxVersion, preMaster, null);
    146153        } 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);
    161244            }
    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);
    164254    }
    165255
    166256    // generate a premaster secret with the specified version number
    167257    static SecretKey generateDummySecret(ProtocolVersion version) {
     258        if (debug != null && Debug.isOn("handshake")) {
     259            System.out.println("Generating a random fake premaster secret");
     260        }
     261
    168262        try {
    169263            KeyGenerator kg =
  • trunk/openjdk/jdk/src/share/classes/sun/security/ssl/SSLSocketImpl.java

    r309 r406  
    11/*
    2  * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    364364    private boolean isFirstAppOutputRecord = true;
    365365
     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
    366372    //
    367373    // CONSTRUCTORS AND INITIALIZATION CODE
     
    629635
    630636    /*
     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    /*
    631648     * Record Output. Application data can't be sent until the first
    632649     * handshake establishes a session.
     
    635652     * TCP-level activity, notably handshaking, to occur.
    636653     */
    637     void writeRecord(OutputRecord r) throws IOException {
     654    void writeRecord(OutputRecord r, boolean holdRecord) throws IOException {
    638655        /*
    639656         * The loop is in case of HANDSHAKE --> ERROR transitions, etc
     
    706723                    if (writeLock.tryLock(getSoLinger(), TimeUnit.SECONDS)) {
    707724                        try {
    708                             writeRecordInternal(r);
     725                            writeRecordInternal(r, holdRecord);
    709726                        } finally {
    710727                            writeLock.unlock();
     
    754771                writeLock.lock();
    755772                try {
    756                     writeRecordInternal(r);
     773                    writeRecordInternal(r, holdRecord);
    757774                } finally {
    758775                    writeLock.unlock();
     
    762779    }
    763780
    764     private void writeRecordInternal(OutputRecord r) throws IOException {
     781    private void writeRecordInternal(OutputRecord r,
     782            boolean holdRecord) throws IOException {
    765783        // r.compress(c);
    766784        r.addMAC(writeMAC);
    767785        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);
    769802
    770803        // turn off the flag of the first application record
  • trunk/openjdk/jdk/src/share/classes/sun/security/ssl/ServerHandshaker.java

    r278 r406  
    11/*
    2  * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    191191                     * certificates/keys.
    192192                     */
    193                     RSAClientKeyExchange pms = new RSAClientKeyExchange
    194                         (protocolVersion, input, message_len, privateKey);
     193                    RSAClientKeyExchange pms = new RSAClientKeyExchange(
     194                            protocolVersion, clientRequestedVersion,
     195                            input, message_len, privateKey);
    195196                    preMasterSecret = this.clientKeyExchange(pms);
    196197                    break;
  • trunk/openjdk/jdk/src/share/classes/sun/security/x509/CRLExtensions.java

    r278 r406  
    3333import java.security.cert.CertificateException;
    3434import java.util.Collection;
     35import java.util.Collections;
    3536import java.util.Enumeration;
    36 import java.util.Hashtable;
     37import java.util.Map;
     38import java.util.TreeMap;
    3739
    3840import sun.security.util.*;
     
    6365public class CRLExtensions {
    6466
    65     private Hashtable<String,Extension> map = new Hashtable<String,Extension>();
     67    private Map<String,Extension> map = Collections.synchronizedMap(
     68            new TreeMap<String,Extension>());
    6669    private boolean unsupportedCritExt = false;
    6770
     
    216219     */
    217220    public Enumeration<Extension> getElements() {
    218         return map.elements();
     221        return Collections.enumeration(map.values());
    219222    }
    220223
  • trunk/openjdk/jdk/src/share/classes/sun/security/x509/CertificateExtensions.java

    r278 r406  
    5858    private static final Debug debug = Debug.getInstance("x509");
    5959
    60     private Hashtable<String,Extension> map = new Hashtable<String,Extension>();
     60    private Map<String,Extension> map = Collections.synchronizedMap(
     61            new TreeMap<String,Extension>());
    6162    private boolean unsupportedCritExt = false;
    6263
     
    118119                // ignore errors parsing non-critical extensions
    119120                if (unparseableExtensions == null) {
    120                     unparseableExtensions = new HashMap<String,Extension>();
     121                    unparseableExtensions = new TreeMap<String,Extension>();
    121122                }
    122123                unparseableExtensions.put(ext.getExtensionId().toString(),
     
    219220    }
    220221
     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
    221228    /**
    222229     * Delete the attribute value.
     
    237244     */
    238245    public Enumeration<Extension> getElements() {
    239         return map.elements();
     246        return Collections.enumeration(map.values());
    240247    }
    241248
  • trunk/openjdk/jdk/src/share/classes/sun/security/x509/X509CRLEntryImpl.java

    r278 r406  
    3232import java.security.cert.X509CRLEntry;
    3333import 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;
     34import java.util.*;
    3935
    4036import javax.security.auth.x500.X500Principal;
     
    7369 */
    7470
    75 public class X509CRLEntryImpl extends X509CRLEntry {
     71public class X509CRLEntryImpl extends X509CRLEntry
     72        implements Comparable<X509CRLEntryImpl> {
    7673
    7774    private SerialNumber serialNumber = null;
     
    194191     */
    195192    public byte[] getEncoded() throws CRLException {
     193        return getEncoded0().clone();
     194    }
     195
     196    // Called internally to avoid clone
     197    private byte[] getEncoded0() throws CRLException {
    196198        if (revokedCert == null)
    197199            this.encode(new DerOutputStream());
    198         return revokedCert.clone();
     200        return revokedCert;
    199201    }
    200202
     
    314316            return null;
    315317        }
    316         Set<String> extSet = new HashSet<String>();
     318        Set<String> extSet = new TreeSet<String>();
    317319        for (Extension ex : extensions.getAllExtensions()) {
    318320            if (ex.isCritical()) {
     
    335337            return null;
    336338        }
    337         Set<String> extSet = new HashSet<String>();
     339        Set<String> extSet = new TreeSet<String>();
    338340        for (Extension ex : extensions.getAllExtensions()) {
    339341            if (!ex.isCritical()) {
     
    462464            getExtension(PKIXExtensions.CertificateIssuer_Id);
    463465    }
     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    }
    464485}
  • trunk/openjdk/jdk/src/share/classes/sun/security/x509/X509CRLImpl.java

    r278 r406  
    5454/**
    5555 * <p>
    56  * An implmentation for X509 CRL (Certificate Revocation List).
     56 * An implementation for X509 CRL (Certificate Revocation List).
    5757 * <p>
    5858 * The X.509 v2 CRL format is described below in ASN.1:
     
    105105    private Date             thisUpdate = null;
    106106    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>();
    108110    private CRLExtensions    extensions = null;
    109111    private final static boolean isExplicit = true;
     
    224226                X509IssuerSerial issuerSerial = new X509IssuerSerial
    225227                    (badCertIssuer, badCert.getSerialNumber());
    226                 this.revokedCerts.put(issuerSerial, badCert);
     228                this.revokedMap.put(issuerSerial, badCert);
     229                this.revokedList.add(badCert);
    227230                if (badCert.hasExtensions()) {
    228231                    this.version = 1;
     
    306309            }
    307310
    308             if (!revokedCerts.isEmpty()) {
    309                 for (X509CRLEntry entry : revokedCerts.values()) {
     311            if (!revokedList.isEmpty()) {
     312                for (X509CRLEntry entry : revokedList) {
    310313                    ((X509CRLEntryImpl)entry).encode(rCerts);
    311314                }
     
    491494        if (nextUpdate != null)
    492495            sb.append("Next Update: " + nextUpdate.toString() + "\n");
    493         if (revokedCerts.isEmpty())
     496        if (revokedList.isEmpty())
    494497            sb.append("\nNO certificates have been revoked\n");
    495498        else {
    496             sb.append("\nRevoked Certificates: " + revokedCerts.size());
     499            sb.append("\nRevoked Certificates: " + revokedList.size());
    497500            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            }
    501504        }
    502505        if (extensions != null) {
     
    544547     */
    545548    public boolean isRevoked(Certificate cert) {
    546         if (revokedCerts.isEmpty() || (!(cert instanceof X509Certificate))) {
     549        if (revokedMap.isEmpty() || (!(cert instanceof X509Certificate))) {
    547550            return false;
    548551        }
    549552        X509Certificate xcert = (X509Certificate) cert;
    550553        X509IssuerSerial issuerSerial = new X509IssuerSerial(xcert);
    551         return revokedCerts.containsKey(issuerSerial);
     554        return revokedMap.containsKey(issuerSerial);
    552555    }
    553556
     
    639642     */
    640643    public X509CRLEntry getRevokedCertificate(BigInteger serialNumber) {
    641         if (revokedCerts.isEmpty()) {
     644        if (revokedMap.isEmpty()) {
    642645            return null;
    643646        }
     
    645648        X509IssuerSerial issuerSerial = new X509IssuerSerial
    646649            (getIssuerX500Principal(), serialNumber);
    647         return revokedCerts.get(issuerSerial);
     650        return revokedMap.get(issuerSerial);
    648651    }
    649652
     
    652655     */
    653656    public X509CRLEntry getRevokedCertificate(X509Certificate cert) {
    654         if (revokedCerts.isEmpty()) {
     657        if (revokedMap.isEmpty()) {
    655658            return null;
    656659        }
    657660        X509IssuerSerial issuerSerial = new X509IssuerSerial(cert);
    658         return revokedCerts.get(issuerSerial);
     661        return revokedMap.get(issuerSerial);
    659662    }
    660663
     
    668671     */
    669672    public Set<X509CRLEntry> getRevokedCertificates() {
    670         if (revokedCerts.isEmpty()) {
     673        if (revokedList.isEmpty()) {
    671674            return null;
    672675        } else {
    673             return new HashSet<X509CRLEntry>(revokedCerts.values());
     676            return new TreeSet<X509CRLEntry>(revokedList);
    674677        }
    675678    }
     
    897900            return null;
    898901        }
    899         Set<String> extSet = new HashSet<String>();
     902        Set<String> extSet = new TreeSet<String>();
    900903        for (Extension ex : extensions.getAllExtensions()) {
    901904            if (ex.isCritical()) {
     
    918921            return null;
    919922        }
    920         Set<String> extSet = new HashSet<String>();
     923        Set<String> extSet = new TreeSet<String>();
    921924        for (Extension ex : extensions.getAllExtensions()) {
    922925            if (!ex.isCritical()) {
     
    10951098                X509IssuerSerial issuerSerial = new X509IssuerSerial
    10961099                    (badCertIssuer, entry.getSerialNumber());
    1097                 revokedCerts.put(issuerSerial, entry);
     1100                revokedMap.put(issuerSerial, entry);
     1101                revokedList.add(entry);
    10981102            }
    10991103        }
     
    11931197     * Immutable X.509 Certificate Issuer DN and serial number pair
    11941198     */
    1195     private final static class X509IssuerSerial {
     1199    private final static class X509IssuerSerial
     1200            implements Comparable<X509IssuerSerial> {
    11961201        final X500Principal issuer;
    11971202        final BigInteger serial;
     
    12721277            return hashcode;
    12731278        }
     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        }
    12741287    }
    12751288}
  • trunk/openjdk/jdk/src/share/classes/sun/security/x509/X509CertImpl.java

    r278 r406  
    12151215                return null;
    12161216            }
    1217             Set<String> extSet = new HashSet<String>();
     1217            Set<String> extSet = new TreeSet<String>();
    12181218            for (Extension ex : exts.getAllExtensions()) {
    12191219                if (ex.isCritical()) {
     
    12451245                return null;
    12461246            }
    1247             Set<String> extSet = new HashSet<String>();
     1247            Set<String> extSet = new TreeSet<String>();
    12481248            for (Extension ex : exts.getAllExtensions()) {
    12491249                if (!ex.isCritical()) {
     
    12791279                return null;
    12801280            } 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)) {
    12831287                        //XXXX May want to consider cloning this
    1284                         return ex;
     1288                        return ex2;
    12851289                    }
    12861290                }
     
    14811485            return Collections.<List<?>>emptySet();
    14821486        }
    1483         Set<List<?>> newNames = new HashSet<List<?>>();
     1487        List<List<?>> newNames = new ArrayList<List<?>>();
    14841488        for (GeneralName gname : names.names()) {
    14851489            GeneralNameInterface name = gname.getName();
     
    15421546        }
    15431547        if (mustClone) {
    1544             Set<List<?>> namesCopy = new HashSet<List<?>>();
     1548            List<List<?>> namesCopy = new ArrayList<List<?>>();
    15451549            for (List<?> nameEntry : altNames) {
    15461550                Object nameObject = nameEntry.get(1);
  • trunk/openjdk/jdk/src/share/classes/sun/tools/jar/Main.java

    r278 r406  
    11/*
    2  * Copyright (c) 1996, 2007, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    128128    /**
    129129     * 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.
    131131     */
    132132    private static File createTempFileInSameDirectoryAs(File file)
  • trunk/openjdk/jdk/src/share/classes/sun/tools/native2ascii/Main.java

    r278 r406  
    11/*
    2  * Copyright (c) 1996, 2007, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    238238                tempDir = new File(System.getProperty("user.dir"));
    239239
    240             tempFile = File.createTempFile("_N2A",
    241                                            ".TMP",
    242                                             tempDir);
     240            tempFile = File.createTempFile("_N2A", ".TMP", tempDir);
    243241            tempFile.deleteOnExit();
    244242
  • trunk/openjdk/jdk/src/share/demo/jvmti/compiledMethodLoad/sample.makefile.txt

    r278 r406  
    9191    # Library name and options needed to build it
    9292    LIBRARY=lib$(LIBNAME).so
    93     LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc -mimpure-text
     93    LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc
    9494    # Libraries we are dependent on
    9595    LIBRARIES=-lc
  • trunk/openjdk/jdk/src/share/demo/jvmti/gctest/sample.makefile.txt

    r278 r406  
    9191    # Library name and options needed to build it
    9292    LIBRARY=lib$(LIBNAME).so
    93     LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc -mimpure-text
     93    LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc
    9494    # Libraries we are dependent on
    9595    LIBRARIES=-lc
  • trunk/openjdk/jdk/src/share/demo/jvmti/heapTracker/sample.makefile.txt

    r278 r406  
    9595    # Library name and options needed to build it
    9696    LIBRARY=lib$(LIBNAME).so
    97     LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc -mimpure-text
     97    LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc
    9898    # Libraries we are dependent on
    9999    LIBRARIES=-L $(JDK)/jre/lib/$(LIBARCH) -ljava_crw_demo -lc
  • trunk/openjdk/jdk/src/share/demo/jvmti/heapViewer/sample.makefile.txt

    r278 r406  
    9191    # Library name and options needed to build it
    9292    LIBRARY=lib$(LIBNAME).so
    93     LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc -mimpure-text
     93    LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc
    9494    # Libraries we are dependent on
    9595    LIBRARIES=-lc
  • trunk/openjdk/jdk/src/share/demo/jvmti/hprof/sample.makefile.txt

    r278 r406  
    131131    # Library name and options needed to build it
    132132    LIBRARY=lib$(LIBNAME).so
    133     LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc -mimpure-text
     133    LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc
    134134    # Libraries we are dependent on
    135135    LIBRARIES= -lnsl -ldl -lc
  • trunk/openjdk/jdk/src/share/demo/jvmti/index.html

    r2 r406  
    309309gcc -O2 -fPIC -pthread -DLINUX -c <i>*.c</i>
    310310<br>
    311 gcc -z defs -static-libgcc -shared -mimpure-text -o <i>libXXX.so *.o</i> -lc
     311gcc -z defs -static-libgcc -shared -o <i>libXXX.so *.o</i> -lc
    312312</code></ul>
    313313<br>
     
    317317gcc -O2 -fPIC -pthread -DLINUX -D_LP64=1 -c <i>*.c</i>
    318318<br>
    319 gcc -z defs -static-libgcc -shared -mimpure-text -o <i>libXXX.so *.o</i> -lc
     319gcc -z defs -static-libgcc -shared -o <i>libXXX.so *.o</i> -lc
    320320</code></ul>
    321321<br>
     
    340340
    341341<li>
    342 Library: Use -static-libgcc -mimpure-text.
     342Library: Use -static-libgcc.
    343343<br>
    344344When building the shared library (-shared option), this option
  • trunk/openjdk/jdk/src/share/demo/jvmti/java_crw_demo/sample.makefile.txt

    r278 r406  
    9191    # Library name and options needed to build it
    9292    LIBRARY=lib$(LIBNAME).so
    93     LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc -mimpure-text
     93    LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc
    9494    # Libraries we are dependent on
    9595    LIBRARIES=-lc
  • trunk/openjdk/jdk/src/share/demo/jvmti/minst/sample.makefile.txt

    r278 r406  
    9595    # Library name and options needed to build it
    9696    LIBRARY=lib$(LIBNAME).so
    97     LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc -mimpure-text
     97    LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc
    9898    # Libraries we are dependent on
    9999    LIBRARIES=-L $(JDK)/jre/lib/$(LIBARCH) -ljava_crw_demo -lc
  • trunk/openjdk/jdk/src/share/demo/jvmti/mtrace/sample.makefile.txt

    r278 r406  
    9595    # Library name and options needed to build it
    9696    LIBRARY=lib$(LIBNAME).so
    97     LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc -mimpure-text
     97    LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc
    9898    # Libraries we are dependent on
    9999    LIBRARIES=-L $(JDK)/jre/lib/$(LIBARCH) -ljava_crw_demo -lc
  • trunk/openjdk/jdk/src/share/demo/jvmti/versionCheck/sample.makefile.txt

    r278 r406  
    9191    # Library name and options needed to build it
    9292    LIBRARY=lib$(LIBNAME).so
    93     LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc -mimpure-text
     93    LDFLAGS=-Wl,-soname=$(LIBRARY) -static-libgcc
    9494    # Libraries we are dependent on
    9595    LIBRARIES=-lc
  • trunk/openjdk/jdk/src/share/lib/security/java.security

    r2 r406  
    137137# been granted.
    138138#
    139 # by default, no packages are restricted for definition, and none of
    140 # the class loaders supplied with the JDK call checkPackageDefinition.
    141 #
    142 #package.definition=
     139# by default, none of the class loaders supplied with the JDK call
     140# checkPackageDefinition.
     141#
     142package.definition=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.
    143143
    144144#
  • trunk/openjdk/jdk/src/share/lib/security/java.security-solaris

    r2 r406  
    138138# been granted.
    139139#
    140 # by default, no packages are restricted for definition, and none of
    141 # the class loaders supplied with the JDK call checkPackageDefinition.
    142 #
    143 #package.definition=
     140# by default, none of the class loaders supplied with the JDK call
     141# checkPackageDefinition.
     142#
     143package.definition=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.
    144144
    145145#
  • trunk/openjdk/jdk/src/share/lib/security/java.security-windows

    r2 r406  
    138138# been granted.
    139139#
    140 # by default, no packages are restricted for definition, and none of
    141 # the class loaders supplied with the JDK call checkPackageDefinition.
    142 #
    143 #package.definition=
     140# by default, none of the class loaders supplied with the JDK call
     141# checkPackageDefinition.
     142#
     143package.definition=sun.,com.sun.xml.internal.ws.,com.sun.xml.internal.bind.,com.sun.imageio.
    144144
    145145#
  • trunk/openjdk/jdk/src/share/native/java/net/net_util.c

    r278 r406  
    11/*
    2  * Copyright (c) 1998, 2005, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    6969    IPv6_available = IPv6_supported() & (!preferIPv4Stack);
    7070    initLocalAddrTable ();
     71    parseExclusiveBindProperty(env);
     72
    7173    return JNI_VERSION_1_2;
    7274}
  • trunk/openjdk/jdk/src/share/native/java/net/net_util.h

    r278 r406  
    11/*
    2  * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    121121
    122122void initLocalAddrTable ();
     123void parseExclusiveBindProperty(JNIEnv *env);
    123124
    124125void
  • trunk/openjdk/jdk/src/share/native/sun/font/layout/LookupProcessor.cpp

    r278 r406  
    8787        if (selectMask != 0) {
    8888            const LookupTable *lookupTable = lookupListTable->getLookupTable(lookup);
     89
     90            if (!lookupTable)
     91                continue;
     92
    8993            le_uint16 lookupFlags = SWAPW(lookupTable->lookupFlags);
    9094
     
    125129        le_uint16 lookupListIndex = SWAPW(featureTable->lookupListIndexArray[lookup]);
    126130
     131        if (lookupListIndex >= lookupSelectCount)
     132            continue;
     133
    127134        lookupSelectArray[lookupListIndex] |= featureMask;
    128135        lookupOrderArray[store++] = lookupListIndex;
     
    136143        LETag scriptTag, LETag languageTag, const FeatureMap *featureMap,
    137144        le_int32 featureMapCount, le_bool orderFeatures)
    138     : lookupListTable(NULL), featureListTable(NULL), lookupSelectArray(NULL),
     145    : lookupListTable(NULL), featureListTable(NULL), lookupSelectArray(NULL), lookupSelectCount(0),
    139146      lookupOrderArray(NULL), lookupOrderCount(0)
    140147{
     
    175182        lookupSelectArray[i] = 0;
    176183    }
     184
     185    lookupSelectCount = lookupListCount;
    177186
    178187    le_int32 count, order = 0;
     
    192201
    193202        featureTable = featureListTable->getFeatureTable(featureIndex, &featureTag);
     203
     204        if (!featureTable)
     205            continue;
     206
    194207        featureReferences += SWAPW(featureTable->lookupCount);
    195208    }
  • trunk/openjdk/jdk/src/share/native/sun/font/layout/LookupProcessor.h

    r278 r406  
    7878
    7979    FeatureMask             *lookupSelectArray;
     80    le_uint32               lookupSelectCount;
    8081
    8182    le_uint16               *lookupOrderArray;
  • trunk/openjdk/jdk/src/solaris/classes/java/io/UnixFileSystem.java

    r278 r406  
    11/*
    2  * Copyright (c) 1998, 2005, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    254254    /* -- File operations -- */
    255255
    256     public native boolean createFileExclusively(String path)
     256    public native boolean createFileExclusively(String path, boolean restrictive)
    257257        throws IOException;
    258258    public boolean delete(File f) {
  • trunk/openjdk/jdk/src/solaris/classes/sun/awt/X11/XCheckboxMenuItemPeer.java

    r278 r406  
    3030import java.awt.event.*;
    3131
    32 import java.lang.reflect.Field;
    33 import sun.awt.SunToolkit;
     32import sun.awt.AWTAccessor;
    3433
    3534class XCheckboxMenuItemPeer extends XMenuItemPeer implements CheckboxMenuItemPeer {
    36 
    37     /************************************************
    38      *
    39      * Data members
    40      *
    41      ************************************************/
    42 
    43     /*
    44      * CheckboxMenuItem's fields
    45      */
    46     private final static Field f_state;
    47     static {
    48         f_state = SunToolkit.getField(CheckboxMenuItem.class, "state");
    49     }
    5035
    5136    /************************************************
     
    7560     ************************************************/
    7661    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());
    8764    }
    8865
  • trunk/openjdk/jdk/src/solaris/classes/sun/awt/X11/XComponentPeer.java

    r278 r406  
    3232import java.awt.Container;
    3333import java.awt.Cursor;
    34 import java.awt.DefaultKeyboardFocusManager;
    3534import java.awt.Dimension;
    36 import java.awt.Event;
    3735import java.awt.Font;
    3836import java.awt.FontMetrics;
     
    4139import java.awt.Insets;
    4240import java.awt.KeyboardFocusManager;
    43 import java.awt.MenuBar;
    44 import java.awt.Point;
    4541import java.awt.Rectangle;
    4642import java.awt.SystemColor;
     
    6157import java.awt.image.ImageProducer;
    6258import java.awt.image.VolatileImage;
    63 import java.awt.peer.CanvasPeer;
    6459import java.awt.peer.ComponentPeer;
    6560import java.awt.peer.ContainerPeer;
    6661import java.awt.peer.LightweightPeer;
    67 import java.awt.peer.PanelPeer;
    68 import java.awt.peer.WindowPeer;
    6962import java.lang.reflect.*;
    7063import java.security.*;
     
    398391    }
    399392
    400     static Method requestFocusWithCause;
    401 
    402393    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);
    413395    }
    414396
  • trunk/openjdk/jdk/src/solaris/classes/sun/awt/X11/XEmbedCanvasPeer.java

    r278 r406  
    3030import java.awt.dnd.DropTargetListener;
    3131import 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.*;
    3732import sun.awt.*;
    38 import sun.awt.motif.X11FontMetrics;
    39 import java.lang.reflect.*;
    4033import java.util.logging.*;
    4134import java.util.*;
     
    456449    }
    457450
    458     static Field bdataField;
    459451    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);
    468453    }
    469454
  • trunk/openjdk/jdk/src/solaris/classes/sun/awt/X11/XEmbeddingContainer.java

    r278 r406  
    2929import java.util.HashMap;
    3030import java.awt.event.KeyEvent;
    31 import java.lang.reflect.*;
    32 import sun.awt.SunToolkit;
     31import sun.awt.AWTAccessor;
    3332
    3433public class XEmbeddingContainer extends XEmbedHelper implements XEventDispatcher {
     
    128127    }
    129128
    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 
    142129    void forwardKeyEvent(long child, KeyEvent e) {
    143         byte[] bdata = getBData(e);
     130        byte[] bdata = AWTAccessor.getAWTEventAccessor().getBData(e);
    144131        long data = Native.toData(bdata);
    145132        if (data == 0) {
  • trunk/openjdk/jdk/src/solaris/classes/sun/awt/X11/XGlobalCursorManager.java

    r278 r406  
    3030import java.awt.peer.LightweightPeer;
    3131import java.lang.ref.WeakReference;
    32 import java.lang.reflect.Field;
    33 import java.lang.reflect.Method;
    3432import sun.awt.ComponentAccessor;
    3533
    3634import sun.awt.GlobalCursorManager;
    37 import sun.awt.SunToolkit;
     35import sun.awt.AWTAccessor;
    3836
    3937public 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 
    5738
    5839    // cached nativeContainer
     
    217198        int type = 0;
    218199        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);
    221202        }
    222203        catch (Exception e)
     
    288269    static void setPData(Cursor c, long pData) {
    289270        try {
    290             method_setPData.invoke(c, pData);
     271            AWTAccessor.getCursorAccessor().setPData(c, pData);
    291272        }
    292273        catch (Exception e)
  • trunk/openjdk/jdk/src/solaris/classes/sun/awt/X11/XKeyboardFocusManagerPeer.java

    r278 r406  
    3333import java.awt.peer.KeyboardFocusManagerPeer;
    3434
    35 import java.lang.reflect.InvocationTargetException;
    36 import java.lang.reflect.Method;
    37 
    3835import java.util.logging.Level;
    3936import java.util.logging.Logger;
    4037
    4138import sun.awt.CausedFocusEvent;
    42 import sun.awt.SunToolkit;
     39import sun.awt.AWTAccessor;
    4340
    4441public class XKeyboardFocusManagerPeer implements KeyboardFocusManagerPeer {
     
    131128    }
    132129
    133     static Method shouldNativelyFocusHeavyweightMethod;
    134 
    135130    static int shouldNativelyFocusHeavyweight(Component heavyweight,
    136131         Component descendant, boolean temporary,
    137132         boolean focusedWindowChangeAllowed, long time, CausedFocusEvent.Cause cause)
    138133    {
    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);
    174141    }
    175142}
  • trunk/openjdk/jdk/src/solaris/classes/sun/awt/X11/XMenuBarPeer.java

    r278 r406  
    2929import java.awt.event.*;
    3030
    31 import java.lang.reflect.Field;
    3231import java.util.Vector;
    3332import java.util.logging.*;
    34 import sun.awt.SunToolkit;
     33import sun.awt.AWTAccessor;
    3534
    3635public class XMenuBarPeer extends XBaseMenuWindow implements MenuBarPeer {
     
    6766    private final static int BAR_ITEM_MARGIN_TOP = 2;
    6867    private final static int BAR_ITEM_MARGIN_BOTTOM = 2;
    69 
    70     //fields
    71     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     }
    7868
    7969    /************************************************
     
    205195    void postInit(XCreateWindowParams params) {
    206196        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);
    220203        xSetVisible(true);
    221204        toFront();
  • trunk/openjdk/jdk/src/solaris/classes/sun/awt/X11/XMenuItemPeer.java

    r278 r406  
    2929import java.awt.event.*;
    3030
    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;
     31import sun.awt.AWTAccessor;
    3732
    3833public class XMenuItemPeer implements MenuItemPeer {
     
    8479    private final static int SEPARATOR_HEIGHT = 5;
    8580
    86     /*
    87      * MenuItem's fields & methods
    88      */
    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     }
    10481    /************************************************
    10582     *
     
    219196            return XWindow.defaultFont;
    220197        }
    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);
    229199    }
    230200
     
    233203            return "";
    234204        }
    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;
    242207    }
    243208
     
    246211            return false;
    247212        }
    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);
    254214    }
    255215
     
    263223            return false;
    264224        }
    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);
    273226    }
    274227
     
    277230            return "";
    278231        }
    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);
    287233    }
    288234
     
    291237            return null;
    292238        }
    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);
    299240    }
    300241
  • trunk/openjdk/jdk/src/solaris/classes/sun/awt/X11/XMenuPeer.java

    r278 r406  
    2828import java.awt.peer.*;
    2929
    30 import java.lang.reflect.Field;
    3130import java.util.Vector;
    3231import java.util.logging.*;
    33 import sun.awt.SunToolkit;
     32import sun.awt.AWTAccessor;
    3433
    3534public class XMenuPeer extends XMenuItemPeer implements MenuPeer {
     
    4645     */
    4746    XMenuWindow menuWindow;
    48 
    49 
    50     /*
    51      * Menu's fields & methods
    52      */
    53     private final static Field f_items;
    54 
    55     static {
    56         f_items = SunToolkit.getField(Menu.class, "items");
    57     }
    5847
    5948    /************************************************
     
    154143     ************************************************/
    155144    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());
    162146    }
    163147
  • trunk/openjdk/jdk/src/solaris/classes/sun/awt/X11/XPopupMenuPeer.java

    r278 r406  
    2929import java.awt.event.*;
    3030
    31 import java.lang.reflect.Field;
    32 import java.lang.reflect.Method;
    33 import java.lang.reflect.InvocationTargetException;
    34 
    3531import java.util.Vector;
     32import sun.awt.AWTAccessor;
    3633import java.util.logging.*;
    37 
    38 import sun.awt.SunToolkit;
    3934
    4035public class XPopupMenuPeer extends XMenuWindow implements PopupMenuPeer {
     
    6661    private final static int CAPTION_MARGIN_TOP = 4;
    6762    private final static int CAPTION_SEPARATOR_HEIGHT = 6;
    68 
    69     /*
    70      * Menu's fields & methods
    71      */
    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, XToolkit
    75     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 
    8663
    8764    /************************************************
     
    190167            return XWindow.defaultFont;
    191168        }
    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
    202174    String getTargetLabel() {
    203175        if (target == null) {
    204176            return "";
    205177        }
    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);
    213179    }
    214180
     
    218184            return false;
    219185        }
    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);
    226187    }
    227188
    228189    Vector getMenuTargetItems() {
    229         try {
    230             return (Vector)f_items.get(popupMenuTarget);
    231         } catch (IllegalAccessException iae) {
    232             iae.printStackTrace();
     190        if (popupMenuTarget == null) {
    233191            return null;
    234192        }
     193        return AWTAccessor.getMenuAccessor().getItems(popupMenuTarget);
    235194    }
    236195
  • trunk/openjdk/jdk/src/solaris/classes/sun/awt/X11/XScrollPanePeer.java

    r278 r406  
    2929import java.awt.event.*;
    3030import java.awt.peer.*;
    31 import java.lang.reflect.*;
    32 import sun.awt.SunToolkit;
     31
     32import sun.awt.AWTAccessor;
    3333
    3434class XScrollPanePeer extends XComponentPeer implements ScrollPanePeer, XScrollbarClient {
     
    4242    public final static int     HORIZONTAL = 1 << 1;
    4343
    44     private static Method m_setValue;
    4544    static {
    46         m_setValue = SunToolkit.getMethod(ScrollPaneAdjustable.class, "setTypedValue", new Class[] {Integer.TYPE, Integer.TYPE});
    4745        SCROLLBAR = XToolkit.getUIDefaults().getInt("ScrollBar.defaultWidth");
    4846    }
     
    317315
    318316    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);
    329319    }
    330320
  • trunk/openjdk/jdk/src/solaris/classes/sun/awt/X11/XTextAreaPeer.java

    r278 r406  
    6262import sun.awt.CausedFocusEvent;
    6363import sun.awt.ComponentAccessor;
     64import sun.awt.AWTAccessor;
    6465
    6566
     
    986987        public void setTransferHandler(TransferHandler newHandler) {
    987988            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(),
    990993                              newHandler);
    991994
  • trunk/openjdk/jdk/src/solaris/classes/sun/awt/X11/XTextFieldPeer.java

    r278 r406  
    5656import sun.awt.CausedFocusEvent;
    5757import sun.awt.ComponentAccessor;
     58import sun.awt.AWTAccessor;
    5859
    5960public class XTextFieldPeer extends XComponentPeer implements TextFieldPeer {
     
    715716        public void setTransferHandler(TransferHandler newHandler) {
    716717            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(),
    719722                              newHandler);
    720723
  • trunk/openjdk/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java

    r278 r406  
    5050import sun.print.PrintJob2D;
    5151import sun.security.action.GetBooleanAction;
    52 import java.lang.reflect.*;
     52import sun.security.action.GetPropertyAction;
    5353
    5454public class XToolkit extends UNIXToolkit implements Runnable, XConstants {
     
    103103    static long awt_defaultFg; // Pixel
    104104    private static XMouseInfoPeer xPeer;
    105     private static Method m_removeSourceEvents;
    106105
    107106    static {
     
    121120            setBackingStoreType();
    122121        }
    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"));
    126125    }
    127126
     
    204203    static void initSecurityWarning() {
    205204        // Enable warning only for internal builds
    206         String runtime = getSystemProperty("java.runtime.version");
     205        String runtime = AccessController.doPrivileged(
     206                new GetPropertyAction("java.runtime.version"));
    207207        securityWarningEnabled = (runtime != null && runtime.contains("internal"));
    208208    }
     
    11251125            awtUnlock();
    11261126        }
    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             });
    11351127    }
    11361128
     
    18951887
    18961888    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);
    19071890    }
    19081891
     
    19381921
    19391922    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"));
    19421925
    19431926        if (prop == null) {
  • trunk/openjdk/jdk/src/solaris/classes/sun/awt/X11/XWindow.java

    r278 r406  
    3434
    3535import java.lang.reflect.Field;
    36 import java.lang.reflect.Method;
    3736
    3837import java.util.logging.Level;
     
    109108    private native static void initIDs();
    110109
    111     private static Field isPostedField;
    112110    static {
    113111        initIDs();
     
    362360    }
    363361
    364     static Method m_sendMessage;
    365362    static void sendEvent(final AWTEvent e) {
    366         if (isPostedField == null) {
    367             isPostedField = SunToolkit.getField(AWTEvent.class, "isPosted");
    368         }
    369363        PeerEvent pe = new PeerEvent(Toolkit.getDefaultToolkit(), new Runnable() {
    370364                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);
    378366                    ((Component)e.getSource()).dispatchEvent(e);
    379367                }
     
    12511239
    12521240
    1253     static Field bdata;
    12541241    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);
    12631243    }
    12641244
  • trunk/openjdk/jdk/src/solaris/classes/sun/awt/X11/XlibWrapper.java

    r278 r406  
    2727
    2828import java.security.AccessController;
    29 import java.security.PrivilegedAction;
     29import sun.security.action.GetPropertyAction;
    3030import sun.misc.*;
    3131
     
    563563
    564564    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"));
    571566        try {
    572567            dataModel = Integer.parseInt(dataModelProp);
     
    611606
    612607    private static boolean getBuildInternal() {
    613         String javaVersion = XToolkit.getSystemProperty("java.version");
     608        String javaVersion = AccessController.doPrivileged(new GetPropertyAction("java.version"));
    614609        return javaVersion != null && javaVersion.contains("internal");
    615610    }
  • trunk/openjdk/jdk/src/solaris/classes/sun/awt/motif/MComponentPeer.java

    r278 r406  
    401401
    402402    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);
    413404    }
    414405
  • trunk/openjdk/jdk/src/solaris/classes/sun/print/UnixPrintJob.java

    r278 r406  
    11/*
    2  * Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    938938                     * removed when the VM exits.
    939939                     */
    940                     spoolFile = File.createTempFile("javaprint", ".ps", null);
     940                    spoolFile = sun.misc.IOUtils.createTempFile("javaprint", ".ps", null);
    941941                    spoolFile.deleteOnExit();
    942942                }
  • trunk/openjdk/jdk/src/solaris/classes/sun/print/UnixPrintServiceLookup.java

    r278 r406  
    11/*
    2  * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    713713                        Process proc;
    714714                        BufferedReader bufferedReader = null;
    715                         File f = File.createTempFile("prn","xc");
     715                        File f = sun.misc.IOUtils.createTempFile("prn","xc");
    716716                        cmd[2] = cmd[2]+">"+f.getAbsolutePath();
    717717
  • trunk/openjdk/jdk/src/solaris/native/java/io/UnixFileSystem_md.c

    r278 r406  
    11/*
    2  * Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    311311JNIEXPORT jboolean JNICALL
    312312Java_java_io_UnixFileSystem_createFileExclusively(JNIEnv *env, jclass cls,
    313                                                   jstring pathname)
     313                                                  jstring pathname,
     314                                                  jboolean restrictive)
    314315{
    315316    jboolean rv = JNI_FALSE;
     
    320321            fd = JVM_EEXIST;    /* The root directory always exists */
    321322        } 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);
    323325        }
    324326        if (fd < 0) {
  • trunk/openjdk/jdk/src/solaris/native/java/net/net_util_md.c

    r278 r406  
    11/*
    2  * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    6565
    6666/*
    67  * EXCLBIND socket options only on Solaris 8 & 9.
     67 * EXCLBIND socket options only on Solaris
    6868 */
    6969#if defined(__solaris__) && !defined(TCP_EXCLBIND)
     
    7878static int tcp_max_buf;
    7979static int udp_max_buf;
     80static int useExclBind = 0;
    8081
    8182/*
     
    646647
    647648#endif
     649
     650void 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}
    648669
    649670/* In the case of an IPv4 Inetaddress this method will return an
     
    12231244 * caught.
    12241245 *
    1225  * On Solaris 8/9 with IPv6 enabled we must use an exclusive
    1226  * bind to guaranteed a unique port number across the IPv4 and
     1246 * On Solaris with IPv6 enabled we must use an exclusive
     1247 * bind to guarantee a unique port number across the IPv4 and
    12271248 * IPv6 port spaces.
    12281249 *
     
    12541275#if defined(__solaris__) && defined(AF_INET6)
    12551276    /*
    1256      * Solaris 8/9 have seperate IPv4 and IPv6 port spaces so we
     1277     * Solaris has separate IPv4 and IPv6 port spaces so we
    12571278     * use an exclusive bind when SO_REUSEADDR is not used to
    12581279     * give the illusion of a unified port space.
    1259      * This also avoid problems with IPv6 sockets connecting
     1280     * This also avoids problems with IPv6 sockets connecting
    12601281     * to IPv4 mapped addresses whereby the socket conversion
    12611282     * results in a late bind that fails because the
     
    12661287
    12671288        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) {
    12711292                /*
    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
    12731295                 * UDP_EXCLBIND
    12741296                 */
  • trunk/openjdk/jdk/src/windows/classes/java/io/Win32FileSystem.java

    r278 r406  
    11/*
    2  * Copyright (c) 1998, 2005, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    511511    /* -- File operations -- */
    512512
    513     public native boolean createFileExclusively(String path)
     513    public native boolean createFileExclusively(String path, boolean restrictive)
    514514        throws IOException;
    515515    public boolean delete(File f) {
  • trunk/openjdk/jdk/src/windows/classes/java/io/WinNTFileSystem.java

    r278 r406  
    11/*
    2  * Copyright (c) 2001, 2006, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    6262    /* -- File operations -- */
    6363
    64     public native boolean createFileExclusively(String path)
     64    public native boolean createFileExclusively(String path, boolean restrictive)
    6565                                               throws IOException;
    6666    protected native boolean delete0(File f);
  • trunk/openjdk/jdk/src/windows/classes/sun/awt/windows/WPopupMenuPeer.java

    r278 r406  
    2727import java.awt.*;
    2828import java.awt.peer.*;
    29 import java.lang.reflect.Field;
    3029
    31 import sun.awt.SunToolkit;
     30import sun.awt.AWTAccessor;
    3231
    3332public class WPopupMenuPeer extends WMenuPeer implements PopupMenuPeer {
     
    3534    // because this method should return null for the TrayIcon
    3635    // 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     }
    4436
    4537    public WPopupMenuPeer(PopupMenu target) {
     
    4739        MenuContainer parent = null;
    4840        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();
    5946        }
    6047
  • trunk/openjdk/jdk/src/windows/native/java/io/Win32FileSystem_md.c

    r330 r406  
    11/*
    2  * Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    274274JNIEXPORT jboolean JNICALL
    275275Java_java_io_Win32FileSystem_createFileExclusively(JNIEnv *env, jclass cls,
    276                                                    jstring pathname)
     276                                                   jstring pathname,
     277                                                   jboolean restrictive)
    277278{
    278279    jboolean rv = JNI_FALSE;
  • trunk/openjdk/jdk/src/windows/native/java/io/WinNTFileSystem_md.c

    r330 r406  
    11/*
    2  * Copyright (c) 2001, 2006, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    366366JNIEXPORT jboolean JNICALL
    367367Java_java_io_WinNTFileSystem_createFileExclusively(JNIEnv *env, jclass cls,
    368                                                    jstring path)
     368                                                   jstring path,
     369                                                   jboolean restrictive)
    369370{
    370371    HANDLE h = NULL;
  • trunk/openjdk/jdk/src/windows/native/java/net/net_util_md.c

    r333 r406  
    11/*
    2  * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    133133
    134134void initLocalAddrTable () {}
     135void parseExclusiveBindProperty (JNIEnv *env) {}
    135136
    136137/*
  • trunk/openjdk/jdk/src/windows/native/sun/windows/awt_Dialog.cpp

    r309 r406  
    429429    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
    430430
    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));
    433437    if (windows == NULL) {
    434438        return;
  • trunk/openjdk/jdk/src/windows/native/sun/windows/awt_Window.cpp

    r309 r406  
    11/*
    2  * Copyright (c) 1996, 2007, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    125125jfieldID AwtWindow::locationByPlatformID;
    126126jfieldID AwtWindow::autoRequestFocusID;
    127 
    128 jclass AwtWindow::wwindowPeerCls;
    129 jmethodID AwtWindow::getActiveWindowsMID;
    130127
    131128jfieldID AwtWindow::sysXID;
     
    21692166    AwtWindow::sysHID = env->GetFieldID(cls, "sysH", "I");
    21702167
    2171     AwtWindow::wwindowPeerCls = cls;
    2172     AwtWindow::getActiveWindowsMID =
    2173         env->GetStaticMethodID(cls, "getActiveWindowHandles", "()[J");
    2174     DASSERT(AwtWindow::getActiveWindowsMID != NULL);
    2175 
    21762168    CATCH_BAD_ALLOC;
    21772169}
  • trunk/openjdk/jdk/src/windows/native/sun/windows/awt_Window.h

    r309 r406  
    5757    static jfieldID screenID; /* screen number passed over from WindowPeer */
    5858    static jfieldID autoRequestFocusID;
    59 
    60     /* WWindowPeer class */
    61     static jclass wwindowPeerCls;
    62     /* long[] getActiveWindowHandles() method in WWindowPeer */
    63     static jmethodID getActiveWindowsMID;
    6459
    6560    // The coordinates at the peer.
Note: See TracChangeset for help on using the changeset viewer.