Changeset 390 for trunk/openjdk/jdk/src


Ignore:
Timestamp:
Jul 2, 2012, 3:05:26 PM (13 years ago)
Author:
dmik
Message:

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

This accompanies an incomplete r389.

Location:
trunk/openjdk/jdk/src
Files:
54 edited
3 copied

Legend:

Unmodified
Added
Removed
  • trunk/openjdk/jdk/src/share/bin/java.c

    r341 r390  
    11/*
    2  * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
  • trunk/openjdk/jdk/src/share/bin/java.h

    r278 r390  
    11/*
    2  * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
  • trunk/openjdk/jdk/src/share/classes/com/sun/media/sound/DirectAudioDevice.java

    r278 r390  
    772772                throw new ArrayIndexOutOfBoundsException(off);
    773773            }
    774             if (off + len > b.length) {
     774            if ((long)off + (long)len > (long)b.length) {
    775775                throw new ArrayIndexOutOfBoundsException(b.length);
    776776            }
     
    10011001                throw new ArrayIndexOutOfBoundsException(off);
    10021002            }
    1003             if (off + len > b.length) {
     1003            if ((long)off + (long)len > (long)b.length) {
    10041004                throw new ArrayIndexOutOfBoundsException(b.length);
    10051005            }
  • trunk/openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMixingSourceDataLine.java

    r278 r390  
    131131            throw new IllegalArgumentException(
    132132                    "Number of bytes does not represent an integral number of sample frames.");
     133        if (off < 0) {
     134            throw new ArrayIndexOutOfBoundsException(off);
     135        }
     136        if ((long)off + (long)len > (long)b.length) {
     137            throw new ArrayIndexOutOfBoundsException(b.length);
     138        }
    133139
    134140        byte[] buff = cycling_buffer;
  • trunk/openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/Base64.java

    r2 r390  
    4949 * @author Anli Shundi
    5050 * @author Christian Geuer-Pollmann
    51  * @see <A HREF="ftp://ftp.isi.edu/in-notes/rfc2045.txt">RFC 2045</A>
     51 * @see <A HREF="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045</A>
    5252 * @see com.sun.org.apache.xml.internal.security.transforms.implementations.TransformBase64Decode
    5353 */
  • trunk/openjdk/jdk/src/share/classes/com/sun/security/auth/LdapPrincipal.java

    r278 r390  
    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 *
     
    3232/**
    3333 * A principal identified by a distinguished name as specified by
    34  * <a href="http://ietf.org//rfc/rfc2253.txt">RFC 2253</a>.
     34 * <a href="http://www.ietf.org/rfc/rfc2253.txt">RFC 2253</a>.
    3535 *
    3636 * <p>
     
    123123    /**
    124124     * Creates a string representation of this principal's name in the format
    125      * defined by <a href="http://ietf.org/rfc/rfc2253.txt">RFC 2253</a>.
     125     * defined by <a href="http://www.ietf.org/rfc/rfc2253.txt">RFC 2253</a>.
    126126     * If the name has zero components an empty string is returned.
    127127     *
  • trunk/openjdk/jdk/src/share/classes/com/sun/security/sasl/CramMD5Client.java

    r278 r390  
    11/*
    2  * Copyright (c) 1999, 2003, 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 *
     
    3434/**
    3535  * Implements the CRAM-MD5 SASL client-side mechanism.
    36   * (<A HREF="ftp://ftp.isi.edu/in-notes/rfc2195.txt">RFC 2195</A>).
     36  * (<A HREF="http://www.ietf.org/rfc/rfc2195.txt">RFC 2195</A>).
    3737  * CRAM-MD5 has no initial response. It receives bytes from
    3838  * the server as a challenge, which it hashes by using MD5 and the password.
  • trunk/openjdk/jdk/src/share/classes/com/sun/security/sasl/CramMD5Server.java

    r278 r390  
    11/*
    2  * Copyright (c) 2003, 2004, 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 *
     
    3939/**
    4040  * Implements the CRAM-MD5 SASL server-side mechanism.
    41   * (<A HREF="ftp://ftp.isi.edu/in-notes/rfc2195.txt">RFC 2195</A>).
     41  * (<A HREF="http://www.ietf.org/rfc/rfc2195.txt">RFC 2195</A>).
    4242  * CRAM-MD5 has no initial response.
    4343  *
  • trunk/openjdk/jdk/src/share/classes/com/sun/security/sasl/ExternalClient.java

    r278 r390  
    11/*
    2  * Copyright (c) 1999, 2003, 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 *
     
    3030/**
    3131  * Implements the EXTERNAL SASL client mechanism.
    32   * (<A HREF="ftp://ftp.isi.edu/in-notes/rfc2222.txt">RFC 2222</A>).
     32  * (<A HREF="http://www.ietf.org/rfc/rfc2222.txt">RFC 2222</A>).
    3333  * The EXTERNAL mechanism returns the optional authorization ID as
    3434  * the initial response. It processes no challenges.
  • trunk/openjdk/jdk/src/share/classes/com/sun/security/sasl/gsskerb/GssKrb5Client.java

    r278 r390  
    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 *
     
    4040/**
    4141  * Implements the GSSAPI SASL client mechanism for Kerberos V5.
    42   * (<A HREF="ftp://ftp.isi.edu/in-notes/rfc2222.txt">RFC 2222</A>,
     42  * (<A HREF="http://www.ietf.org/rfc/rfc2222.txt">RFC 2222</A>,
    4343  * <a HREF="http://www.ietf.org/internet-drafts/draft-ietf-cat-sasl-gssapi-04.txt">draft-ietf-cat-sasl-gssapi-04.txt</a>).
    4444  * It uses the Java Bindings for GSSAPI
    45   * (<A HREF="ftp://ftp.isi.edu/in-notes/rfc2853.txt">RFC 2853</A>)
     45  * (<A HREF="http://www.ietf.org/rfc/rfc2853.txt">RFC 2853</A>)
    4646  * for getting GSSAPI/Kerberos V5 support.
    4747  *
  • trunk/openjdk/jdk/src/share/classes/com/sun/security/sasl/gsskerb/GssKrb5Server.java

    r278 r390  
    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 *
     
    4040/**
    4141  * Implements the GSSAPI SASL server mechanism for Kerberos V5.
    42   * (<A HREF="ftp://ftp.isi.edu/in-notes/rfc2222.txt">RFC 2222</A>,
     42  * (<A HREF="http://www.ietf.org/rfc/rfc2222.txt">RFC 2222</A>,
    4343  * <a HREF="http://www.ietf.org/internet-drafts/draft-ietf-cat-sasl-gssapi-00.txt">draft-ietf-cat-sasl-gssapi-00.txt</a>).
    4444  *
  • trunk/openjdk/jdk/src/share/classes/java/awt/AWTKeyStroke.java

    r309 r390  
    11/*
    2  * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
  • trunk/openjdk/jdk/src/share/classes/java/awt/KeyboardFocusManager.java

    r278 r390  
    11/*
    2  * Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    477477    protected Component getGlobalFocusOwner() throws SecurityException {
    478478        synchronized (KeyboardFocusManager.class) {
    479             if (this == getCurrentKeyboardFocusManager()) {
    480                 return focusOwner;
    481             } else {
    482                 if (focusLog.isLoggable(Level.FINER)) {
    483                     focusLog.log(Level.FINER, "This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
    484                 }
    485                 throw new SecurityException(notPrivileged);
    486             }
     479            checkCurrentKFMSecurity();
     480            return focusOwner;
    487481        }
    488482    }
     
    518512        if (focusOwner == null || focusOwner.isFocusable()) {
    519513            synchronized (KeyboardFocusManager.class) {
     514                checkCurrentKFMSecurity();
    520515                oldFocusOwner = getFocusOwner();
    521516
     
    567562     */
    568563    public void clearGlobalFocusOwner() {
     564        synchronized (KeyboardFocusManager.class) {
     565             checkCurrentKFMSecurity();
     566        }
     567
    569568        if (!GraphicsEnvironment.isHeadless()) {
    570569            // Toolkit must be fully initialized, otherwise
     
    646645    {
    647646        synchronized (KeyboardFocusManager.class) {
    648             if (this == getCurrentKeyboardFocusManager()) {
    649                 return permanentFocusOwner;
    650             } else {
    651                 if (focusLog.isLoggable(Level.FINER)) {
    652                     focusLog.log(Level.FINER, "This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
    653                 }
    654                 throw new SecurityException(notPrivileged);
    655             }
     647            checkCurrentKFMSecurity();
     648            return permanentFocusOwner;
    656649        }
    657650    }
     
    689682        if (permanentFocusOwner == null || permanentFocusOwner.isFocusable()) {
    690683            synchronized (KeyboardFocusManager.class) {
     684                checkCurrentKFMSecurity();
    691685                oldPermanentFocusOwner = getPermanentFocusOwner();
    692686
     
    754748    protected Window getGlobalFocusedWindow() throws SecurityException {
    755749        synchronized (KeyboardFocusManager.class) {
    756             if (this == getCurrentKeyboardFocusManager()) {
    757                return focusedWindow;
    758             } else {
    759                 if (focusLog.isLoggable(Level.FINER)) {
    760                     focusLog.log(Level.FINER, "This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
    761                 }
    762                 throw new SecurityException(notPrivileged);
    763             }
     750            checkCurrentKFMSecurity();
     751            return focusedWindow;
    764752        }
    765753    }
     
    792780        if (focusedWindow == null || focusedWindow.isFocusableWindow()) {
    793781            synchronized (KeyboardFocusManager.class) {
     782                checkCurrentKFMSecurity();
    794783                oldFocusedWindow = getFocusedWindow();
    795784
     
    858847    protected Window getGlobalActiveWindow() throws SecurityException {
    859848        synchronized (KeyboardFocusManager.class) {
    860             if (this == getCurrentKeyboardFocusManager()) {
    861                return activeWindow;
    862             } else {
    863                 if (focusLog.isLoggable(Level.FINER)) {
    864                     focusLog.log(Level.FINER, "This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
    865                 }
    866                 throw new SecurityException(notPrivileged);
    867             }
     849            checkCurrentKFMSecurity();
     850            return activeWindow;
    868851        }
    869852    }
     
    894877        Window oldActiveWindow;
    895878        synchronized (KeyboardFocusManager.class) {
     879            checkCurrentKFMSecurity();
    896880            oldActiveWindow = getActiveWindow();
    897881            if (focusLog.isLoggable(Level.FINER)) {
     
    11881172    {
    11891173        synchronized (KeyboardFocusManager.class) {
    1190             if (this == getCurrentKeyboardFocusManager()) {
    1191                 return currentFocusCycleRoot;
    1192             } else {
    1193                 if (focusLog.isLoggable(Level.FINER)) {
    1194                     focusLog.log(Level.FINER, "This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
    1195                 }
    1196                 throw new SecurityException(notPrivileged);
    1197             }
     1174            checkCurrentKFMSecurity();
     1175            return currentFocusCycleRoot;
    11981176        }
    11991177    }
     
    12191197
    12201198        synchronized (KeyboardFocusManager.class) {
     1199            checkCurrentKFMSecurity();
    12211200            oldFocusCycleRoot  = getCurrentFocusCycleRoot();
    12221201            currentFocusCycleRoot = newFocusCycleRoot;
     
    31033082        }
    31043083    }
     3084
     3085     private void checkCurrentKFMSecurity() {
     3086         if (this != getCurrentKeyboardFocusManager()) {
     3087             if (focusLog.isLoggable(Level.FINER)) {
     3088                 focusLog.finer("This manager is " + this +
     3089                                ", current is " + getCurrentKeyboardFocusManager());
     3090             }
     3091             throw new SecurityException(notPrivileged);
     3092         }
     3093     }
    31053094}
  • trunk/openjdk/jdk/src/share/classes/java/io/ObjectStreamClass.java

    r278 r390  
    11/*
    2  * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    731731                new InvalidClassException(deserializeEx.classname,
    732732                                          deserializeEx.getMessage());
    733             ice.initCause(deserializeEx);
    734733            throw ice;
    735734        }
     
    746745                new InvalidClassException(serializeEx.classname,
    747746                                          serializeEx.getMessage());
    748             ice.initCause(serializeEx);
    749747            throw ice;
    750748        }
     
    763761                new InvalidClassException(defaultSerializeEx.classname,
    764762                                          defaultSerializeEx.getMessage());
    765             ice.initCause(defaultSerializeEx);
    766763            throw ice;
    767764        }
  • trunk/openjdk/jdk/src/share/classes/java/net/NetworkInterface.java

    r309 r390  
    11/*
    2  * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
  • trunk/openjdk/jdk/src/share/classes/java/net/URI.java

    r278 r390  
    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 *
     
    458458 * @since 1.4
    459459 *
    460  * @see <a href="http://ietf.org/rfc/rfc2279.txt"><i>RFC&nbsp;2279: UTF-8, a
     460 * @see <a href="http://www.ietf.org/rfc/rfc2279.txt"><i>RFC&nbsp;2279: UTF-8, a
    461461 * transformation format of ISO 10646</i></a>, <br><a
    462462 * href="http://www.ietf.org/rfc/rfc2373.txt"><i>RFC&nbsp;2373: IPv6 Addressing
  • trunk/openjdk/jdk/src/share/classes/java/nio/charset/package.html

    r278 r390  
    11<!--
    2  Copyright (c) 2001, 2005, 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
     
    4949<p> A <i>charset</i> is named mapping between sequences of sixteen-bit Unicode
    5050characters and sequences of bytes, in the sense defined in <a
    51 href="http://ietf.org/rfc/rfc2278.txt"><i>RFC&nbsp;2278</i></a>.  A
     51href="http://www.ietf.org/rfc/rfc2278.txt"><i>RFC&nbsp;2278</i></a>.  A
    5252<i>decoder</i> is an engine which transforms bytes in a specific charset into
    5353characters, and an <i>encoder</i> is an engine which transforms characters into
  • trunk/openjdk/jdk/src/share/classes/java/sql/Timestamp.java

    r309 r390  
    11/*
    2  * Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
  • trunk/openjdk/jdk/src/share/classes/java/util/TimeZone.java

    r278 r390  
    11/*
    2  * Copyright (c) 1996, 2005, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    4444import java.security.PrivilegedAction;
    4545import java.util.concurrent.ConcurrentHashMap;
     46import sun.misc.SharedSecrets;
     47import sun.misc.JavaAWTAccess;
    4648import sun.security.action.GetPropertyAction;
    4749import sun.util.TimeZoneNameUtility;
     
    543545     */
    544546    static TimeZone getDefaultRef() {
    545         TimeZone defaultZone = defaultZoneTL.get();
     547        TimeZone defaultZone = getDefaultInAppContext();
    546548        if (defaultZone == null) {
    547549            defaultZone = defaultTimeZone;
     
    634636            synchronized (TimeZone.class) {
    635637                defaultTimeZone = zone;
    636                 defaultZoneTL.set(null);
     638                setDefaultInAppContext(null);
    637639            }
    638640        } else {
    639             defaultZoneTL.set(zone);
     641            setDefaultInAppContext(zone);
     642        }
     643    }
     644
     645    /**
     646     * Returns the default TimeZone in an AppContext if any AppContext
     647     * has ever used. null is returned if any AppContext hasn't been
     648     * used or if the AppContext doesn't have the default TimeZone.
     649     */
     650    private synchronized static TimeZone getDefaultInAppContext() {
     651        javaAWTAccess = SharedSecrets.getJavaAWTAccess();
     652        if (javaAWTAccess == null) {
     653            return mainAppContextDefault;
     654        } else {
     655            if (!javaAWTAccess.isDisposed()) {
     656                TimeZone tz = (TimeZone)
     657                    javaAWTAccess.get(TimeZone.class);
     658                if (tz == null && javaAWTAccess.isMainAppContext()) {
     659                    return mainAppContextDefault;
     660                } else {
     661                    return tz;
     662                }
     663            }
     664        }
     665        return null;
     666    }
     667
     668    /**
     669     * Sets the default TimeZone in the AppContext to the given
     670     * tz. null is handled special: do nothing if any AppContext
     671     * hasn't been used, remove the default TimeZone in the
     672     * AppContext otherwise.
     673     */
     674    private synchronized static void setDefaultInAppContext(TimeZone tz) {
     675        javaAWTAccess = SharedSecrets.getJavaAWTAccess();
     676        if (javaAWTAccess == null) {
     677            mainAppContextDefault = tz;
     678        } else {
     679            if (!javaAWTAccess.isDisposed()) {
     680                javaAWTAccess.put(TimeZone.class, tz);
     681                if (javaAWTAccess.isMainAppContext()) {
     682                    mainAppContextDefault = null;
     683                }
     684            }
    640685        }
    641686    }
     
    688733    private String           ID;
    689734    private static volatile TimeZone defaultTimeZone;
    690     private static final InheritableThreadLocal<TimeZone> defaultZoneTL
    691                                         = new InheritableThreadLocal<TimeZone>();
    692735
    693736    static final String         GMT_ID        = "GMT";
    694737    private static final int    GMT_ID_LENGTH = 3;
     738
     739    /*
     740     * Provides access implementation-private methods without using reflection
     741     *
     742     * Note that javaAWTAccess may be null if sun.awt.AppContext class hasn't
     743     * been loaded. If so, it implies that AWTSecurityManager is not our
     744     * SecurityManager and we can use a local static variable.
     745     * This works around a build time issue.
     746     */
     747    private static JavaAWTAccess javaAWTAccess;
     748
     749    // a static TimeZone we can reference if no AppContext is in place
     750    private static TimeZone mainAppContextDefault;
     751
    695752
    696753    /**
  • trunk/openjdk/jdk/src/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java

    r278 r390  
    3535
    3636package java.util.concurrent.atomic;
     37import java.lang.reflect.Array;
     38import java.util.Arrays;
    3739import sun.misc.Unsafe;
    38 import java.util.*;
    3940
    4041/**
     
    5051    private static final long serialVersionUID = -6209656149925076980L;
    5152
    52     private static final Unsafe unsafe = Unsafe.getUnsafe();
    53     private static final int base = unsafe.arrayBaseOffset(Object[].class);
    54     private static final int scale = unsafe.arrayIndexScale(Object[].class);
    55     private final Object[] array;
    56 
    57     private long rawIndex(int i) {
     53    private static final Unsafe unsafe;
     54    private static final int base;
     55    private static final int shift;
     56    private static final long arrayFieldOffset;
     57    private final Object[] array; // must have exact type Object[]
     58
     59    static {
     60        int scale;
     61        try {
     62            unsafe = Unsafe.getUnsafe();
     63            arrayFieldOffset = unsafe.objectFieldOffset
     64                (AtomicReferenceArray.class.getDeclaredField("array"));
     65            base = unsafe.arrayBaseOffset(Object[].class);
     66            scale = unsafe.arrayIndexScale(Object[].class);
     67        } catch (Exception e) {
     68            throw new Error(e);
     69        }
     70        if ((scale & (scale - 1)) != 0)
     71            throw new Error("data type scale not a power of two");
     72        shift = 31 - Integer.numberOfLeadingZeros(scale);
     73    }
     74
     75    private long checkedByteOffset(int i) {
    5876        if (i < 0 || i >= array.length)
    5977            throw new IndexOutOfBoundsException("index " + i);
    60         return base + (long) i * scale;
     78
     79        return byteOffset(i);
     80    }
     81
     82    private static long byteOffset(int i) {
     83        return ((long) i << shift) + base;
    6184    }
    6285
     
    6790    public AtomicReferenceArray(int length) {
    6891        array = new Object[length];
    69         // must perform at least one volatile write to conform to JMM
    70         if (length > 0)
    71             unsafe.putObjectVolatile(array, rawIndex(0), null);
    7292    }
    7393
     
    80100     */
    81101    public AtomicReferenceArray(E[] array) {
    82         if (array == null)
    83             throw new NullPointerException();
    84         int length = array.length;
    85         this.array = new Object[length];
    86         if (length > 0) {
    87             int last = length-1;
    88             for (int i = 0; i < last; ++i)
    89                 this.array[i] = array[i];
    90             // Do the last write as volatile
    91             E e = array[last];
    92             unsafe.putObjectVolatile(this.array, rawIndex(last), e);
    93         }
     102        // Visibility guaranteed by final field guarantees
     103        this.array = Arrays.copyOf(array, array.length, Object[].class);
    94104    }
    95105
     
    110120     */
    111121    public final E get(int i) {
    112         return (E) unsafe.getObjectVolatile(array, rawIndex(i));
     122        return getRaw(checkedByteOffset(i));
     123    }
     124
     125    private E getRaw(long offset) {
     126        return (E) unsafe.getObjectVolatile(array, offset);
    113127    }
    114128
     
    120134     */
    121135    public final void set(int i, E newValue) {
    122         unsafe.putObjectVolatile(array, rawIndex(i), newValue);
     136        unsafe.putObjectVolatile(array, checkedByteOffset(i), newValue);
    123137    }
    124138
     
    131145     */
    132146    public final void lazySet(int i, E newValue) {
    133         unsafe.putOrderedObject(array, rawIndex(i), newValue);
     147        unsafe.putOrderedObject(array, checkedByteOffset(i), newValue);
    134148    }
    135149
     
    144158     */
    145159    public final E getAndSet(int i, E newValue) {
     160        long offset = checkedByteOffset(i);
    146161        while (true) {
    147             E current = get(i);
    148             if (compareAndSet(i, current, newValue))
     162            E current = getRaw(offset);
     163            if (compareAndSetRaw(offset, current, newValue))
    149164                return current;
    150165        }
     
    154169     * Atomically sets the element at position {@code i} to the given
    155170     * updated value if the current value {@code ==} the expected value.
     171     *
    156172     * @param i the index
    157173     * @param expect the expected value
     
    161177     */
    162178    public final boolean compareAndSet(int i, E expect, E update) {
    163         return unsafe.compareAndSwapObject(array, rawIndex(i),
    164                                          expect, update);
     179        return compareAndSetRaw(checkedByteOffset(i), expect, update);
     180    }
     181
     182    private boolean compareAndSetRaw(long offset, E expect, E update) {
     183        return unsafe.compareAndSwapObject(array, offset, expect, update);
    165184    }
    166185
     
    187206     */
    188207    public String toString() {
    189         if (array.length > 0) // force volatile read
    190             get(0);
    191         return Arrays.toString(array);
     208        int iMax = array.length - 1;
     209        if (iMax == -1)
     210            return "[]";
     211
     212        StringBuilder b = new StringBuilder();
     213        b.append('[');
     214        for (int i = 0; ; i++) {
     215            b.append(getRaw(byteOffset(i)));
     216            if (i == iMax)
     217                return b.append(']').toString();
     218            b.append(',').append(' ');
     219        }
     220    }
     221
     222    /**
     223     * Reconstitutes the instance from a stream (that is, deserializes it).
     224     * @param s the stream
     225     */
     226    private void readObject(java.io.ObjectInputStream s)
     227        throws java.io.IOException, ClassNotFoundException {
     228        // Note: This must be changed if any additional fields are defined
     229        Object a = s.readFields().get("array", null);
     230        if (a == null || !a.getClass().isArray())
     231            throw new java.io.InvalidObjectException("Not array type");
     232        if (a.getClass() != Object[].class)
     233            a = Arrays.copyOf((Object[])a, Array.getLength(a), Object[].class);
     234        unsafe.putObjectVolatile(this, arrayFieldOffset, a);
    192235    }
    193236
  • trunk/openjdk/jdk/src/share/classes/javax/management/remote/JMXServiceURL.java

    r278 r390  
    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 *
     
    108108 *
    109109 * @see <a
    110  * href="ftp://ftp.rfc-editor.org/in-notes/rfc2609.txt">RFC 2609,
     110 * href="http://www.ietf.org/rfc/rfc2609.txt">RFC 2609,
    111111 * "Service Templates and <code>Service:</code> Schemes"</a>
    112112 * @see <a
    113  * href="ftp://ftp.rfc-editor.org/in-notes/rfc3111.txt">RFC 3111,
     113 * href="http://www.ietf.org/rfc/rfc3111.txt">RFC 3111,
    114114 * "Service Location Protocol Modifications for IPv6"</a>
    115115 *
  • trunk/openjdk/jdk/src/share/classes/javax/naming/ldap/LdapName.java

    r278 r390  
    11/*
    2  * Copyright (c) 2003, 2004, 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 *
     
    4343/**
    4444 * This class represents a distinguished name as specified by
    45  * <a href="http://ietf.org//rfc/rfc2253.txt">RFC 2253</a>.
     45 * <a href="http://www.ietf.org/rfc/rfc2253.txt">RFC 2253</a>.
    4646 * A distinguished name, or DN, is composed of an ordered list of
    4747 * components called <em>relative distinguished name</em>s, or RDNs.
     
    116116     * @param name  This is a non-null distinguished name formatted
    117117     * according to the rules defined in
    118      * <a href="http://ietf.org/rfc/rfc2253.txt">RFC 2253</a>.
     118     * <a href="http://www.ietf.org/rfc/rfc2253.txt">RFC 2253</a>.
    119119     *
    120120     * @throws InvalidNameException if a syntax violation is detected.
     
    615615    /**
    616616     * Returns a string representation of this LDAP name in a format
    617      * defined by <a href="http://ietf.org/rfc/rfc2253.txt">RFC 2253</a>
     617     * defined by <a href="http://www.ietf.org/rfc/rfc2253.txt">RFC 2253</a>
    618618     * and described in the class description. If the name has zero
    619619     * components an empty string is returned.
  • trunk/openjdk/jdk/src/share/classes/javax/naming/ldap/Rdn.java

    r278 r390  
    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 *
     
    4646 * This class represents a relative distinguished name, or RDN, which is a
    4747 * component of a distinguished name as specified by
    48  * <a href="http://ietf.org/rfc/rfc2253.txt">RFC 2253</a>.
     48 * <a href="http://www.ietf.org/rfc/rfc2253.txt">RFC 2253</a>.
    4949 * An example of an RDN is "OU=Sales+CN=J.Smith". In this example,
    5050 * the RDN consist of multiple attribute type/value pairs. The
     
    118118     * <p>
    119119     * The string attribute values are not interpretted as
    120      * <a href="http://ietf.org/rfc/rfc2253.txt">RFC 2253</a>
     120     * <a href="http://www.ietf.org/rfc/rfc2253.txt">RFC 2253</a>
    121121     * formatted RDN strings. That is, the values are used
    122122     * literally (not parsed) and assumed to be unescaped.
     
    153153     * Constructs an Rdn from the given string.
    154154     * This constructor takes a string formatted according to the rules
    155      * defined in <a href="http://ietf.org//rfc/rfc2253.txt">RFC 2253</a>
     155     * defined in <a href="http://www.ietf.org/rfc/rfc2253.txt">RFC 2253</a>
    156156     * and described in the class description for
    157157     * {@link javax.naming.ldap.LdapName}.
     
    181181     * value.
    182182     * The string attribute values are not interpretted as
    183      * <a href="http://ietf.org/rfc/rfc2253.txt">RFC 2253</a>
     183     * <a href="http://www.ietf.org/rfc/rfc2253.txt">RFC 2253</a>
    184184     * formatted RDN strings. That is, the values are used
    185185     * literally (not parsed) and assumed to be unescaped.
     
    217217     * Adds the given attribute type and value to this Rdn.
    218218     * The string attribute values are not interpretted as
    219      * <a href="http://ietf.org/rfc/rfc2253.txt">RFC 2253</a>
     219     * <a href="http://www.ietf.org/rfc/rfc2253.txt">RFC 2253</a>
    220220     * formatted RDN strings. That is the values are used
    221221     * literally (not parsed) and assumed to be unescaped.
     
    281281    /**
    282282     * Returns this Rdn as a string represented in a format defined by
    283      * <a href="http://ietf.org//rfc/rfc2253.txt">RFC 2253</a> and described
     283     * <a href="http://www.ietf.org/rfc/rfc2253.txt">RFC 2253</a> and described
    284284     * in the class description for {@link javax.naming.ldap.LdapName LdapName}.
    285285     *
     
    504504     * Given the value of an attribute, returns a string escaped according
    505505     * to the rules specified in
    506      * <a href="http://ietf.org/rfc/rfc2253.txt">RFC 2253</a>.
     506     * <a href="http://www.ietf.org/rfc/rfc2253.txt">RFC 2253</a>.
    507507     * <p>
    508508     * For example, if the val is "Sue, Grabbit and Runn", the escaped
     
    583583     * Given an attribute value string formated according to the rules
    584584     * specified in
    585      * <a href="http://ietf.org//rfc/rfc2253.txt">RFC 2253</a>,
     585     * <a href="http://www.ietf.org/rfc/rfc2253.txt">RFC 2253</a>,
    586586     * returns the unformated value.  Escapes and quotes are
    587587     * stripped away, and hex-encoded UTF-8 is converted to equivalent
  • trunk/openjdk/jdk/src/share/classes/javax/net/ssl/SSLContext.java

    r278 r390  
    11/*
    2  * Copyright (c) 1999, 2006, 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 *
     
    160160     * @param protocol the standard name of the requested protocol.
    161161     *          See Appendix A in the <a href=
    162      *  "{@docRoot}/../technotes/guides//security/jsse/JSSERefGuide.html#AppA">
     162     *  "{@docRoot}/../technotes/guides/security/jsse/JSSERefGuide.html#AppA">
    163163     *          Java Secure Socket Extension Reference Guide </a>
    164164     *          for information about standard protocol names.
  • trunk/openjdk/jdk/src/share/classes/javax/print/DocFlavor.java

    r278 r390  
    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 *
     
    452452     * A String representing the host operating system encoding.
    453453     * This will follow the conventions documented in
    454      * <a href="http://ietf.org/rfc/rfc2278.txt">
     454     * <a href="http://www.ietf.org/rfc/rfc2278.txt">
    455455     * <i>RFC&nbsp;2278:&nbsp;IANA Charset Registration Procedures</i></a>
    456456     * except where historical names are returned for compatibility with
  • trunk/openjdk/jdk/src/share/classes/javax/swing/ImageIcon.java

    r309 r390  
    11/*
    2  * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
  • trunk/openjdk/jdk/src/share/classes/sun/awt/AppContext.java

    r278 r390  
    11/*
    2  * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    768768        return changeSupport.getPropertyChangeListeners(propertyName);
    769769    }
     770
     771    // Set up JavaAWTAccess in SharedSecrets
     772    static {
     773        sun.misc.SharedSecrets.setJavaAWTAccess(new sun.misc.JavaAWTAccess() {
     774            public Object get(Object key) {
     775                return getAppContext().get(key);
     776            }
     777            public void put(Object key, Object value) {
     778                getAppContext().put(key, value);
     779            }
     780            public void remove(Object key) {
     781                getAppContext().remove(key);
     782            }
     783            public boolean isDisposed() {
     784                return getAppContext().isDisposed();
     785            }
     786            public boolean isMainAppContext() {
     787                return (numAppContexts == 1);
     788            }
     789        });
     790    }
    770791}
    771792
  • trunk/openjdk/jdk/src/share/classes/sun/awt/SunToolkit.java

    r309 r390  
    11/*
    2  * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
  • trunk/openjdk/jdk/src/share/classes/sun/awt/image/PNGImageDecoder.java

    r278 r390  
    11/*
    2  * Copyright (c) 1999, 2006, 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 *
     
    3333
    3434/** PNG - Portable Network Graphics - image file reader.
    35     See <a href=ftp://ds.internic.net/rfc/rfc2083.txt>RFC2083</a> for details. */
     35    See <a href=http://www.ietf.org/rfc/rfc2083.txt>RFC2083</a> for details. */
    3636
    3737/* this is changed
  • trunk/openjdk/jdk/src/share/classes/sun/font/FileFontStrike.java

    r278 r390  
    11/*
    2  * Copyright (c) 2003, 2006, 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 *
     
    5757    private static final int SEGLONGARRAY  = 4;
    5858
    59     private int glyphCacheFormat = UNINITIALISED;
     59    private volatile int glyphCacheFormat = UNINITIALISED;
    6060
    6161    /* segmented arrays are blocks of 256 */
     
    427427
    428428    /* Called only from synchronized code or constructor */
    429     private void initGlyphCache() {
     429    private synchronized void initGlyphCache() {
    430430
    431431        int numGlyphs = mapper.getNumGlyphs();
     432        int tmpFormat = UNINITIALISED;
    432433
    433434        if (segmentedCache) {
    434435            int numSegments = (numGlyphs + SEGSIZE-1)/SEGSIZE;
    435436            if (FontManager.longAddresses) {
    436                 glyphCacheFormat = SEGLONGARRAY;
     437                tmpFormat = SEGLONGARRAY;
    437438                segLongGlyphImages = new long[numSegments][];
    438439                this.disposer.segLongGlyphImages = segLongGlyphImages;
    439440             } else {
    440                  glyphCacheFormat = SEGINTARRAY;
     441                 tmpFormat = SEGINTARRAY;
    441442                 segIntGlyphImages = new int[numSegments][];
    442443                 this.disposer.segIntGlyphImages = segIntGlyphImages;
     
    444445        } else {
    445446            if (FontManager.longAddresses) {
    446                 glyphCacheFormat = LONGARRAY;
     447                tmpFormat = LONGARRAY;
    447448                longGlyphImages = new long[numGlyphs];
    448449                this.disposer.longGlyphImages = longGlyphImages;
    449450            } else {
    450                 glyphCacheFormat = INTARRAY;
     451                tmpFormat = INTARRAY;
    451452                intGlyphImages = new int[numGlyphs];
    452453                this.disposer.intGlyphImages = intGlyphImages;
    453454            }
    454455        }
     456        glyphCacheFormat = tmpFormat;
    455457    }
    456458
  • trunk/openjdk/jdk/src/share/classes/sun/java2d/pipe/DrawImage.java

    r309 r390  
    11/*
    2  * Copyright (c) 2001, 2007, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
  • trunk/openjdk/jdk/src/share/classes/sun/misc/SharedSecrets.java

    r309 r390  
    5353    private static JavaSecurityProtectionDomainAccess javaSecurityProtectionDomainAccess;
    5454    private static JavaSecurityAccess javaSecurityAccess;
     55    private static JavaAWTAccess javaAWTAccess;
    5556
    5657    public static JavaUtilJarAccess javaUtilJarAccess() {
     
    139140        return javaSecurityAccess;
    140141    }
     142
     143    public static void setJavaAWTAccess(JavaAWTAccess jaa) {
     144        javaAWTAccess = jaa;
     145    }
     146
     147    public static JavaAWTAccess getJavaAWTAccess() {
     148        // this may return null in which case calling code needs to
     149        // provision for.
     150        return javaAWTAccess;
     151    }
    141152}
  • trunk/openjdk/jdk/src/share/classes/sun/net/httpserver/Request.java

    r278 r390  
    11/*
    2  * Copyright (c) 2005, 2006, 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 *
     
    191191            else
    192192                v = String.copyValueOf(s, keyend, len - keyend);
     193
     194            if (hdrs.size() >= ServerConfig.getMaxReqHeaders()) {
     195                throw new IOException("Maximum number of request headers (" +
     196                        "sun.net.httpserver.maxReqHeaders) exceeded, " +
     197                        ServerConfig.getMaxReqHeaders() + ".");
     198            }
     199
    193200            hdrs.add (k,v);
    194201        }
  • trunk/openjdk/jdk/src/share/classes/sun/net/httpserver/ServerConfig.java

    r278 r390  
    11/*
    2  * Copyright (c) 2005, 2006, 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 *
     
    4646    static long defaultSelCacheTimeout = 120 ;  // seconds
    4747    static int defaultMaxIdleConnections = 200 ;
     48    static int defaultMaxReqHeaders = 200 ;
     49
    4850
    4951    static long defaultDrainAmount = 64 * 1024;
     
    5557    static long drainAmount;    // max # of bytes to drain from an inputstream
    5658    static int maxIdleConnections;
     59    // The maximum number of request headers allowable
     60    private static int maxReqHeaders;
     61
    5762    static boolean debug = false;
    5863
     
    9499                defaultDrainAmount))).longValue();
    95100
     101        maxReqHeaders = ((Integer)java.security.AccessController.doPrivileged(
     102                new sun.security.action.GetIntegerAction(
     103                "sun.net.httpserver.maxReqHeaders",
     104                defaultMaxReqHeaders))).intValue();
     105
    96106        debug = ((Boolean)java.security.AccessController.doPrivileged(
    97107                new sun.security.action.GetBooleanAction(
     
    130140        return drainAmount;
    131141    }
     142
     143    static int getMaxReqHeaders() {
     144        return maxReqHeaders;
     145    }
    132146}
  • trunk/openjdk/jdk/src/share/classes/sun/rmi/registry/RegistryImpl.java

    r309 r390  
    3030import java.util.MissingResourceException;
    3131import java.util.ResourceBundle;
     32import java.io.FilePermission;
    3233import java.io.IOException;
    3334import java.net.*;
     
    4243import java.security.AccessController;
    4344import java.security.CodeSource;
    44 import java.security.Policy; 
     45import java.security.Policy;
    4546import java.security.PrivilegedActionException;
    4647import java.security.PrivilegedExceptionAction;
    4748import java.security.PermissionCollection;
    4849import java.security.Permissions;
    49 import java.security.ProtectionDomain; 
     50import java.security.ProtectionDomain;
    5051import java.text.MessageFormat;
    5152import sun.rmi.server.LoaderHandler;
     
    5556import sun.rmi.transport.ObjectTable;
    5657import sun.rmi.transport.Target;
    57 import sun.security.action.GetPropertyAction;
    5858
    5959/**
     
    7777    /* indicate compatibility with JDK 1.1.x version of class */
    7878    private static final long serialVersionUID = 4666870661827494597L;
    79     private Hashtable bindings = new Hashtable(101);
    80     private static Hashtable allowedAccessCache = new Hashtable(3);
     79    private Hashtable<String, Remote> bindings
     80        = new Hashtable<String, Remote>(101);
     81    private static Hashtable<InetAddress, InetAddress> allowedAccessCache
     82        = new Hashtable<InetAddress, InetAddress>(3);
    8183    private static RegistryImpl registry;
    8284    private static ObjID id = new ObjID(ObjID.REGISTRY_ID);
     
    130132    {
    131133        synchronized (bindings) {
    132             Remote obj = (Remote)bindings.get(name);
     134            Remote obj = bindings.get(name);
    133135            if (obj == null)
    134136                throw new NotBoundException(name);
     
    147149        checkAccess("Registry.bind");
    148150        synchronized (bindings) {
    149             Remote curr = (Remote)bindings.get(name);
     151            Remote curr = bindings.get(name);
    150152            if (curr != null)
    151153                throw new AlreadyBoundException(name);
     
    164166        checkAccess("Registry.unbind");
    165167        synchronized (bindings) {
    166             Remote obj = (Remote)bindings.get(name);
     168            Remote obj = bindings.get(name);
    167169            if (obj == null)
    168170                throw new NotBoundException(name);
     
    214216
    215217            try {
    216                 clientHost = (InetAddress)
    217                     java.security.AccessController.doPrivileged(
    218                         new java.security.PrivilegedExceptionAction() {
    219                         public Object run()
     218                clientHost = java.security.AccessController.doPrivileged(
     219                    new java.security.PrivilegedExceptionAction<InetAddress>() {
     220                        public InetAddress run()
    220221                            throws java.net.UnknownHostException
    221222                        {
     
    239240
    240241                    java.security.AccessController.doPrivileged(
    241                         new java.security.PrivilegedExceptionAction() {
    242                             public Object run() throws java.io.IOException {
     242                        new java.security.PrivilegedExceptionAction<Void>() {
     243                            public Void run() throws java.io.IOException {
    243244                                /*
    244245                                 * if a ServerSocket can be bound to the client's
     
    335336            ClassLoader cl = new URLClassLoader(urls);
    336337
    337             String codebaseProperty = null;
    338             String prop = java.security.AccessController.doPrivileged(
    339                 new GetPropertyAction("java.rmi.server.codebase"));
    340                 if (prop != null && prop.trim().length() > 0) {
    341                     codebaseProperty = prop;
    342                 }
    343             URL[] codebaseURLs = null;
    344             if (codebaseProperty != null) {
    345                 codebaseURLs = sun.misc.URLClassPath.pathToURLs(codebaseProperty);
    346             } else {
    347                 codebaseURLs = new URL[0];
    348             }
    349 
    350338            /*
    351339             * Fix bugid 4242317: Classes defined by this class loader should
     
    365353                            return new RegistryImpl(regPort);
    366354                        }
    367                     }, getAccessControlContext(codebaseURLs));
     355                    }, getAccessControlContext());
    368356            } catch (PrivilegedActionException ex) {
    369357                throw (RemoteException) ex.getException();
     
    391379
    392380    /**
    393      * Generates an AccessControlContext from several URLs.
     381     * Generates an AccessControlContext with minimal permissions.
    394382     * The approach used here is taken from the similar method
    395383     * getAccessControlContext() in the sun.applet.AppletPanel class.
    396384     */
    397     private static AccessControlContext getAccessControlContext(URL[] urls) {
     385    private static AccessControlContext getAccessControlContext() {
    398386        // begin with permissions granted to all code in current policy
    399387        PermissionCollection perms = AccessController.doPrivileged(
     
    420408        perms.add(new RuntimePermission("accessClassInPackage.sun.*"));
    421409
    422         // add permissions required to load from codebase URL path
    423         LoaderHandler.addPermissionsForURLs(urls, perms, false);
     410        perms.add(new FilePermission("<<ALL FILES>>", "read"));
    424411
    425412        /*
     
    428415         */
    429416        ProtectionDomain pd = new ProtectionDomain(
    430             new CodeSource((urls.length > 0 ? urls[0] : null),
    431                 (java.security.cert.Certificate[]) null),
    432             perms);
     417            new CodeSource(null,
     418                (java.security.cert.Certificate[]) null), perms);
    433419        return new AccessControlContext(new ProtectionDomain[] { pd });
    434420    }
  • trunk/openjdk/jdk/src/share/classes/sun/rmi/server/LoaderHandler.java

    r309 r390  
    10291029     * it is not already implied by the collection.
    10301030     */
    1031     public static void addPermissionsForURLs(URL[] urls,
     1031    private static void addPermissionsForURLs(URL[] urls,
    10321032                                              PermissionCollection perms,
    10331033                                              boolean forLoader)
  • trunk/openjdk/jdk/src/share/classes/sun/security/jgss/krb5/InitialToken.java

    r278 r390  
    3434import java.security.MessageDigest;
    3535import java.security.NoSuchAlgorithmException;
     36import java.util.Arrays;
    3637import sun.security.krb5.*;
    3738import sun.security.jgss.GSSUtil;
     
    226227            }
    227228
    228             byte[] remoteBindingBytes = new byte[CHECKSUM_BINDINGS_SIZE];
    229             System.arraycopy(checksumBytes, 4, remoteBindingBytes, 0,
    230                              CHECKSUM_BINDINGS_SIZE);
    231 
    232             byte[] noBindings = new byte[CHECKSUM_BINDINGS_SIZE];
    233             boolean tokenContainsBindings =
    234                 (!java.util.Arrays.equals(noBindings, remoteBindingBytes));
    235 
    236229            ChannelBinding localBindings = context.getChannelBinding();
    237230
    238             if (tokenContainsBindings ||
    239                 localBindings != null) {
    240 
    241                 boolean badBindings = false;
    242                 String errorMessage = null;
    243 
    244                 if (tokenContainsBindings &&
    245                     localBindings != null) {
     231            // Ignore remote channel binding info when not requested at
     232            // local side (RFC 4121 4.1.1.2: the acceptor MAY ignore...).
     233            //
     234            // All major krb5 implementors implement this "MAY",
     235            // and some applications depend on it as a workaround
     236            // for not having a way to negotiate the use of channel
     237            // binding -- the initiator application always uses CB
     238            // and hopes the acceptor will ignore the CB if the
     239            // acceptor doesn't support CB.
     240            if (localBindings != null) {
     241                byte[] remoteBindingBytes = new byte[CHECKSUM_BINDINGS_SIZE];
     242                System.arraycopy(checksumBytes, 4, remoteBindingBytes, 0,
     243                                 CHECKSUM_BINDINGS_SIZE);
     244
     245                byte[] noBindings = new byte[CHECKSUM_BINDINGS_SIZE];
     246                if (!Arrays.equals(noBindings, remoteBindingBytes)) {
    246247                    byte[] localBindingsBytes =
    247248                        computeChannelBinding(localBindings);
    248                     //              System.out.println("ChannelBinding hash: "
    249                     //         + getHexBytes(localBindingsBytes));
    250                     badBindings =
    251                         (!java.util.Arrays.equals(localBindingsBytes,
    252                                                 remoteBindingBytes));
    253                     errorMessage = "Bytes mismatch!";
    254                 } else if (localBindings == null) {
    255                     errorMessage = "ChannelBinding not provided!";
    256                     badBindings = true;
     249                    if (!Arrays.equals(localBindingsBytes,
     250                                                remoteBindingBytes)) {
     251                        throw new GSSException(GSSException.BAD_BINDINGS, -1,
     252                                               "Bytes mismatch!");
     253                    }
    257254                } else {
    258                     errorMessage = "Token missing ChannelBinding!";
    259                     badBindings = true;
     255                    throw new GSSException(GSSException.BAD_BINDINGS, -1,
     256                                           "Token missing ChannelBinding!");
    260257                }
    261 
    262                 if (badBindings)
    263                     throw new GSSException(GSSException.BAD_BINDINGS, -1,
    264                                            errorMessage);
    265258            }
    266259
  • trunk/openjdk/jdk/src/share/classes/sun/security/provider/certpath/ForwardBuilder.java

    r278 r390  
    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 *
     
    641641        }
    642642
    643         ForwardState currState = (ForwardState) currentState;
     643        ForwardState currState = (ForwardState)currentState;
     644   
     645        // Don't bother to verify untrusted certificate.
     646        currState.untrustedChecker.check(cert, Collections.<String>emptySet());
    644647
    645648        /*
  • trunk/openjdk/jdk/src/share/classes/sun/security/provider/certpath/ForwardState.java

    r278 r390  
    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 *
     
    7979    /* the checker used for revocation status */
    8080    public CrlRevocationChecker crlChecker;
     81   
     82    /* the untrusted certificates checker */
     83    UntrustedChecker untrustedChecker;
    8184
    8285    /* The list of user-defined checkers that support forward checking */
  • trunk/openjdk/jdk/src/share/classes/sun/security/provider/certpath/PKIXCertPathValidator.java

    r278 r390  
    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 *
     
    293293                              pkixParam.getPolicyQualifiersRejected(),
    294294                              rootNode);
     295        UntrustedChecker untrustedChecker = new UntrustedChecker();
    295296
    296297        // add standard checkers that we will be using
     298        certPathCheckers.add(untrustedChecker);
    297299        certPathCheckers.add(algorithmChecker);
    298300        certPathCheckers.add(keyChecker);
  • trunk/openjdk/jdk/src/share/classes/sun/security/provider/certpath/ReverseBuilder.java

    r278 r390  
    11/*
    2  * Copyright (c) 2000, 2009, 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 *
     
    346346            return;
    347347        }
     348       
     349        // Don't bother to verify untrusted certificate.
     350        currentState.untrustedChecker.check(cert,
     351                                    Collections.<String>emptySet());
    348352
    349353        /* check that the signature algorithm is not disabled. */
  • trunk/openjdk/jdk/src/share/classes/sun/security/provider/certpath/ReverseState.java

    r278 r390  
    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 *
     
    9696    /* the checker used for revocation status */
    9797    public CrlRevocationChecker crlChecker;
     98   
     99    /* the untrusted certificates checker */
     100    UntrustedChecker untrustedChecker;
    98101
    99102    /* the trust anchor used to validate the path */
  • trunk/openjdk/jdk/src/share/classes/sun/security/provider/certpath/SunCertPathBuilder.java

    r278 r390  
    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 *
     
    305305            currentState.crlChecker =
    306306                new CrlRevocationChecker(null, buildParams, null, onlyEECert);
     307            currentState.untrustedChecker = new UntrustedChecker();
    307308            try {
    308309                depthFirstSearchReverse(null, currentState,
     
    351352        currentState.crlChecker
    352353            = new CrlRevocationChecker(null, buildParams, null, onlyEECert);
     354        currentState.untrustedChecker = new UntrustedChecker();
    353355
    354356        depthFirstSearchForward(targetSubjectDN, currentState,
     
    626628
    627629            /* recursively search for matching certs at next dN */
    628             depthFirstSearchForward(cert.getIssuerX500Principal(), nextState, builder,
    629                 adjList, certPathList);
     630            depthFirstSearchForward(cert.getIssuerX500Principal(),
     631                nextState, builder, adjList, certPathList);
    630632
    631633            /*
  • trunk/openjdk/jdk/src/share/classes/sun/security/ssl/AppOutputStream.java

    r309 r390  
    9191                int howmuch;
    9292                if (isFirstRecordOfThePayload && c.needToSplitPayload()) {
    93                     howmuch = Math.min(0x01, r.availableDataBytes());
     93                    howmuch = (len == 0) ? 0 : Math.min(
     94                        0x01, r.availableDataBytes());
    9495                } else {
    9596                    howmuch = Math.min(len, r.availableDataBytes());
  • trunk/openjdk/jdk/src/share/classes/sun/security/ssl/EngineArgs.java

    r278 r390  
    11/*
    2  * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    2626package sun.security.ssl;
    2727
    28 import javax.net.ssl.*;
    2928import java.nio.*;
    3029
     
    158157            appData[i].limit(appData[i].position() + amount);
    159158            netData.put(appData[i]);
     159            appRemaining -= amount;
    160160            spaceLeft -= amount;
    161161        }
     
    210210     * In the case of Exception, we want to reset the positions
    211211     * to appear as though no data has been consumed or produced.
     212     *
     213     * Currently, this method is only called as we are preparing to
     214     * fail out, and thus we don't need to actually recalculate
     215     * appRemaining.  If that assumption changes, that variable should
     216     * be updated here.
    212217     */
    213218    void resetPos() {
    214219        netData.position(netPos);
    215220        for (int i = offset; i < offset + len; i++) {
     221            // See comment above about recalculating appRemaining.
    216222            appData[i].position(appPoss[i]);
    217223        }
  • trunk/openjdk/jdk/src/share/classes/sun/security/ssl/SSLEngineImpl.java

    r309 r390  
    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 *
     
    735735             */
    736736            fatal(Alerts.alert_internal_error,
    737                 "problem unwrapping net record", e);
     737                "problem wrapping app data", e);
    738738            return null;  // make compiler happy
    739739        } finally {
  • trunk/openjdk/jdk/src/share/classes/sun/security/validator/SimpleValidator.java

    r278 r390  
    11/*
    2  * Copyright (c) 2002, 2009, 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 *
     
    4242
    4343import sun.security.provider.certpath.AlgorithmChecker;
     44import sun.security.provider.certpath.UntrustedChecker;
    4445
    4546/**
     
    130131            date = new Date();
    131132        }
     133       
     134        // create distrusted certificates checker
     135        UntrustedChecker untrustedChecker = new UntrustedChecker();
     136
    132137        // verify top down, starting at the certificate issued by
    133138        // the trust anchor
     
    135140            X509Certificate issuerCert = chain[i + 1];
    136141            X509Certificate cert = chain[i];
     142           
     143            // check untrusted certificate
     144            try {
     145                // Untrusted checker does not care about the unresolved
     146                // critical extensions.
     147                untrustedChecker.check(cert, Collections.<String>emptySet());
     148            } catch (CertPathValidatorException cpve) {
     149                throw new ValidatorException(
     150                    "Untrusted certificate: " + cert.getSubjectX500Principal(),
     151                    ValidatorException.T_UNTRUSTED_CERT, cert, cpve);
     152            }
    137153
    138154            // check certificate algorithm
  • trunk/openjdk/jdk/src/share/classes/sun/security/validator/ValidatorException.java

    r278 r390  
    11/*
    2  * Copyright (c) 2002, 2009, 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 *
     
    5959        "Certificate signature algorithm disabled";
    6060
     61    public final static Object T_UNTRUSTED_CERT =
     62        "Untrusted certificate";
     63
    6164    private Object type;
    6265    private X509Certificate cert;
  • trunk/openjdk/jdk/src/share/native/java/util/zip/zip_util.c

    r388 r390  
    11/*
    2  * Copyright (c) 1995, 2006, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
     
    451451    jint count = 0;
    452452    ptrdiff_t i;
    453     for (i = 0; i + CENHDR < end - beg; i += CENSIZE(beg + i))
     453    for (i = 0; i + CENHDR <= end - beg; i += CENSIZE(beg + i))
    454454        count++;
    455455    return count;
  • trunk/openjdk/jdk/src/share/native/sun/awt/image/jpeg/imageioJPEG.c

    r309 r390  
    11/*
    2  * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
  • trunk/openjdk/jdk/src/solaris/bin/java_md.c

    r309 r390  
    11/*
    2  * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
  • trunk/openjdk/jdk/src/windows/bin/java_md.c

    r346 r390  
    11/*
    2  * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
  • trunk/openjdk/jdk/src/windows/classes/java/net/TwoStacksPlainDatagramSocketImpl.java

    r309 r390  
    11/*
    2  * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
  • trunk/openjdk/jdk/src/windows/native/sun/windows/awt_FileDialog.cpp

    r309 r390  
    11/*
    2  * Copyright (c) 1996, 2007, Oracle and/or its affiliates. All rights reserved.
     2 * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
    33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44 *
Note: See TracChangeset for help on using the changeset viewer.