Merge jdk8-b29
authorlana
Mon, 05 Mar 2012 17:04:10 -0800
changeset 5136c5b882dce0fe
parent 5108 c7ff6d8dc90d
parent 5135 189207b31cd3
child 5137 46e0a0467a3c
child 5143 b6fbe0a78fbc
child 5160 c2f3fdce1398
child 5164 fb3a2cafc230
child 5179 8532efc112ea
child 5187 b1af41b86f9f
Merge
     1.1 --- a/make/Makefile	Thu Mar 01 12:23:25 2012 -0800
     1.2 +++ b/make/Makefile	Mon Mar 05 17:04:10 2012 -0800
     1.3 @@ -197,7 +197,7 @@
     1.4  #
     1.5  # 'all' target intro
     1.6  #
     1.7 -all:: 
     1.8 +all::
     1.9  	@$(ECHO) $(PLATFORM) $(ARCH) $(RELEASE) build started: $(shell $(DATE) '+%y-%m-%d %H:%M')
    1.10  
    1.11  # Just in case anyone uses this old name, same as 'build'
    1.12 @@ -234,7 +234,17 @@
    1.13  
    1.14  SUBDIRS       = tools java javax sun com
    1.15  SUBDIRS_tools = launchers
    1.16 -SUBDIRS_misc  = org sunw jpda mkdemo mksample
    1.17 +SUBDIRS_misc  = org sunw jpda
    1.18 +
    1.19 +# demos
    1.20 +ifndef NO_DEMOS
    1.21 +  SUBDIRS_misc += mkdemo
    1.22 +endif
    1.23 +
    1.24 +# samples
    1.25 +ifndef NO_SAMPLES
    1.26 +  SUBDIRS_misc += mksample
    1.27 +endif
    1.28  
    1.29  # Alternate classes implementation
    1.30  ifndef OPENJDK
    1.31 @@ -383,4 +393,3 @@
    1.32  .PHONY: all build clean clobber optimized debug fastdebug create_links \
    1.33  	import import_product import_fastdebug import_debug \
    1.34  	test test_run test_start test_clean test_summary
    1.35 -
     2.1 --- a/make/common/Release.gmk	Thu Mar 01 12:23:25 2012 -0800
     2.2 +++ b/make/common/Release.gmk	Mon Mar 05 17:04:10 2012 -0800
     2.3 @@ -234,7 +234,7 @@
     2.4  	 $(INITIAL_IMAGE_JRE) $(INITIAL_IMAGE_JDK) \
     2.5  	 trim-image-jre trim-image-jdk \
     2.6           identify-image-jre identify-image-jdk \
     2.7 -	 process-image-jre process-image-jdk sec-files sec-files-win jgss-files 
     2.8 +	 process-image-jre process-image-jdk sec-files sec-files-win jgss-files
     2.9  
    2.10  # Don't use these
    2.11  image-jre:: initial-image-jre trim-image-jre identify-image-jre process-image-jre
    2.12 @@ -496,7 +496,7 @@
    2.13  $(JDK_IMAGE_DIR)/sample/SAMPLES_LICENSE: $(SHARE_JDK_DOC_SRC)/SAMPLES_LICENSE
    2.14  	$(process-doc-file)
    2.15  
    2.16 -# JRE files 
    2.17 +# JRE files
    2.18  $(JRE_IMAGE_DIR)/%: $(SHARE_JRE_DOC_SRC)/%
    2.19  	$(process-doc-file)
    2.20  ifeq ($(PLATFORM), windows)
    2.21 @@ -1095,8 +1095,12 @@
    2.22  	@#
    2.23  	@# demo, include
    2.24  	@#
    2.25 +ifndef NO_DEMOS
    2.26  	$(CP) -r -f $(DEMODIR) $(JDK_IMAGE_DIR)
    2.27 +endif
    2.28 +ifndef NO_SAMPLES
    2.29  	$(CP) -r -f $(SAMPLEDIR) $(JDK_IMAGE_DIR)
    2.30 +endif
    2.31  	$(CP) -r $(INCLUDEDIR) $(JDK_IMAGE_DIR)
    2.32  	@#
    2.33  	@# Swing BeanInfo generation
    2.34 @@ -1359,4 +1363,3 @@
    2.35  
    2.36  # Force rule
    2.37  FRC:
    2.38 -
     3.1 --- a/make/common/shared/Sanity-Settings.gmk	Thu Mar 01 12:23:25 2012 -0800
     3.2 +++ b/make/common/shared/Sanity-Settings.gmk	Mon Mar 05 17:04:10 2012 -0800
     3.3 @@ -134,6 +134,8 @@
     3.4  ALL_SETTINGS+=$(call addOptionalSetting,PEDANTIC)
     3.5  ALL_SETTINGS+=$(call addOptionalSetting,DEV_ONLY)
     3.6  ALL_SETTINGS+=$(call addOptionalSetting,NO_DOCS)
     3.7 +ALL_SETTINGS+=$(call addOptionalSetting,NO_DEMOS)
     3.8 +ALL_SETTINGS+=$(call addOptionalSetting,NO_SAMPLES)
     3.9  ALL_SETTINGS+=$(call addOptionalSetting,NO_IMAGES)
    3.10  ALL_SETTINGS+=$(call addOptionalSetting,TOOLS_ONLY)
    3.11  ALL_SETTINGS+=$(call addOptionalSetting,INSANE)
    3.12 @@ -263,4 +265,3 @@
    3.13    ALL_SETTINGS+=$(call addAltSetting,PREVIOUS_JRE_FILE)
    3.14    ALL_SETTINGS+=$(call addAltSetting,PREVIOUS_RELEASE_IMAGE)
    3.15  endif
    3.16 -
     4.1 --- a/make/tools/src/build/tools/javazic/Mappings.java	Thu Mar 01 12:23:25 2012 -0800
     4.2 +++ b/make/tools/src/build/tools/javazic/Mappings.java	Mon Mar 05 17:04:10 2012 -0800
     4.3 @@ -1,5 +1,5 @@
     4.4  /*
     4.5 - * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
     4.6 + * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
     4.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4.8   *
     4.9   * This code is free software; you can redistribute it and/or modify it
    4.10 @@ -26,6 +26,7 @@
    4.11  package build.tools.javazic;
    4.12  
    4.13  import  java.util.ArrayList;
    4.14 +import  java.util.HashMap;
    4.15  import  java.util.LinkedList;
    4.16  import  java.util.List;
    4.17  import  java.util.Map;
    4.18 @@ -162,6 +163,20 @@
    4.19          for (String key : toBeRemoved) {
    4.20              aliases.remove(key);
    4.21          }
    4.22 +        // Eliminate any alias-to-alias mappings. For example, if
    4.23 +        // there are A->B and B->C, A->B is changed to A->C.
    4.24 +        Map<String, String> newMap = new HashMap<String, String>();
    4.25 +        for (String key : aliases.keySet()) {
    4.26 +            String realid = aliases.get(key);
    4.27 +            String leaf = realid;
    4.28 +            while (aliases.get(leaf) != null) {
    4.29 +                leaf = aliases.get(leaf);
    4.30 +            }
    4.31 +            if (!realid.equals(leaf)) {
    4.32 +                newMap.put(key, leaf);
    4.33 +            }
    4.34 +        }
    4.35 +        aliases.putAll(newMap);
    4.36      }
    4.37  
    4.38      Map<String,String> getAliases() {
     5.1 --- a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java	Thu Mar 01 12:23:25 2012 -0800
     5.2 +++ b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java	Mon Mar 05 17:04:10 2012 -0800
     5.3 @@ -55,7 +55,6 @@
     5.4  
     5.5  import java.awt.Font;
     5.6  import java.awt.Color;
     5.7 -import java.awt.event.KeyEvent;
     5.8  import java.awt.event.ActionEvent;
     5.9  
    5.10  import java.security.AccessController;
    5.11 @@ -523,6 +522,7 @@
    5.12          Object ScrollbarBackgroundColor = new DesktopProperty(
    5.13                                                         "win.scrollbar.backgroundColor",
    5.14                                                          table.get("scrollbar"));
    5.15 +        Object buttonFocusColor = new FocusColorProperty();
    5.16  
    5.17          Object TextBackground         = new XPColorValue(Part.EP_EDIT, null, Prop.FILLCOLOR,
    5.18                                                           WindowBackgroundColor);
    5.19 @@ -629,7 +629,7 @@
    5.20              "Button.highlight", ControlHighlightColor,
    5.21              "Button.disabledForeground", InactiveTextColor,
    5.22              "Button.disabledShadow", ControlHighlightColor,
    5.23 -            "Button.focus", black,
    5.24 +            "Button.focus", buttonFocusColor,
    5.25              "Button.dashedRectGapX", new XPValue(Integer.valueOf(3), Integer.valueOf(5)),
    5.26              "Button.dashedRectGapY", new XPValue(Integer.valueOf(3), Integer.valueOf(4)),
    5.27              "Button.dashedRectGapWidth", new XPValue(Integer.valueOf(6), Integer.valueOf(10)),
    5.28 @@ -652,7 +652,7 @@
    5.29              "CheckBox.darkShadow", ControlDarkShadowColor,
    5.30              "CheckBox.light", ControlLightColor,
    5.31              "CheckBox.highlight", ControlHighlightColor,
    5.32 -            "CheckBox.focus", black,
    5.33 +            "CheckBox.focus", buttonFocusColor,
    5.34              "CheckBox.focusInputMap",
    5.35                 new UIDefaults.LazyInputMap(new Object[] {
    5.36                              "SPACE", "pressed",
    5.37 @@ -1007,7 +1007,7 @@
    5.38              "RadioButton.darkShadow", ControlDarkShadowColor,
    5.39              "RadioButton.light", ControlLightColor,
    5.40              "RadioButton.highlight", ControlHighlightColor,
    5.41 -            "RadioButton.focus", black,
    5.42 +            "RadioButton.focus", buttonFocusColor,
    5.43              "RadioButton.focusInputMap",
    5.44                 new UIDefaults.LazyInputMap(new Object[] {
    5.45                            "SPACE", "pressed",
    5.46 @@ -2614,4 +2614,19 @@
    5.47          }
    5.48      }
    5.49  
    5.50 +    private static class FocusColorProperty extends DesktopProperty {
    5.51 +        public FocusColorProperty () {
    5.52 +            // Fallback value is never used bacause of the configureValue method doesn't return null
    5.53 +            super("win.3d.backgroundColor", Color.BLACK);
    5.54 +        }
    5.55 +
    5.56 +        @Override
    5.57 +        protected Object configureValue(Object value) {
    5.58 +            if (! ((Boolean)Toolkit.getDefaultToolkit().getDesktopProperty("win.highContrast.on")).booleanValue()){
    5.59 +                return Color.BLACK;
    5.60 +            }
    5.61 +            return Color.BLACK.equals(value) ? Color.WHITE : Color.BLACK;
    5.62 +        }
    5.63 +    }
    5.64 +
    5.65  }
     6.1 --- a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsRadioButtonUI.java	Thu Mar 01 12:23:25 2012 -0800
     6.2 +++ b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsRadioButtonUI.java	Mon Mar 05 17:04:10 2012 -0800
     6.3 @@ -89,6 +89,11 @@
     6.4          }
     6.5      }
     6.6  
     6.7 +    protected void uninstallDefaults(AbstractButton b) {
     6.8 +        super.uninstallDefaults(b);
     6.9 +        initialized = false;
    6.10 +    }
    6.11 +
    6.12      protected Color getFocusColor() {
    6.13          return focusColor;
    6.14      }
     7.1 --- a/src/share/classes/java/awt/Component.java	Thu Mar 01 12:23:25 2012 -0800
     7.2 +++ b/src/share/classes/java/awt/Component.java	Mon Mar 05 17:04:10 2012 -0800
     7.3 @@ -10070,11 +10070,12 @@
     7.4          }
     7.5          Window window = getContainingWindow();
     7.6          if (window != null) {
     7.7 -            if (!window.hasHeavyweightDescendants() || !window.hasLightweightDescendants()) {
     7.8 +            if (!window.hasHeavyweightDescendants() || !window.hasLightweightDescendants() || window.isDisposing()) {
     7.9                  if (mixingLog.isLoggable(PlatformLogger.FINE)) {
    7.10                      mixingLog.fine("containing window = " + window +
    7.11                              "; has h/w descendants = " + window.hasHeavyweightDescendants() +
    7.12 -                            "; has l/w descendants = " + window.hasLightweightDescendants());
    7.13 +                            "; has l/w descendants = " + window.hasLightweightDescendants() +
    7.14 +                            "; disposing = " + window.isDisposing());
    7.15                  }
    7.16                  return false;
    7.17              }
     8.1 --- a/src/share/classes/java/awt/Window.java	Thu Mar 01 12:23:25 2012 -0800
     8.2 +++ b/src/share/classes/java/awt/Window.java	Mon Mar 05 17:04:10 2012 -0800
     8.3 @@ -226,6 +226,7 @@
     8.4      static boolean systemSyncLWRequests = false;
     8.5      boolean     syncLWRequests = false;
     8.6      transient boolean beforeFirstShow = true;
     8.7 +    private transient boolean disposing = false;
     8.8  
     8.9      static final int OPENED = 0x01;
    8.10  
    8.11 @@ -1162,36 +1163,41 @@
    8.12      void doDispose() {
    8.13      class DisposeAction implements Runnable {
    8.14          public void run() {
    8.15 -            // Check if this window is the fullscreen window for the
    8.16 -            // device. Exit the fullscreen mode prior to disposing
    8.17 -            // of the window if that's the case.
    8.18 -            GraphicsDevice gd = getGraphicsConfiguration().getDevice();
    8.19 -            if (gd.getFullScreenWindow() == Window.this) {
    8.20 -                gd.setFullScreenWindow(null);
    8.21 +            disposing = true;
    8.22 +            try {
    8.23 +                // Check if this window is the fullscreen window for the
    8.24 +                // device. Exit the fullscreen mode prior to disposing
    8.25 +                // of the window if that's the case.
    8.26 +                GraphicsDevice gd = getGraphicsConfiguration().getDevice();
    8.27 +                if (gd.getFullScreenWindow() == Window.this) {
    8.28 +                    gd.setFullScreenWindow(null);
    8.29 +                }
    8.30 +
    8.31 +                Object[] ownedWindowArray;
    8.32 +                synchronized(ownedWindowList) {
    8.33 +                    ownedWindowArray = new Object[ownedWindowList.size()];
    8.34 +                    ownedWindowList.copyInto(ownedWindowArray);
    8.35 +                }
    8.36 +                for (int i = 0; i < ownedWindowArray.length; i++) {
    8.37 +                    Window child = (Window) (((WeakReference)
    8.38 +                                   (ownedWindowArray[i])).get());
    8.39 +                    if (child != null) {
    8.40 +                        child.disposeImpl();
    8.41 +                    }
    8.42 +                }
    8.43 +                hide();
    8.44 +                beforeFirstShow = true;
    8.45 +                removeNotify();
    8.46 +                synchronized (inputContextLock) {
    8.47 +                    if (inputContext != null) {
    8.48 +                        inputContext.dispose();
    8.49 +                        inputContext = null;
    8.50 +                    }
    8.51 +                }
    8.52 +                clearCurrentFocusCycleRootOnHide();
    8.53 +            } finally {
    8.54 +                disposing = false;
    8.55              }
    8.56 -
    8.57 -            Object[] ownedWindowArray;
    8.58 -            synchronized(ownedWindowList) {
    8.59 -                ownedWindowArray = new Object[ownedWindowList.size()];
    8.60 -                ownedWindowList.copyInto(ownedWindowArray);
    8.61 -            }
    8.62 -            for (int i = 0; i < ownedWindowArray.length; i++) {
    8.63 -                Window child = (Window) (((WeakReference)
    8.64 -                               (ownedWindowArray[i])).get());
    8.65 -                if (child != null) {
    8.66 -                    child.disposeImpl();
    8.67 -                }
    8.68 -            }
    8.69 -            hide();
    8.70 -            beforeFirstShow = true;
    8.71 -            removeNotify();
    8.72 -            synchronized (inputContextLock) {
    8.73 -                if (inputContext != null) {
    8.74 -                    inputContext.dispose();
    8.75 -                    inputContext = null;
    8.76 -                }
    8.77 -            }
    8.78 -            clearCurrentFocusCycleRootOnHide();
    8.79          }
    8.80      }
    8.81          DisposeAction action = new DisposeAction();
    8.82 @@ -2734,6 +2740,10 @@
    8.83          return visible;
    8.84      }
    8.85  
    8.86 +    boolean isDisposing() {
    8.87 +        return disposing;
    8.88 +    }
    8.89 +
    8.90      /**
    8.91       * @deprecated As of J2SE 1.4, replaced by
    8.92       * {@link Component#applyComponentOrientation Component.applyComponentOrientation}.
     9.1 --- a/src/share/classes/java/lang/reflect/Executable.java	Thu Mar 01 12:23:25 2012 -0800
     9.2 +++ b/src/share/classes/java/lang/reflect/Executable.java	Mon Mar 05 17:04:10 2012 -0800
     9.3 @@ -180,7 +180,7 @@
     9.4  
     9.5      /**
     9.6       * Returns the {@code Class} object representing the class or interface
     9.7 -     * that declares the method represented by this executable object.
     9.8 +     * that declares the executable represented by this object.
     9.9       */
    9.10      public abstract Class<?> getDeclaringClass();
    9.11  
    9.12 @@ -215,18 +215,18 @@
    9.13       * Returns an array of {@code Class} objects that represent the formal
    9.14       * parameter types, in declaration order, of the executable
    9.15       * represented by this object.  Returns an array of length
    9.16 -     * 0 if the underlying method takes no parameters.
    9.17 +     * 0 if the underlying executable takes no parameters.
    9.18       *
    9.19 -     * @return the parameter types for the method this object
    9.20 +     * @return the parameter types for the executable this object
    9.21       * represents
    9.22       */
    9.23      public abstract Class<?>[] getParameterTypes();
    9.24  
    9.25      /**
    9.26       * Returns an array of {@code Type} objects that represent the formal
    9.27 -     * parameter types, in declaration order, of the method represented by
    9.28 -     * this executable object. Returns an array of length 0 if the
    9.29 -     * underlying method takes no parameters.
    9.30 +     * parameter types, in declaration order, of the executable represented by
    9.31 +     * this object. Returns an array of length 0 if the
    9.32 +     * underlying executable takes no parameters.
    9.33       *
    9.34       * <p>If a formal parameter type is a parameterized type,
    9.35       * the {@code Type} object returned for it must accurately reflect
    9.36 @@ -236,16 +236,16 @@
    9.37       * type, it is created. Otherwise, it is resolved.
    9.38       *
    9.39       * @return an array of {@code Type}s that represent the formal
    9.40 -     *     parameter types of the underlying method, in declaration order
    9.41 +     *     parameter types of the underlying executable, in declaration order
    9.42       * @throws GenericSignatureFormatError
    9.43       *     if the generic method signature does not conform to the format
    9.44       *     specified in
    9.45       *     <cite>The Java&trade; Virtual Machine Specification</cite>
    9.46       * @throws TypeNotPresentException if any of the parameter
    9.47 -     *     types of the underlying method refers to a non-existent type
    9.48 +     *     types of the underlying executable refers to a non-existent type
    9.49       *     declaration
    9.50       * @throws MalformedParameterizedTypeException if any of
    9.51 -     *     the underlying method's parameter types refer to a parameterized
    9.52 +     *     the underlying executable's parameter types refer to a parameterized
    9.53       *     type that cannot be instantiated for any reason
    9.54       */
    9.55      public Type[] getGenericParameterTypes() {
    9.56 @@ -277,15 +277,15 @@
    9.57       * type, it is created. Otherwise, it is resolved.
    9.58       *
    9.59       * @return an array of Types that represent the exception types
    9.60 -     *     thrown by the underlying method
    9.61 +     *     thrown by the underlying executable
    9.62       * @throws GenericSignatureFormatError
    9.63       *     if the generic method signature does not conform to the format
    9.64       *     specified in
    9.65       *     <cite>The Java&trade; Virtual Machine Specification</cite>
    9.66 -     * @throws TypeNotPresentException if the underlying method's
    9.67 +     * @throws TypeNotPresentException if the underlying executable's
    9.68       *     {@code throws} clause refers to a non-existent type declaration
    9.69       * @throws MalformedParameterizedTypeException if
    9.70 -     *     the underlying method's {@code throws} clause refers to a
    9.71 +     *     the underlying executable's {@code throws} clause refers to a
    9.72       *     parameterized type that cannot be instantiated for any reason
    9.73       */
    9.74      public Type[] getGenericExceptionTypes() {
    9.75 @@ -330,7 +330,7 @@
    9.76       * Returns an array of arrays that represent the annotations on
    9.77       * the formal parameters, in declaration order, of the executable
    9.78       * represented by this object. (Returns an array of length zero if
    9.79 -     * the underlying method is parameterless.  If the executable has
    9.80 +     * the underlying executable is parameterless.  If the executable has
    9.81       * one or more parameters, a nested array of length zero is
    9.82       * returned for each parameter with no annotations.) The
    9.83       * annotation objects contained in the returned arrays are
    9.84 @@ -339,7 +339,7 @@
    9.85       * to other callers.
    9.86       *
    9.87       * @return an array of arrays that represent the annotations on the formal
    9.88 -     *    parameters, in declaration order, of the exectuable represented by this
    9.89 +     *    parameters, in declaration order, of the executable represented by this
    9.90       *    object
    9.91       */
    9.92      public abstract Annotation[][] getParameterAnnotations();
    10.1 --- a/src/share/classes/java/util/Collections.java	Thu Mar 01 12:23:25 2012 -0800
    10.2 +++ b/src/share/classes/java/util/Collections.java	Mon Mar 05 17:04:10 2012 -0800
    10.3 @@ -1,5 +1,5 @@
    10.4  /*
    10.5 - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
    10.6 + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
    10.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    10.8   *
    10.9   * This code is free software; you can redistribute it and/or modify it
   10.10 @@ -1489,6 +1489,8 @@
   10.11                  }
   10.12                  public int hashCode()    {return e.hashCode();}
   10.13                  public boolean equals(Object o) {
   10.14 +                    if (this == o)
   10.15 +                        return true;
   10.16                      if (!(o instanceof Map.Entry))
   10.17                          return false;
   10.18                      Map.Entry t = (Map.Entry)o;
   10.19 @@ -1709,6 +1711,8 @@
   10.20          }
   10.21  
   10.22          public boolean equals(Object o) {
   10.23 +            if (this == o)
   10.24 +                return true;
   10.25              synchronized (mutex) {return c.equals(o);}
   10.26          }
   10.27          public int hashCode() {
   10.28 @@ -1863,6 +1867,8 @@
   10.29          }
   10.30  
   10.31          public boolean equals(Object o) {
   10.32 +            if (this == o)
   10.33 +                return true;
   10.34              synchronized (mutex) {return list.equals(o);}
   10.35          }
   10.36          public int hashCode() {
   10.37 @@ -2073,6 +2079,8 @@
   10.38          }
   10.39  
   10.40          public boolean equals(Object o) {
   10.41 +            if (this == o)
   10.42 +                return true;
   10.43              synchronized (mutex) {return m.equals(o);}
   10.44          }
   10.45          public int hashCode() {
    11.1 --- a/src/share/classes/javax/swing/JViewport.java	Thu Mar 01 12:23:25 2012 -0800
    11.2 +++ b/src/share/classes/javax/swing/JViewport.java	Mon Mar 05 17:04:10 2012 -0800
    11.3 @@ -27,9 +27,7 @@
    11.4  
    11.5  import java.awt.*;
    11.6  import java.awt.event.*;
    11.7 -import java.awt.image.VolatileImage;
    11.8  import java.awt.peer.ComponentPeer;
    11.9 -import java.applet.Applet;
   11.10  import java.beans.Transient;
   11.11  import javax.swing.plaf.ViewportUI;
   11.12  
   11.13 @@ -265,6 +263,14 @@
   11.14       */
   11.15      private boolean hasHadValidView;
   11.16  
   11.17 +    /**
   11.18 +     * When view is changed we have to synchronize scrollbar values
   11.19 +     * with viewport (see the BasicScrollPaneUI#syncScrollPaneWithViewport method).
   11.20 +     * This flag allows to invoke that method while ScrollPaneLayout#layoutContainer
   11.21 +     * is running.
   11.22 +     */
   11.23 +    private boolean viewChanged;
   11.24 +
   11.25      /** Creates a <code>JViewport</code>. */
   11.26      public JViewport() {
   11.27          super();
   11.28 @@ -830,7 +836,9 @@
   11.29              backingStoreImage = null;
   11.30          }
   11.31          super.reshape(x, y, w, h);
   11.32 -        if (sizeChanged) {
   11.33 +        if (sizeChanged || viewChanged) {
   11.34 +            viewChanged = false;
   11.35 +
   11.36              fireStateChanged();
   11.37          }
   11.38      }
   11.39 @@ -967,6 +975,8 @@
   11.40              hasHadValidView = true;
   11.41          }
   11.42  
   11.43 +        viewChanged = true;
   11.44 +
   11.45          revalidate();
   11.46          repaint();
   11.47      }
    12.1 --- a/src/share/classes/sun/font/SunFontManager.java	Thu Mar 01 12:23:25 2012 -0800
    12.2 +++ b/src/share/classes/sun/font/SunFontManager.java	Mon Mar 05 17:04:10 2012 -0800
    12.3 @@ -2619,10 +2619,6 @@
    12.4          physicalFonts.remove(oldFont.fullName);
    12.5          fullNameToFont.remove(oldFont.fullName.toLowerCase(Locale.ENGLISH));
    12.6          FontFamily.remove(oldFont);
    12.7 -        if (oldFont instanceof FileFont) {
    12.8 -            ((FileFont)oldFont).deregisterFontAndClearStrikeCache();
    12.9 -        }
   12.10 -
   12.11          if (localeFullNamesToFont != null) {
   12.12              Map.Entry[] mapEntries =
   12.13                  (Map.Entry[])localeFullNamesToFont.entrySet().
    13.1 --- a/src/share/classes/sun/management/Agent.java	Thu Mar 01 12:23:25 2012 -0800
    13.2 +++ b/src/share/classes/sun/management/Agent.java	Mon Mar 05 17:04:10 2012 -0800
    13.3 @@ -1,5 +1,5 @@
    13.4  /*
    13.5 - * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
    13.6 + * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
    13.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    13.8   *
    13.9   * This code is free software; you can redistribute it and/or modify it
   13.10 @@ -25,30 +25,34 @@
   13.11  
   13.12  package sun.management;
   13.13  
   13.14 +import java.io.BufferedInputStream;
   13.15  import java.io.File;
   13.16 -import java.io.InputStream;
   13.17  import java.io.FileInputStream;
   13.18 -import java.io.BufferedInputStream;
   13.19  import java.io.FileNotFoundException;
   13.20  import java.io.IOException;
   13.21 +import java.io.InputStream;
   13.22 +
   13.23  import java.lang.reflect.InvocationTargetException;
   13.24 +import java.lang.reflect.Method;
   13.25 +import java.lang.management.ManagementFactory;
   13.26 +
   13.27  import java.text.MessageFormat;
   13.28 +
   13.29 +import java.util.MissingResourceException;
   13.30  import java.util.Properties;
   13.31  import java.util.ResourceBundle;
   13.32 -import java.util.MissingResourceException;
   13.33 -import java.lang.management.ManagementFactory;
   13.34 -import java.lang.reflect.Method;
   13.35  
   13.36  import javax.management.remote.JMXConnectorServer;
   13.37  
   13.38 +import static sun.management.AgentConfigurationError.*;
   13.39  import sun.management.jmxremote.ConnectorBootstrap;
   13.40 -import static sun.management.AgentConfigurationError.*;
   13.41  import sun.misc.VMSupport;
   13.42  
   13.43  /**
   13.44   * This Agent is started by the VM when -Dcom.sun.management.snmp
   13.45   * or -Dcom.sun.management.jmxremote is set. This class will be
   13.46 - * loaded by the system class loader.
   13.47 + * loaded by the system class loader. Also jmx framework could
   13.48 + * be started by jcmd
   13.49   */
   13.50  public class Agent {
   13.51      // management properties
   13.52 @@ -69,7 +73,33 @@
   13.53          "com.sun.management.jmxremote.localConnectorAddress";
   13.54  
   13.55      private static final String SNMP_ADAPTOR_BOOTSTRAP_CLASS_NAME =
   13.56 -            "sun.management.snmp.AdaptorBootstrap";
   13.57 +        "sun.management.snmp.AdaptorBootstrap";
   13.58 +
   13.59 +    // The only active agent allowed
   13.60 +    private static JMXConnectorServer jmxServer = null;
   13.61 +
   13.62 +    // Parse string com.sun.management.prop=xxx,com.sun.management.prop=yyyy
   13.63 +    // and return property set if args is null or empty
   13.64 +    // return empty property set
   13.65 +    private static Properties parseString(String args){
   13.66 +        Properties argProps = new Properties();
   13.67 +        if (args != null) {
   13.68 +           for (String option : args.split(",")) {
   13.69 +               String s[] = option.split("=", 2);
   13.70 +               String name = s[0].trim();
   13.71 +               String value = (s.length > 1) ? s[1].trim() : "";
   13.72 +
   13.73 +               if (!name.startsWith("com.sun.management.")) {
   13.74 +                  error(INVALID_OPTION, name);
   13.75 +               }
   13.76 +
   13.77 +               argProps.setProperty(name, value);
   13.78 +           }
   13.79 +        }
   13.80 +
   13.81 +        return argProps;
   13.82 +    }
   13.83 +
   13.84  
   13.85      // invoked by -javaagent or -Dcom.sun.management.agent.class
   13.86      public static void premain(String args) throws Exception {
   13.87 @@ -82,37 +112,104 @@
   13.88              args = JMXREMOTE;           // default to local management
   13.89          }
   13.90  
   13.91 -        // Parse agent options into properties
   13.92 +        Properties arg_props = parseString(args);
   13.93  
   13.94 -        Properties arg_props = new Properties();
   13.95 -        if (args != null) {
   13.96 -            String[] options = args.split(",");
   13.97 -            for (int i=0; i<options.length; i++) {
   13.98 -                String[] option = options[i].split("=");
   13.99 -                if (option.length >= 1 && option.length <= 2) {
  13.100 -                    String name = option[0];
  13.101 -                    String value = (option.length == 1) ? "" : option[1];
  13.102 -                    if (name != null && name.length() > 0) {
  13.103 +        // Read properties from the config file
  13.104 +         Properties config_props = new Properties();
  13.105 +         String fname = arg_props.getProperty(CONFIG_FILE);
  13.106 +         readConfiguration(fname, config_props);
  13.107  
  13.108 -                        // Assume that any com.sun.management.* options are okay
  13.109 -                        if (name.startsWith("com.sun.management.")) {
  13.110 -                            arg_props.setProperty(name, value);
  13.111 -                        } else {
  13.112 -                            error(INVALID_OPTION, name);
  13.113 -                        }
  13.114 -                    }
  13.115 -                }
  13.116 +         // Arguments override config file
  13.117 +         config_props.putAll(arg_props);
  13.118 +         startAgent(config_props);
  13.119 +    }
  13.120 +
  13.121 +    // jcmd ManagementAgent.start_local entry point
  13.122 +    // Also called due to command-line via startAgent()
  13.123 +    private static synchronized void startLocalManagementAgent(){
  13.124 +        Properties agentProps = VMSupport.getAgentProperties();
  13.125 +
  13.126 +        // start local connector if not started
  13.127 +        if (agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP) == null) {
  13.128 +            JMXConnectorServer cs = ConnectorBootstrap.startLocalConnectorServer();
  13.129 +            String address = cs.getAddress().toString();
  13.130 +            // Add the local connector address to the agent properties
  13.131 +            agentProps.put(LOCAL_CONNECTOR_ADDRESS_PROP, address);
  13.132 +
  13.133 +            try {
  13.134 +                // export the address to the instrumentation buffer
  13.135 +                ConnectorAddressLink.export(address);
  13.136 +            } catch (Exception x) {
  13.137 +                // Connector server started but unable to export address
  13.138 +                // to instrumentation buffer - non-fatal error.
  13.139 +                warning(EXPORT_ADDRESS_FAILED, x.getMessage());
  13.140              }
  13.141          }
  13.142 +    }
  13.143  
  13.144 -        // Read properties from the config file
  13.145 -        Properties config_props = new Properties();
  13.146 -        String fname = arg_props.getProperty(CONFIG_FILE);
  13.147 -        readConfiguration(fname, config_props);
  13.148 +    // jcmd ManagementAgent.start entry point
  13.149 +    // This method starts the remote JMX agent and starts neither
  13.150 +    // the local JMX agent nor the SNMP agent
  13.151 +    // @see #startLocalManagementAgent and also @see #startAgent.
  13.152 +    private static synchronized void startRemoteManagementAgent(String args) throws Exception {
  13.153 +        if (jmxServer != null) {
  13.154 +            throw new RuntimeException(getText(INVALID_STATE, "Agent already started"));
  13.155 +        }
  13.156  
  13.157 -        // Arguments override config file
  13.158 -        config_props.putAll(arg_props);
  13.159 -        startAgent(config_props);
  13.160 +        Properties argProps    = parseString(args);
  13.161 +        Properties configProps = new Properties();
  13.162 +
  13.163 +        // Load the management properties from the config file
  13.164 +        // if config file is not specified readConfiguration implicitly
  13.165 +        // reads <java.home>/lib/management/management.properties
  13.166 +
  13.167 +        String fname = System.getProperty(CONFIG_FILE);
  13.168 +        readConfiguration(fname, configProps);
  13.169 +
  13.170 +        // management properties can be overridden by system properties
  13.171 +        // which take precedence
  13.172 +        configProps.putAll(System.getProperties());
  13.173 +
  13.174 +        // if user specifies config file into command line for either
  13.175 +        // jcmd utilities or attach command it overrides properties set in
  13.176 +        // command line at the time of VM start
  13.177 +        String fnameUser = argProps.getProperty(CONFIG_FILE);
  13.178 +        if (fnameUser != null) {
  13.179 +            readConfiguration(fnameUser, configProps);
  13.180 +        }
  13.181 +
  13.182 +        // arguments specified in command line of jcmd utilities
  13.183 +        // override both system properties and one set by config file
  13.184 +        // specified in jcmd command line
  13.185 +        configProps.putAll(argProps);
  13.186 +
  13.187 +        // jcmd doesn't allow to change ThreadContentionMonitoring, but user
  13.188 +        // can specify this property inside config file, so enable optional
  13.189 +        // monitoring functionality if this property is set
  13.190 +        final String enableThreadContentionMonitoring =
  13.191 +            configProps.getProperty(ENABLE_THREAD_CONTENTION_MONITORING);
  13.192 +
  13.193 +        if (enableThreadContentionMonitoring != null) {
  13.194 +            ManagementFactory.getThreadMXBean().
  13.195 +                setThreadContentionMonitoringEnabled(true);
  13.196 +        }
  13.197 +
  13.198 +        String jmxremotePort = configProps.getProperty(JMXREMOTE_PORT);
  13.199 +        if (jmxremotePort != null) {
  13.200 +            jmxServer = ConnectorBootstrap.
  13.201 +                           startRemoteConnectorServer(jmxremotePort, configProps);
  13.202 +        }
  13.203 +    }
  13.204 +
  13.205 +    private static synchronized void stopRemoteManagementAgent() throws Exception {
  13.206 +        if (jmxServer != null) {
  13.207 +            ConnectorBootstrap.unexportRegistry();
  13.208 +
  13.209 +            // Attempt to stop already stopped agent
  13.210 +            // Don't cause any errors.
  13.211 +            jmxServer.stop();
  13.212 +            jmxServer = null;
  13.213 +        }
  13.214      }
  13.215  
  13.216      private static void startAgent(Properties props) throws Exception {
  13.217 @@ -130,7 +227,7 @@
  13.218  
  13.219          try {
  13.220              if (snmpPort != null) {
  13.221 -                loadSnmpAgent(snmpPort, props);
  13.222 +               loadSnmpAgent(snmpPort, props);
  13.223              }
  13.224  
  13.225              /*
  13.226 @@ -142,31 +239,14 @@
  13.227               * of this "local" server is exported as a counter to the jstat
  13.228               * instrumentation buffer.
  13.229               */
  13.230 -            if (jmxremote != null || jmxremotePort != null) {
  13.231 +             if (jmxremote != null || jmxremotePort != null) {
  13.232                  if (jmxremotePort != null) {
  13.233 -                    ConnectorBootstrap.initialize(jmxremotePort, props);
  13.234 +                   jmxServer = ConnectorBootstrap.
  13.235 +                               startRemoteConnectorServer(jmxremotePort, props);
  13.236                  }
  13.237 +                startLocalManagementAgent();
  13.238 +             }
  13.239  
  13.240 -                Properties agentProps = VMSupport.getAgentProperties();
  13.241 -                // start local connector if not started
  13.242 -                // System.out.println("local address : " +
  13.243 -                  //     agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP));
  13.244 -                if (agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP) == null) {
  13.245 -                    JMXConnectorServer cs = ConnectorBootstrap.startLocalConnectorServer();
  13.246 -                    String address = cs.getAddress().toString();
  13.247 -                    // Add the local connector address to the agent properties
  13.248 -                    agentProps.put(LOCAL_CONNECTOR_ADDRESS_PROP, address);
  13.249 -
  13.250 -                    try {
  13.251 -                        // export the address to the instrumentation buffer
  13.252 -                        ConnectorAddressLink.export(address);
  13.253 -                    } catch (Exception x) {
  13.254 -                        // Connector server started but unable to export address
  13.255 -                        // to instrumentation buffer - non-fatal error.
  13.256 -                        warning(EXPORT_ADDRESS_FAILED, x.getMessage());
  13.257 -                    }
  13.258 -                }
  13.259 -            }
  13.260          } catch (AgentConfigurationError e) {
  13.261              error(e.getError(), e.getParams());
  13.262          } catch (Exception e) {
  13.263 @@ -187,9 +267,9 @@
  13.264          props.putAll(System.getProperties());
  13.265  
  13.266          return props;
  13.267 -    }
  13.268 +   }
  13.269  
  13.270 -    public static synchronized Properties getManagementProperties() {
  13.271 +   public static synchronized Properties getManagementProperties() {
  13.272          if (mgmtProps == null) {
  13.273              String configFile = System.getProperty(CONFIG_FILE);
  13.274              String snmpPort = System.getProperty(SNMP_PORT);
    14.1 --- a/src/share/classes/sun/management/AgentConfigurationError.java	Thu Mar 01 12:23:25 2012 -0800
    14.2 +++ b/src/share/classes/sun/management/AgentConfigurationError.java	Mon Mar 05 17:04:10 2012 -0800
    14.3 @@ -1,5 +1,5 @@
    14.4  /*
    14.5 - * Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved.
    14.6 + * Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
    14.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    14.8   *
    14.9   * This code is free software; you can redistribute it and/or modify it
   14.10 @@ -53,6 +53,8 @@
   14.11          "agent.err.invalid.agentclass";
   14.12      public static final String INVALID_JMXREMOTE_PORT =
   14.13          "agent.err.invalid.jmxremote.port";
   14.14 +    public static final String INVALID_JMXREMOTE_RMI_PORT =
   14.15 +        "agent.err.invalid.jmxremote.rmi.port";
   14.16      public static final String PASSWORD_FILE_NOT_SET =
   14.17          "agent.err.password.file.notset";
   14.18      public static final String PASSWORD_FILE_NOT_READABLE =
   14.19 @@ -105,6 +107,8 @@
   14.20          "agent.err.snmp.adaptor.start.failed";
   14.21      public static final String SNMP_MIB_INIT_FAILED =
   14.22          "agent.err.snmp.mib.init.failed";
   14.23 +    public static final String INVALID_STATE =
   14.24 +        "agent.err.invalid.state";
   14.25  
   14.26      private final String error;
   14.27      private final String[] params;
    15.1 --- a/src/share/classes/sun/management/jmxremote/ConnectorBootstrap.java	Thu Mar 01 12:23:25 2012 -0800
    15.2 +++ b/src/share/classes/sun/management/jmxremote/ConnectorBootstrap.java	Mon Mar 05 17:04:10 2012 -0800
    15.3 @@ -1,5 +1,5 @@
    15.4  /*
    15.5 - * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
    15.6 + * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
    15.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    15.8   *
    15.9   * This code is free software; you can redistribute it and/or modify it
   15.10 @@ -28,25 +28,22 @@
   15.11  import java.io.BufferedInputStream;
   15.12  import java.io.File;
   15.13  import java.io.FileInputStream;
   15.14 +import java.io.IOException;
   15.15  import java.io.InputStream;
   15.16 -import java.io.IOException;
   15.17 -
   15.18 +import java.lang.management.ManagementFactory;
   15.19  import java.net.InetAddress;
   15.20  import java.net.MalformedURLException;
   15.21  import java.net.UnknownHostException;
   15.22 -
   15.23  import java.rmi.NoSuchObjectException;
   15.24  import java.rmi.Remote;
   15.25  import java.rmi.RemoteException;
   15.26  import java.rmi.registry.Registry;
   15.27 -import java.rmi.server.RemoteObject;
   15.28  import java.rmi.server.RMIClientSocketFactory;
   15.29  import java.rmi.server.RMIServerSocketFactory;
   15.30 +import java.rmi.server.RemoteObject;
   15.31  import java.rmi.server.UnicastRemoteObject;
   15.32 -
   15.33  import java.security.KeyStore;
   15.34  import java.security.Principal;
   15.35 -
   15.36  import java.util.HashMap;
   15.37  import java.util.HashSet;
   15.38  import java.util.Iterator;
   15.39 @@ -55,35 +52,31 @@
   15.40  import java.util.Set;
   15.41  import java.util.StringTokenizer;
   15.42  
   15.43 -import java.lang.management.ManagementFactory;
   15.44 -
   15.45 -import javax.net.ssl.*;
   15.46 -
   15.47  import javax.management.MBeanServer;
   15.48  import javax.management.remote.JMXAuthenticator;
   15.49  import javax.management.remote.JMXConnectorServer;
   15.50  import javax.management.remote.JMXConnectorServerFactory;
   15.51  import javax.management.remote.JMXServiceURL;
   15.52  import javax.management.remote.rmi.RMIConnectorServer;
   15.53 -
   15.54 +import javax.net.ssl.KeyManagerFactory;
   15.55 +import javax.net.ssl.SSLContext;
   15.56 +import javax.net.ssl.TrustManagerFactory;
   15.57  import javax.rmi.ssl.SslRMIClientSocketFactory;
   15.58  import javax.rmi.ssl.SslRMIServerSocketFactory;
   15.59 -
   15.60  import javax.security.auth.Subject;
   15.61  
   15.62 -import sun.rmi.server.UnicastRef;
   15.63 -import sun.rmi.server.UnicastServerRef;
   15.64 -import sun.rmi.server.UnicastServerRef2;
   15.65 +import com.sun.jmx.remote.internal.RMIExporter;
   15.66 +import com.sun.jmx.remote.security.JMXPluggableAuthenticator;
   15.67 +import com.sun.jmx.remote.util.ClassLogger;
   15.68  
   15.69  import sun.management.Agent;
   15.70  import sun.management.AgentConfigurationError;
   15.71  import static sun.management.AgentConfigurationError.*;
   15.72  import sun.management.ConnectorAddressLink;
   15.73  import sun.management.FileSystem;
   15.74 -import com.sun.jmx.remote.util.ClassLogger;
   15.75 -
   15.76 -import com.sun.jmx.remote.internal.RMIExporter;
   15.77 -import com.sun.jmx.remote.security.JMXPluggableAuthenticator;
   15.78 +import sun.rmi.server.UnicastRef;
   15.79 +import sun.rmi.server.UnicastServerRef;
   15.80 +import sun.rmi.server.UnicastServerRef2;
   15.81  
   15.82  /**
   15.83   * This class initializes and starts the RMIConnectorServer for JSR 163
   15.84 @@ -114,6 +107,8 @@
   15.85  
   15.86          public static final String PORT =
   15.87                  "com.sun.management.jmxremote.port";
   15.88 +        public static final String RMI_PORT =
   15.89 +                "com.sun.management.jmxremote.rmi.port";
   15.90          public static final String CONFIG_FILE_NAME =
   15.91                  "com.sun.management.config.file";
   15.92          public static final String USE_LOCAL_ONLY =
   15.93 @@ -266,34 +261,61 @@
   15.94          private final String accessFile;
   15.95      }
   15.96  
   15.97 +    // The variable below is here to support stop functionality
   15.98 +    // It would be overriten if you call startRemoteCommectionServer second
   15.99 +    // time. It's OK for now as logic in Agent.java forbids mutiple agents
  15.100 +    private static Registry registry = null;
  15.101 +
  15.102 +    public static void unexportRegistry() {
  15.103 +        // Remove the entry from registry
  15.104 +        try {
  15.105 +            if (registry != null) {
  15.106 +                UnicastRemoteObject.unexportObject(registry, true);
  15.107 +                registry = null;
  15.108 +            }
  15.109 +        } catch(NoSuchObjectException ex) {
  15.110 +            // This exception can appears only if we attempt
  15.111 +            // to unexportRegistry second time. So it's safe
  15.112 +            // to ignore it without additional messages.
  15.113 +        }
  15.114 +    }
  15.115 +
  15.116 +     /**
  15.117 +      * Initializes and starts the JMX Connector Server.
  15.118 +      * If the com.sun.management.jmxremote.port property is not defined,
  15.119 +      * simply return. Otherwise, attempts to load the config file, and
  15.120 +      * then calls {@link #startRemoteConnectorServer
  15.121 +      *                            (java.lang.String, java.util.Properties)}.
  15.122 +      *
  15.123 +      * This method is used by some jtreg tests.
  15.124 +      **/
  15.125 +      public static synchronized JMXConnectorServer initialize() {
  15.126 +
  15.127 +         // Load a new management properties
  15.128 +         final Properties props = Agent.loadManagementProperties();
  15.129 +         if (props == null) {
  15.130 +              return null;
  15.131 +         }
  15.132 +
  15.133 +         final String portStr = props.getProperty(PropertyNames.PORT);
  15.134 +         return startRemoteConnectorServer(portStr, props);
  15.135 +     }
  15.136 +
  15.137      /**
  15.138 -     * Initializes and starts the JMX Connector Server.
  15.139 -     * If the com.sun.management.jmxremote.port property is not defined,
  15.140 -     * simply return. Otherwise, attempts to load the config file, and
  15.141 -     * then calls {@link #initialize(java.lang.String, java.util.Properties)}.
  15.142 +     * This method is used by some jtreg tests.
  15.143       *
  15.144 -     **/
  15.145 -    public static synchronized JMXConnectorServer initialize() {
  15.146 -
  15.147 -        // Load a new management properties
  15.148 -        final Properties props = Agent.loadManagementProperties();
  15.149 -        if (props == null) {
  15.150 -            return null;
  15.151 -        }
  15.152 -
  15.153 -        final String portStr = props.getProperty(PropertyNames.PORT);
  15.154 -
  15.155 -
  15.156 -        // System.out.println("initializing: {port=" + portStr + ",
  15.157 -        //                     properties="+props+"}");
  15.158 -        return initialize(portStr, props);
  15.159 +     * @see #startRemoteConnectorServer
  15.160 +     *             (String portStr, Properties props)
  15.161 +     */
  15.162 +    public static synchronized JMXConnectorServer initialize(String portStr, Properties props)  {
  15.163 +         return startRemoteConnectorServer(portStr, props);
  15.164      }
  15.165  
  15.166      /**
  15.167       * Initializes and starts a JMX Connector Server for remote
  15.168       * monitoring and management.
  15.169       **/
  15.170 -    public static synchronized JMXConnectorServer initialize(String portStr, Properties props) {
  15.171 +    public static synchronized JMXConnectorServer startRemoteConnectorServer(String portStr, Properties props) {
  15.172  
  15.173          // Get port number
  15.174          final int port;
  15.175 @@ -306,6 +328,22 @@
  15.176              throw new AgentConfigurationError(INVALID_JMXREMOTE_PORT, portStr);
  15.177          }
  15.178  
  15.179 +        // User can specify a port to be used to export rmi object,
  15.180 +        // in order to simplify firewall rules
  15.181 +        // if port is not specified random one will be allocated.
  15.182 +        int rmiPort = 0;
  15.183 +        String rmiPortStr = props.getProperty(PropertyNames.RMI_PORT);
  15.184 +        try {
  15.185 +            if (rmiPortStr != null) {
  15.186 +               rmiPort = Integer.parseInt(rmiPortStr);
  15.187 +            }
  15.188 +        } catch (NumberFormatException x) {
  15.189 +            throw new AgentConfigurationError(INVALID_JMXREMOTE_RMI_PORT, x, rmiPortStr);
  15.190 +        }
  15.191 +        if (rmiPort < 0) {
  15.192 +            throw new AgentConfigurationError(INVALID_JMXREMOTE_RMI_PORT, rmiPortStr);
  15.193 +        }
  15.194 +
  15.195          // Do we use authentication?
  15.196          final String useAuthenticationStr =
  15.197                  props.getProperty(PropertyNames.USE_AUTHENTICATION,
  15.198 @@ -387,9 +425,10 @@
  15.199          }
  15.200  
  15.201          if (log.debugOn()) {
  15.202 -            log.debug("initialize",
  15.203 -                    Agent.getText("jmxremote.ConnectorBootstrap.initialize") +
  15.204 +            log.debug("startRemoteConnectorServer",
  15.205 +                    Agent.getText("jmxremote.ConnectorBootstrap.starting") +
  15.206                      "\n\t" + PropertyNames.PORT + "=" + port +
  15.207 +                    "\n\t" + PropertyNames.RMI_PORT + "=" + rmiPort +
  15.208                      "\n\t" + PropertyNames.USE_SSL + "=" + useSsl +
  15.209                      "\n\t" + PropertyNames.USE_REGISTRY_SSL + "=" + useRegistrySsl +
  15.210                      "\n\t" + PropertyNames.SSL_CONFIG_FILE_NAME + "=" + sslConfigFileName +
  15.211 @@ -404,7 +443,7 @@
  15.212                      (useAuthentication ? (loginConfigName == null ? ("\n\t" + PropertyNames.PASSWORD_FILE_NAME + "=" +
  15.213                      passwordFileName) : ("\n\t" + PropertyNames.LOGIN_CONFIG_NAME + "=" +
  15.214                      loginConfigName)) : "\n\t" +
  15.215 -                    Agent.getText("jmxremote.ConnectorBootstrap.initialize.noAuthentication")) +
  15.216 +                    Agent.getText("jmxremote.ConnectorBootstrap.noAuthentication")) +
  15.217                      (useAuthentication ? ("\n\t" + PropertyNames.ACCESS_FILE_NAME + "=" +
  15.218                      accessFileName) : "") +
  15.219                      "");
  15.220 @@ -415,15 +454,15 @@
  15.221          JMXServiceURL url = null;
  15.222          try {
  15.223              final JMXConnectorServerData data = exportMBeanServer(
  15.224 -                    mbs, port, useSsl, useRegistrySsl,
  15.225 +                    mbs, port, rmiPort, useSsl, useRegistrySsl,
  15.226                      sslConfigFileName, enabledCipherSuitesList,
  15.227                      enabledProtocolsList, sslNeedClientAuth,
  15.228                      useAuthentication, loginConfigName,
  15.229                      passwordFileName, accessFileName);
  15.230              cs = data.jmxConnectorServer;
  15.231              url = data.jmxRemoteURL;
  15.232 -            log.config("initialize",
  15.233 -                    Agent.getText("jmxremote.ConnectorBootstrap.initialize.ready",
  15.234 +            log.config("startRemoteConnectorServer",
  15.235 +                    Agent.getText("jmxremote.ConnectorBootstrap.ready",
  15.236                      url.toString()));
  15.237          } catch (Exception e) {
  15.238              throw new AgentConfigurationError(AGENT_EXCEPTION, e, e.toString());
  15.239 @@ -442,7 +481,7 @@
  15.240              // Remote connector server started but unable to export remote
  15.241              // connector address and associated configuration properties to
  15.242              // the instrumentation buffer - non-fatal error.
  15.243 -            log.debug("initialize", e);
  15.244 +            log.debug("startRemoteConnectorServer", e);
  15.245          }
  15.246          return cs;
  15.247      }
  15.248 @@ -517,9 +556,9 @@
  15.249          try {
  15.250              if (fs.supportsFileSecurity(file)) {
  15.251                  if (!fs.isAccessUserOnly(file)) {
  15.252 -                    final String msg = Agent.getText("jmxremote.ConnectorBootstrap.initialize.password.readonly",
  15.253 +                    final String msg = Agent.getText("jmxremote.ConnectorBootstrap.password.readonly",
  15.254                              passwordFileName);
  15.255 -                    log.config("initialize", msg);
  15.256 +                    log.config("startRemoteConnectorServer", msg);
  15.257                      throw new AgentConfigurationError(PASSWORD_FILE_ACCESS_NOT_RESTRICTED,
  15.258                              passwordFileName);
  15.259                  }
  15.260 @@ -560,9 +599,9 @@
  15.261              if (fs.supportsFileSecurity(file)) {
  15.262                  if (!fs.isAccessUserOnly(file)) {
  15.263                      final String msg = Agent.getText(
  15.264 -                            "jmxremote.ConnectorBootstrap.initialize.file.readonly",
  15.265 +                            "jmxremote.ConnectorBootstrap.file.readonly",
  15.266                              restrictedFileName);
  15.267 -                    log.config("initialize", msg);
  15.268 +                    log.config("startRemoteConnectorServer", msg);
  15.269                      throw new AgentConfigurationError(
  15.270                              FILE_ACCESS_NOT_RESTRICTED, restrictedFileName);
  15.271                  }
  15.272 @@ -662,6 +701,7 @@
  15.273      private static JMXConnectorServerData exportMBeanServer(
  15.274              MBeanServer mbs,
  15.275              int port,
  15.276 +            int rmiPort,
  15.277              boolean useSsl,
  15.278              boolean useRegistrySsl,
  15.279              String sslConfigFileName,
  15.280 @@ -679,7 +719,7 @@
  15.281           * IDs.  */
  15.282          System.setProperty("java.rmi.server.randomIDs", "true");
  15.283  
  15.284 -        JMXServiceURL url = new JMXServiceURL("rmi", null, 0);
  15.285 +        JMXServiceURL url = new JMXServiceURL("rmi", null, rmiPort);
  15.286  
  15.287          Map<String, Object> env = new HashMap<>();
  15.288  
  15.289 @@ -736,7 +776,6 @@
  15.290              }
  15.291          }
  15.292  
  15.293 -        final Registry registry;
  15.294          if (useRegistrySsl) {
  15.295              registry =
  15.296                      new SingleEntryRegistry(port, csf, ssf,
  15.297 @@ -747,10 +786,12 @@
  15.298                      "jmxrmi", exporter.firstExported);
  15.299          }
  15.300  
  15.301 -        JMXServiceURL remoteURL = new JMXServiceURL(
  15.302 -                "service:jmx:rmi:///jndi/rmi://" + url.getHost() + ":" +
  15.303 -                ((UnicastRef) ((RemoteObject) registry).getRef()).getLiveRef().getPort() +
  15.304 -                "/jmxrmi");
  15.305 +
  15.306 +        int registryPort =
  15.307 +            ((UnicastRef) ((RemoteObject) registry).getRef()).getLiveRef().getPort();
  15.308 +        String jmxUrlStr =  String.format("service:jmx:rmi:///jndi/rmi://%s:%d/jmxrmi",
  15.309 +                                           url.getHost(), registryPort);
  15.310 +        JMXServiceURL remoteURL = new JMXServiceURL(jmxUrlStr);
  15.311  
  15.312          /* Our exporter remembers the first object it was asked to
  15.313          export, which will be an RMIServerImpl appropriate for
    16.1 --- a/src/share/classes/sun/management/resources/agent.properties	Thu Mar 01 12:23:25 2012 -0800
    16.2 +++ b/src/share/classes/sun/management/resources/agent.properties	Mon Mar 05 17:04:10 2012 -0800
    16.3 @@ -1,6 +1,6 @@
    16.4  #
    16.5  #
    16.6 -# Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved.
    16.7 +# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
    16.8  # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    16.9  #
   16.10  # This code is free software; you can redistribute it and/or modify it
   16.11 @@ -43,8 +43,9 @@
   16.12  agent.err.premain.notfound         = premain(String) does not exist in agent class
   16.13  agent.err.agentclass.access.denied = Access to premain(String) is denied
   16.14  agent.err.invalid.agentclass       = Invalid com.sun.management.agent.class property value
   16.15 -
   16.16 +agent.err.invalid.state            = Invalid agent state
   16.17  agent.err.invalid.jmxremote.port   = Invalid com.sun.management.jmxremote.port number
   16.18 +agent.err.invalid.jmxremote.rmi.port = Invalid com.sun.management.jmxremote.rmi.port number
   16.19  
   16.20  agent.err.file.not.set               = File not specified
   16.21  agent.err.file.not.readable          = File not readable
   16.22 @@ -78,11 +79,11 @@
   16.23  agent.err.snmp.adaptor.start.failed = Failed to start SNMP adaptor with address
   16.24  agent.err.snmp.mib.init.failed     = Failed to initialize SNMP MIB with error
   16.25  
   16.26 -jmxremote.ConnectorBootstrap.initialize = Starting JMX Connector Server:
   16.27 -jmxremote.ConnectorBootstrap.initialize.noAuthentication = No Authentication
   16.28 -jmxremote.ConnectorBootstrap.initialize.ready = JMX Connector ready at: {0}
   16.29 -jmxremote.ConnectorBootstrap.initialize.password.readonly = Password file read access must be restricted: {0}
   16.30 -jmxremote.ConnectorBootstrap.initialize.file.readonly = File read access must be restricted: {0}
   16.31 +jmxremote.ConnectorBootstrap.starting = Starting JMX Connector Server:
   16.32 +jmxremote.ConnectorBootstrap.noAuthentication = No Authentication
   16.33 +jmxremote.ConnectorBootstrap.ready = JMX Connector ready at: {0}
   16.34 +jmxremote.ConnectorBootstrap.password.readonly = Password file read access must be restricted: {0}
   16.35 +jmxremote.ConnectorBootstrap.file.readonly = File read access must be restricted: {0}
   16.36  
   16.37  jmxremote.AdaptorBootstrap.getTargetList.processing = Processing ACL
   16.38  jmxremote.AdaptorBootstrap.getTargetList.adding = Adding target: {0}
    17.1 --- a/src/share/classes/sun/security/provider/PolicyFile.java	Thu Mar 01 12:23:25 2012 -0800
    17.2 +++ b/src/share/classes/sun/security/provider/PolicyFile.java	Mon Mar 05 17:04:10 2012 -0800
    17.3 @@ -1246,7 +1246,10 @@
    17.4       * @return the set of permissions according to the policy.
    17.5       */
    17.6      private PermissionCollection getPermissions(Permissions perms,
    17.7 -                               final CodeSource cs) {
    17.8 +                                                final CodeSource cs) {
    17.9 +
   17.10 +        if (cs == null)
   17.11 +            return perms;
   17.12  
   17.13          CodeSource canonCodeSource = AccessController.doPrivileged(
   17.14              new java.security.PrivilegedAction<CodeSource>(){
    18.1 --- a/src/share/classes/sun/util/calendar/ZoneInfo.java	Thu Mar 01 12:23:25 2012 -0800
    18.2 +++ b/src/share/classes/sun/util/calendar/ZoneInfo.java	Mon Mar 05 17:04:10 2012 -0800
    18.3 @@ -1,5 +1,5 @@
    18.4  /*
    18.5 - * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
    18.6 + * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
    18.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    18.8   *
    18.9   * This code is free software; you can redistribute it and/or modify it
   18.10 @@ -79,13 +79,18 @@
   18.11      private static final int TRANSITION_NSHIFT = 12;
   18.12  
   18.13      // Flag for supporting JDK backward compatible IDs, such as "EST".
   18.14 -    private static final boolean USE_OLDMAPPING;
   18.15 +    static final boolean USE_OLDMAPPING;
   18.16      static {
   18.17        String oldmapping = AccessController.doPrivileged(
   18.18            new sun.security.action.GetPropertyAction("sun.timezone.ids.oldmapping", "false")).toLowerCase(Locale.ROOT);
   18.19        USE_OLDMAPPING = (oldmapping.equals("yes") || oldmapping.equals("true"));
   18.20      }
   18.21  
   18.22 +    // IDs having conflicting data between Olson and JDK 1.1
   18.23 +    static final String[] conflictingIDs = {
   18.24 +        "EST", "MST", "HST"
   18.25 +    };
   18.26 +
   18.27      private static final CalendarSystem gcal = CalendarSystem.getGregorianCalendar();
   18.28  
   18.29      /**
   18.30 @@ -808,6 +813,16 @@
   18.31  
   18.32      private static SoftReference<Map<String, String>> aliasTable;
   18.33  
   18.34 +    static Map<String, String> getCachedAliasTable() {
   18.35 +        Map<String, String> aliases = null;
   18.36 +
   18.37 +        SoftReference<Map<String, String>> cache = aliasTable;
   18.38 +        if (cache != null) {
   18.39 +            aliases = cache.get();
   18.40 +        }
   18.41 +        return aliases;
   18.42 +    }
   18.43 +
   18.44      /**
   18.45       * Returns a Map from alias time zone IDs to their standard
   18.46       * time zone IDs.
   18.47 @@ -816,23 +831,22 @@
   18.48       *    to their standard time zone IDs, or null if
   18.49       *    <code>ZoneInfoMappings</code> file is not available.
   18.50       */
   18.51 -    public synchronized static Map<String, String> getAliasTable() {
   18.52 -        Map<String, String> aliases = null;
   18.53 -
   18.54 -        SoftReference<Map<String, String>> cache = aliasTable;
   18.55 -        if (cache != null) {
   18.56 -            aliases = cache.get();
   18.57 -            if (aliases != null) {
   18.58 -                return aliases;
   18.59 -            }
   18.60 -        }
   18.61 -
   18.62 -        aliases = ZoneInfoFile.getZoneAliases();
   18.63 -        if (aliases != null) {
   18.64 -            aliasTable = new SoftReference<>(aliases);
   18.65 -        }
   18.66 -        return aliases;
   18.67 -    }
   18.68 +     public synchronized static Map<String, String> getAliasTable() {
   18.69 +         Map<String, String> aliases = getCachedAliasTable();
   18.70 +         if (aliases == null) {
   18.71 +             aliases = ZoneInfoFile.getZoneAliases();
   18.72 +             if (aliases != null) {
   18.73 +                 if (!USE_OLDMAPPING) {
   18.74 +                     // Remove the conflicting IDs from the alias table.
   18.75 +                     for (String key : conflictingIDs) {
   18.76 +                         aliases.remove(key);
   18.77 +                     }
   18.78 +                 }
   18.79 +                 aliasTable = new SoftReference<Map<String, String>>(aliases);
   18.80 +             }
   18.81 +         }
   18.82 +         return aliases;
   18.83 +     }
   18.84  
   18.85      private void readObject(ObjectInputStream stream)
   18.86              throws IOException, ClassNotFoundException {
    19.1 --- a/src/share/classes/sun/util/calendar/ZoneInfoFile.java	Thu Mar 01 12:23:25 2012 -0800
    19.2 +++ b/src/share/classes/sun/util/calendar/ZoneInfoFile.java	Mon Mar 05 17:04:10 2012 -0800
    19.3 @@ -1,5 +1,5 @@
    19.4  /*
    19.5 - * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
    19.6 + * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
    19.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    19.8   *
    19.9   * This code is free software; you can redistribute it and/or modify it
   19.10 @@ -473,6 +473,8 @@
   19.11  
   19.12      private static Map<String, ZoneInfo> zoneInfoObjects = null;
   19.13  
   19.14 +    private static final ZoneInfo GMT = new ZoneInfo("GMT", 0);
   19.15 +
   19.16      private static final String ziDir = AccessController.doPrivileged(
   19.17          new PrivilegedAction<String>() {
   19.18              public String run() {
   19.19 @@ -553,8 +555,15 @@
   19.20       * id.
   19.21       */
   19.22      public static ZoneInfo getZoneInfo(String id) {
   19.23 +        //treat GMT zone as special
   19.24 +        if ("GMT".equals(id))
   19.25 +            return (ZoneInfo) GMT.clone();
   19.26          ZoneInfo zi = getFromCache(id);
   19.27          if (zi == null) {
   19.28 +            Map<String, String> aliases = ZoneInfo.getCachedAliasTable();
   19.29 +            if (aliases != null && aliases.get(id) != null) {
   19.30 +                return null;
   19.31 +            }
   19.32              zi = createZoneInfo(id);
   19.33              if (zi == null) {
   19.34                  return null;
   19.35 @@ -1031,30 +1040,26 @@
   19.36       * @return the buffer, or null if any I/O error occurred.
   19.37       */
   19.38      private static byte[] readZoneInfoFile(final String fileName) {
   19.39 +        if (fileName.indexOf("..") >= 0) {
   19.40 +            return null;
   19.41 +        }
   19.42          byte[] buffer = null;
   19.43  
   19.44          try {
   19.45              buffer = AccessController.doPrivileged(new PrivilegedExceptionAction<byte[]>() {
   19.46                  public byte[] run() throws IOException {
   19.47                      File file = new File(ziDir, fileName);
   19.48 -                    if (!file.exists() || !file.isFile()) {
   19.49 -                        return null;
   19.50 -                    }
   19.51 -                    file = file.getCanonicalFile();
   19.52 -                    String path = file.getCanonicalPath();
   19.53                      byte[] buf = null;
   19.54 -                    if (path != null && path.startsWith(ziDir)) {
   19.55 -                        int filesize = (int)file.length();
   19.56 -                        if (filesize > 0) {
   19.57 -                            FileInputStream fis = new FileInputStream(file);
   19.58 -                            buf = new byte[filesize];
   19.59 -                            try {
   19.60 -                                if (fis.read(buf) != filesize) {
   19.61 -                                    throw new IOException("read error on " + fileName);
   19.62 -                                }
   19.63 -                            } finally {
   19.64 -                                fis.close();
   19.65 +                    int filesize = (int)file.length();
   19.66 +                    if (filesize > 0) {
   19.67 +                        FileInputStream fis = new FileInputStream(file);
   19.68 +                        buf = new byte[filesize];
   19.69 +                        try {
   19.70 +                            if (fis.read(buf) != filesize) {
   19.71 +                                throw new IOException("read error on " + fileName);
   19.72                              }
   19.73 +                        } finally {
   19.74 +                            fis.close();
   19.75                          }
   19.76                      }
   19.77                      return buf;
    20.1 --- a/src/solaris/classes/sun/awt/X11/XTextAreaPeer.java	Thu Mar 01 12:23:25 2012 -0800
    20.2 +++ b/src/solaris/classes/sun/awt/X11/XTextAreaPeer.java	Mon Mar 05 17:04:10 2012 -0800
    20.3 @@ -105,7 +105,6 @@
    20.4          this.target = target;
    20.5  
    20.6          //ComponentAccessor.enableEvents(target,AWTEvent.MOUSE_WHEEL_EVENT_MASK);
    20.7 -        target.enableInputMethods(true);
    20.8  
    20.9          firstChangeSkipped = false;
   20.10          String text = ((TextArea)target).getText();
   20.11 @@ -113,7 +112,6 @@
   20.12          jtext.setWrapStyleWord(true);
   20.13          jtext.getDocument().addDocumentListener(jtext);
   20.14          XToolkit.specialPeerMap.put(jtext,this);
   20.15 -        jtext.enableInputMethods(true);
   20.16          textPane = new AWTTextPane(jtext,this, target.getParent());
   20.17  
   20.18          setBounds(x, y, width, height, SET_BOUNDS);
    21.1 --- a/src/solaris/classes/sun/awt/X11/XTextFieldPeer.java	Thu Mar 01 12:23:25 2012 -0800
    21.2 +++ b/src/solaris/classes/sun/awt/X11/XTextFieldPeer.java	Mon Mar 05 17:04:10 2012 -0800
    21.3 @@ -73,8 +73,6 @@
    21.4          xtext = new XAWTTextField(text,this, target.getParent());
    21.5          xtext.getDocument().addDocumentListener(xtext);
    21.6          xtext.setCursor(target.getCursor());
    21.7 -        target.enableInputMethods(true);
    21.8 -        xtext.enableInputMethods(true);
    21.9          XToolkit.specialPeerMap.put(xtext,this);
   21.10  
   21.11          TextField txt = (TextField) target;
    22.1 --- a/test/ProblemList.txt	Thu Mar 01 12:23:25 2012 -0800
    22.2 +++ b/test/ProblemList.txt	Mon Mar 05 17:04:10 2012 -0800
    22.3 @@ -1,6 +1,6 @@
    22.4  ###########################################################################
    22.5  #
    22.6 -# Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
    22.7 +# Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
    22.8  # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    22.9  #
   22.10  # This code is free software; you can redistribute it and/or modify it
   22.11 @@ -125,15 +125,15 @@
   22.12  # 7123972
   22.13  java/lang/annotation/loaderLeak/Main.java			generic-all
   22.14  
   22.15 -# 7079093
   22.16 -java/lang/instrument/ManifestTest.sh                            windows-all
   22.17 -
   22.18  # 6944188
   22.19  java/lang/management/ThreadMXBean/ThreadStateTest.java          generic-all
   22.20  
   22.21  # 7067973
   22.22  java/lang/management/MemoryMXBean/CollectionUsageThreshold.java generic-all
   22.23  
   22.24 +# 7148492
   22.25 +java/lang/management/MemoryMXBean/ResetPeakMemoryUsage.java	generic-all
   22.26 +
   22.27  ############################################################################
   22.28  
   22.29  # jdk_management
   22.30 @@ -144,9 +144,8 @@
   22.31  # 7144846
   22.32  javax/management/remote/mandatory/connection/ReconnectTest.java	generic-all
   22.33  
   22.34 -# 7073626
   22.35 -sun/management/jmxremote/bootstrap/RmiBootstrapTest.sh          windows-all
   22.36 -sun/management/jmxremote/bootstrap/RmiSslBootstrapTest.sh       windows-all
   22.37 +# 7149181 
   22.38 +sun/management/jmxremote/startstop/JMXStartStopTest.sh          generic-all
   22.39  
   22.40  ############################################################################
   22.41  
   22.42 @@ -185,6 +184,10 @@
   22.43  # 7102702
   22.44  java/net/PortUnreachableException/OneExceptionOnly.java         windows-all
   22.45  
   22.46 +# 7148829
   22.47 +sun/net/InetAddress/nameservice/simple/CacheTest.java		generic-all
   22.48 +sun/net/InetAddress/nameservice/simple/DefaultCaching.java	generic-all
   22.49 +
   22.50  ############################################################################
   22.51  
   22.52  # jdk_io
   22.53 @@ -215,6 +218,9 @@
   22.54  # 6948101
   22.55  java/rmi/transport/pinLastArguments/PinLastArguments.java	generic-all
   22.56  
   22.57 +# 7146541
   22.58 +java/rmi/transport/rapidExportUnexport/RapidExportUnexport.java	linux-all
   22.59 +
   22.60  # 7132247
   22.61  java/rmi/registry/readTest/readTest.sh				windows-all
   22.62  
   22.63 @@ -339,4 +345,3 @@
   22.64  java/util/TimeZone/TimeZoneDatePermissionCheck.sh               solaris-all
   22.65  
   22.66  ############################################################################
   22.67 -
    23.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.2 +++ b/test/com/sun/java/swing/plaf/windows/WindowsRadioButtonUI/7089914/bug7089914.java	Mon Mar 05 17:04:10 2012 -0800
    23.3 @@ -0,0 +1,77 @@
    23.4 +/*
    23.5 + * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
    23.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    23.7 + *
    23.8 + * This code is free software; you can redistribute it and/or modify it
    23.9 + * under the terms of the GNU General Public License version 2 only, as
   23.10 + * published by the Free Software Foundation.
   23.11 + *
   23.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   23.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   23.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   23.15 + * version 2 for more details (a copy is included in the LICENSE file that
   23.16 + * accompanied this code).
   23.17 + *
   23.18 + * You should have received a copy of the GNU General Public License version
   23.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   23.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   23.21 + *
   23.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   23.23 + * or visit www.oracle.com if you need additional information or have any
   23.24 + * questions.
   23.25 + */
   23.26 +
   23.27 +/*
   23.28 + * Portions Copyright (c) 2012 IBM Corporation
   23.29 + */
   23.30 +
   23.31 +/* @test
   23.32 + * @bug 7089914
   23.33 + * @summary Focus on image icons are not visible in javaws cache with high contrast mode
   23.34 + * @author Sean Chou
   23.35 + */
   23.36 +
   23.37 +import javax.swing.*;
   23.38 +import java.lang.reflect.Field;
   23.39 +
   23.40 +public class bug7089914 {
   23.41 +
   23.42 +    public static void main(String[] args) throws Exception {
   23.43 +        try {
   23.44 +            UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
   23.45 +        } catch (Exception e) {
   23.46 +            System.out.println("Not WindowsLookAndFeel, test skipped");
   23.47 +
   23.48 +            return;
   23.49 +        }
   23.50 +
   23.51 +        SwingUtilities.invokeAndWait(new Runnable() {
   23.52 +            @Override
   23.53 +            public void run() {
   23.54 +
   23.55 +                JRadioButton rb = new JRadioButton();
   23.56 +
   23.57 +                if (!"com.sun.java.swing.plaf.windows.WindowsRadioButtonUI".equals(rb.getUI().getClass().getName())) {
   23.58 +                    throw new RuntimeException("Unexpected UI class of JRadioButton");
   23.59 +                }
   23.60 +
   23.61 +                try {
   23.62 +                    Field initializedField = rb.getUI().getClass().getDeclaredField("initialized");
   23.63 +                    initializedField.setAccessible(true);
   23.64 +
   23.65 +                    if (!initializedField.getBoolean(rb.getUI())) {
   23.66 +                        throw new RuntimeException("initialized is false");
   23.67 +                    }
   23.68 +
   23.69 +                    rb.getUI().uninstallUI(rb);
   23.70 +
   23.71 +                    if (initializedField.getBoolean(rb.getUI())) {
   23.72 +                        throw new RuntimeException("initialized is true");
   23.73 +                    }
   23.74 +                } catch (NoSuchFieldException | IllegalAccessException e) {
   23.75 +                    throw new RuntimeException(e);
   23.76 +                }
   23.77 +            }
   23.78 +        });
   23.79 +    }
   23.80 +}
    24.1 --- a/test/java/lang/instrument/ManifestTest.sh	Thu Mar 01 12:23:25 2012 -0800
    24.2 +++ b/test/java/lang/instrument/ManifestTest.sh	Mon Mar 05 17:04:10 2012 -0800
    24.3 @@ -1,5 +1,5 @@
    24.4  #
    24.5 -# Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
    24.6 +# Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
    24.7  # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    24.8  #
    24.9  # This code is free software; you can redistribute it and/or modify it
   24.10 @@ -396,7 +396,7 @@
   24.11          touch $FAIL_MARKER
   24.12      fi
   24.13  
   24.14 -    MESG=`cat expect_boot_cp_line`
   24.15 +    MESG=`cat expect_boot_cp_line | tr -d '\n\r'`
   24.16      grep -s "$MESG" output.log > /dev/null
   24.17      result=$?
   24.18      if [ "$result" = 0 ]; then
   24.19 @@ -406,7 +406,7 @@
   24.20          touch $FAIL_MARKER
   24.21      fi
   24.22  
   24.23 -    MESG=`cat expect_redef_line`
   24.24 +    MESG=`cat expect_redef_line | tr -d '\n\r'`
   24.25      grep -s "$MESG" output.log > /dev/null
   24.26      result=$?
   24.27      if [ "$result" = 0 ]; then
   24.28 @@ -416,7 +416,7 @@
   24.29          touch $FAIL_MARKER
   24.30      fi
   24.31  
   24.32 -    MESG=`cat expect_retrans_line`
   24.33 +    MESG=`cat expect_retrans_line | tr -d '\n\r'`
   24.34      grep -s "$MESG" output.log > /dev/null
   24.35      result=$?
   24.36      if [ "$result" = 0 ]; then
   24.37 @@ -426,7 +426,7 @@
   24.38          touch $FAIL_MARKER
   24.39      fi
   24.40  
   24.41 -    MESG=`cat expect_set_nmp_line`
   24.42 +    MESG=`cat expect_set_nmp_line | tr -d '\n\r'`
   24.43      grep -s "$MESG" output.log > /dev/null
   24.44      result=$?
   24.45      if [ "$result" = 0 ]; then
    25.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.2 +++ b/test/java/util/Collections/EqualsTest.java	Mon Mar 05 17:04:10 2012 -0800
    25.3 @@ -0,0 +1,67 @@
    25.4 +/*
    25.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    25.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    25.7 + *
    25.8 + * This code is free software; you can redistribute it and/or modify it
    25.9 + * under the terms of the GNU General Public License version 2 only, as
   25.10 + * published by the Free Software Foundation.
   25.11 + *
   25.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   25.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   25.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   25.15 + * version 2 for more details (a copy is included in the LICENSE file that
   25.16 + * accompanied this code).
   25.17 + *
   25.18 + * You should have received a copy of the GNU General Public License version
   25.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   25.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   25.21 + *
   25.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   25.23 + * or visit www.oracle.com if you need additional information or have any
   25.24 + * questions.
   25.25 + */
   25.26 +
   25.27 +/*
   25.28 + * @test
   25.29 + * @bug 7144488
   25.30 + * @summary Infinite recursion for some equals tests in Collections
   25.31 + */
   25.32 +
   25.33 +import java.util.ArrayList;
   25.34 +import java.util.Collections;
   25.35 +import java.util.HashMap;
   25.36 +import java.util.HashSet;
   25.37 +import java.util.List;
   25.38 +import java.util.Map;
   25.39 +import java.util.Set;
   25.40 +
   25.41 +public class EqualsTest {
   25.42 +    public static void main(String[] args) {
   25.43 +        boolean test;
   25.44 +
   25.45 +        /* synchronizedList test */
   25.46 +        List list = Collections.synchronizedList(new ArrayList());
   25.47 +        list.add(list);
   25.48 +        test = list.equals(list);
   25.49 +        assertTrue(test);
   25.50 +        list.remove(list);
   25.51 +
   25.52 +        /* synchronizedSet test */
   25.53 +        Set s = Collections.synchronizedSet(new HashSet());
   25.54 +        s.add(s);
   25.55 +        test = s.equals(s);
   25.56 +        assertTrue(test);
   25.57 +
   25.58 +        /* synchronizedMap test */
   25.59 +        Map m =  Collections.synchronizedMap(new HashMap());
   25.60 +        test = m.equals(m);
   25.61 +        assertTrue(test);
   25.62 +
   25.63 +    }
   25.64 +
   25.65 +    private static void assertTrue(boolean b) {
   25.66 +        if (!b)
   25.67 +            throw new RuntimeException("assertion failed");
   25.68 +    }
   25.69 +}
   25.70 +
    26.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.2 +++ b/test/javax/swing/JTable/4220171/bug4220171.java	Mon Mar 05 17:04:10 2012 -0800
    26.3 @@ -0,0 +1,131 @@
    26.4 +/*
    26.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    26.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    26.7 + *
    26.8 + * This code is free software; you can redistribute it and/or modify it
    26.9 + * under the terms of the GNU General Public License version 2 only, as
   26.10 + * published by the Free Software Foundation.
   26.11 + *
   26.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   26.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   26.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   26.15 + * version 2 for more details (a copy is included in the LICENSE file that
   26.16 + * accompanied this code).
   26.17 + *
   26.18 + * You should have received a copy of the GNU General Public License version
   26.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   26.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   26.21 + *
   26.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   26.23 + * or visit www.oracle.com if you need additional information or have any
   26.24 + * questions.
   26.25 + */
   26.26 +
   26.27 +/*
   26.28 + * @test
   26.29 + * @bug 4220171
   26.30 + * @author Konstantin Eremin
   26.31 + * @summary Tests
   26.32 + * @library ../../regtesthelpers
   26.33 + * @build Util
   26.34 + * @run main bug4220171
   26.35 + */
   26.36 +import java.awt.Color;
   26.37 +import java.awt.Point;
   26.38 +import java.awt.Rectangle;
   26.39 +import java.awt.Robot;
   26.40 +import java.awt.Toolkit;
   26.41 +import java.awt.event.InputEvent;
   26.42 +import java.awt.event.KeyEvent;
   26.43 +import javax.swing.*;
   26.44 +import javax.swing.border.LineBorder;
   26.45 +import sun.awt.SunToolkit;
   26.46 +
   26.47 +public class bug4220171 {
   26.48 +
   26.49 +    private static JTable table;
   26.50 +
   26.51 +    public static void main(String args[]) throws Exception {
   26.52 +
   26.53 +        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
   26.54 +        Robot robot = new Robot();
   26.55 +        robot.setAutoDelay(50);
   26.56 +
   26.57 +        javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
   26.58 +
   26.59 +            public void run() {
   26.60 +                createAndShowGUI();
   26.61 +            }
   26.62 +        });
   26.63 +
   26.64 +        toolkit.realSync();
   26.65 +
   26.66 +        clickMouse(robot, 0, 0);
   26.67 +        Util.hitKeys(robot, KeyEvent.VK_A, KeyEvent.VK_B, KeyEvent.VK_ENTER);
   26.68 +        toolkit.realSync();
   26.69 +        checkCell(0, 0);
   26.70 +
   26.71 +        clickMouse(robot, 0, 1);
   26.72 +        Util.hitKeys(robot, KeyEvent.VK_D, KeyEvent.VK_E, KeyEvent.VK_ENTER);
   26.73 +        toolkit.realSync();
   26.74 +        checkCell(0, 1);
   26.75 +
   26.76 +        clickMouse(robot, 1, 0);
   26.77 +        Util.hitKeys(robot, KeyEvent.VK_1, KeyEvent.VK_2, KeyEvent.VK_ENTER);
   26.78 +        toolkit.realSync();
   26.79 +        checkCell(1, 0);
   26.80 +
   26.81 +        clickMouse(robot, 1, 1);
   26.82 +        Util.hitKeys(robot, KeyEvent.VK_4, KeyEvent.VK_5, KeyEvent.VK_ENTER);
   26.83 +        toolkit.realSync();
   26.84 +        checkCell(1, 1);
   26.85 +    }
   26.86 +
   26.87 +    static void checkCell(final int row, final int column) throws Exception {
   26.88 +        SwingUtilities.invokeAndWait(new Runnable() {
   26.89 +
   26.90 +            public void run() {
   26.91 +                if (table.getValueAt(row, column) != null) {
   26.92 +                    throw new RuntimeException(
   26.93 +                            String.format("Cell (%d, %d) is editable", row, column));
   26.94 +                }
   26.95 +            }
   26.96 +        });
   26.97 +    }
   26.98 +
   26.99 +    static void clickMouse(Robot robot, int row, int column) throws Exception {
  26.100 +        Point point = getCellClickPoint(row, column);
  26.101 +        robot.mouseMove(point.x, point.y);
  26.102 +        robot.mousePress(InputEvent.BUTTON1_MASK);
  26.103 +        robot.mouseRelease(InputEvent.BUTTON1_MASK);
  26.104 +    }
  26.105 +
  26.106 +    private static Point getCellClickPoint(final int row, final int column) throws Exception {
  26.107 +        final Point[] result = new Point[1];
  26.108 +        SwingUtilities.invokeAndWait(new Runnable() {
  26.109 +
  26.110 +            @Override
  26.111 +            public void run() {
  26.112 +                Rectangle rect = table.getCellRect(row, column, false);
  26.113 +                Point point = new Point(rect.x + rect.width / 2,
  26.114 +                        rect.y + rect.height / 2);
  26.115 +                SwingUtilities.convertPointToScreen(point, table);
  26.116 +                result[0] = point;
  26.117 +            }
  26.118 +        });
  26.119 +
  26.120 +        return result[0];
  26.121 +    }
  26.122 +
  26.123 +    private static void createAndShowGUI() {
  26.124 +        JFrame frame = new JFrame("Test");
  26.125 +        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  26.126 +        frame.setSize(200, 200);
  26.127 +
  26.128 +        table = new JTable(2, 2);
  26.129 +        table.setEnabled(false);
  26.130 +
  26.131 +        frame.getContentPane().add(table);
  26.132 +        frame.setVisible(true);
  26.133 +    }
  26.134 +}
    27.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.2 +++ b/test/javax/swing/JToolBar/4247996/bug4247996.java	Mon Mar 05 17:04:10 2012 -0800
    27.3 @@ -0,0 +1,115 @@
    27.4 +/*
    27.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    27.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    27.7 + *
    27.8 + * This code is free software; you can redistribute it and/or modify it
    27.9 + * under the terms of the GNU General Public License version 2 only, as
   27.10 + * published by the Free Software Foundation.
   27.11 + *
   27.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   27.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   27.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   27.15 + * version 2 for more details (a copy is included in the LICENSE file that
   27.16 + * accompanied this code).
   27.17 + *
   27.18 + * You should have received a copy of the GNU General Public License version
   27.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   27.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   27.21 + *
   27.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   27.23 + * or visit www.oracle.com if you need additional information or have any
   27.24 + * questions.
   27.25 + */
   27.26 +
   27.27 +/* @test
   27.28 + * @bug 4247996 4260485
   27.29 + * @summary Test that rollover toolbar doesn't corrupt buttons
   27.30 + * @author Peter Zhelezniakov
   27.31 + * @run main bug4247996
   27.32 + */
   27.33 +import java.awt.*;
   27.34 +import javax.swing.*;
   27.35 +import sun.awt.SunToolkit;
   27.36 +
   27.37 +public class bug4247996 {
   27.38 +
   27.39 +    private static JButton button;
   27.40 +    private static JToggleButton toogleButton;
   27.41 +
   27.42 +    public static void main(String[] args) throws Exception {
   27.43 +
   27.44 +        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
   27.45 +        Robot robot = new Robot();
   27.46 +        robot.setAutoDelay(50);
   27.47 +
   27.48 +        UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
   27.49 +
   27.50 +        javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
   27.51 +
   27.52 +            public void run() {
   27.53 +                createAndShowGUI();
   27.54 +            }
   27.55 +        });
   27.56 +
   27.57 +        toolkit.realSync();
   27.58 +
   27.59 +        Point point = getButtonCenter();
   27.60 +        robot.mouseMove(point.x, point.y);
   27.61 +        toolkit.realSync();
   27.62 +
   27.63 +        checkButtonsSize();
   27.64 +
   27.65 +    }
   27.66 +
   27.67 +    private static void checkButtonsSize() throws Exception {
   27.68 +        SwingUtilities.invokeAndWait(new Runnable() {
   27.69 +
   27.70 +            @Override
   27.71 +            public void run() {
   27.72 +                if (!button.getSize().equals(toogleButton.getSize())) {
   27.73 +                    throw new RuntimeException("Button sizes are different!");
   27.74 +                }
   27.75 +            }
   27.76 +        });
   27.77 +    }
   27.78 +
   27.79 +    private static Point getButtonCenter() throws Exception {
   27.80 +        final Point[] result = new Point[1];
   27.81 +
   27.82 +        SwingUtilities.invokeAndWait(new Runnable() {
   27.83 +
   27.84 +            @Override
   27.85 +            public void run() {
   27.86 +                Point p = button.getLocationOnScreen();
   27.87 +                Dimension size = button.getSize();
   27.88 +                result[0] = new Point(p.x + size.width / 2, p.y + size.height / 2);
   27.89 +            }
   27.90 +        });
   27.91 +        return result[0];
   27.92 +    }
   27.93 +
   27.94 +    private static void createAndShowGUI() {
   27.95 +        JFrame frame = new JFrame("Test");
   27.96 +        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   27.97 +        frame.setSize(200, 200);
   27.98 +
   27.99 +        JButton rButton = new JButton("Rollover");
  27.100 +        rButton.setRolloverEnabled(true);
  27.101 +        JToolBar nrToolbar = new JToolBar();
  27.102 +        nrToolbar.add(rButton);
  27.103 +        nrToolbar.remove(rButton);
  27.104 +
  27.105 +        if (!rButton.isRolloverEnabled()) {
  27.106 +            throw new Error("Failed (bug 4260485): "
  27.107 +                    + "toolbar overrode button's rollover property");
  27.108 +        }
  27.109 +
  27.110 +        JToolBar rToolbar = new JToolBar();
  27.111 +        rToolbar.putClientProperty("JToolBar.isRollover", Boolean.TRUE);
  27.112 +        rToolbar.add(button = new JButton("Test"));
  27.113 +        rToolbar.add(toogleButton = new JToggleButton("Test"));
  27.114 +
  27.115 +        frame.getContentPane().add(rToolbar, BorderLayout.NORTH);
  27.116 +        frame.setVisible(true);
  27.117 +    }
  27.118 +}
    28.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.2 +++ b/test/javax/swing/JToolTip/4846413/bug4846413.java	Mon Mar 05 17:04:10 2012 -0800
    28.3 @@ -0,0 +1,138 @@
    28.4 +/*
    28.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    28.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    28.7 + *
    28.8 + * This code is free software; you can redistribute it and/or modify it
    28.9 + * under the terms of the GNU General Public License version 2 only, as
   28.10 + * published by the Free Software Foundation.
   28.11 + *
   28.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   28.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   28.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   28.15 + * version 2 for more details (a copy is included in the LICENSE file that
   28.16 + * accompanied this code).
   28.17 + *
   28.18 + * You should have received a copy of the GNU General Public License version
   28.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   28.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   28.21 + *
   28.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   28.23 + * or visit www.oracle.com if you need additional information or have any
   28.24 + * questions.
   28.25 + */
   28.26 +
   28.27 +/*
   28.28 + * @test
   28.29 + * @bug 4846413
   28.30 + * @summary Checks if No tooltip modification when no KeyStroke modifier
   28.31 + * @library ../../regtesthelpers
   28.32 + * @build Util
   28.33 + * @author Konstantin Eremin
   28.34 + * @run main bug4846413
   28.35 + */
   28.36 +import java.awt.Dimension;
   28.37 +import java.awt.Point;
   28.38 +import java.awt.Robot;
   28.39 +import java.awt.Toolkit;
   28.40 +import javax.swing.*;
   28.41 +import java.awt.event.*;
   28.42 +import javax.swing.plaf.metal.MetalToolTipUI;
   28.43 +import sun.awt.SunToolkit;
   28.44 +
   28.45 +public class bug4846413 {
   28.46 +
   28.47 +    private static volatile boolean isTooltipAdded;
   28.48 +    private static JButton button;
   28.49 +
   28.50 +    public static void main(String[] args) throws Exception {
   28.51 +
   28.52 +        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
   28.53 +        Robot robot = new Robot();
   28.54 +        robot.setAutoDelay(50);
   28.55 +
   28.56 +        UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
   28.57 +
   28.58 +        javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
   28.59 +
   28.60 +            public void run() {
   28.61 +                createAndShowGUI();
   28.62 +            }
   28.63 +        });
   28.64 +
   28.65 +        toolkit.realSync();
   28.66 +
   28.67 +        Point movePoint = getButtonPoint();
   28.68 +        robot.mouseMove(movePoint.x, movePoint.y);
   28.69 +        toolkit.realSync();
   28.70 +
   28.71 +        long timeout = System.currentTimeMillis() + 9000;
   28.72 +        while (!isTooltipAdded && (System.currentTimeMillis() < timeout)) {
   28.73 +            try {Thread.sleep(500);} catch (Exception e) {}
   28.74 +        }
   28.75 +
   28.76 +        checkToolTip();
   28.77 +    }
   28.78 +
   28.79 +    private static void checkToolTip() throws Exception {
   28.80 +        SwingUtilities.invokeAndWait(new Runnable() {
   28.81 +
   28.82 +            @Override
   28.83 +            public void run() {
   28.84 +                JToolTip tooltip = (JToolTip) Util.findSubComponent(
   28.85 +                        JFrame.getFrames()[0], "JToolTip");
   28.86 +
   28.87 +                if (tooltip == null) {
   28.88 +                    throw new RuntimeException("Tooltip has not been found!");
   28.89 +                }
   28.90 +
   28.91 +                MetalToolTipUI tooltipUI = (MetalToolTipUI) MetalToolTipUI.createUI(tooltip);
   28.92 +                tooltipUI.installUI(tooltip);
   28.93 +
   28.94 +                if (!"-Insert".equals(tooltipUI.getAcceleratorString())) {
   28.95 +                    throw new RuntimeException("Tooltip acceleration is not properly set!");
   28.96 +                }
   28.97 +
   28.98 +            }
   28.99 +        });
  28.100 +    }
  28.101 +
  28.102 +    private static Point getButtonPoint() throws Exception {
  28.103 +        final Point[] result = new Point[1];
  28.104 +
  28.105 +        SwingUtilities.invokeAndWait(new Runnable() {
  28.106 +
  28.107 +            @Override
  28.108 +            public void run() {
  28.109 +                Point p = button.getLocationOnScreen();
  28.110 +                Dimension size = button.getSize();
  28.111 +                result[0] = new Point(p.x + size.width / 2, p.y + size.height / 2);
  28.112 +            }
  28.113 +        });
  28.114 +        return result[0];
  28.115 +    }
  28.116 +
  28.117 +    private static void createAndShowGUI() {
  28.118 +        JFrame frame = new JFrame("Test");
  28.119 +        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  28.120 +        frame.setSize(200, 200);
  28.121 +
  28.122 +        button = new JButton("Press me");
  28.123 +        button.setToolTipText("test");
  28.124 +        button.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
  28.125 +                KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, 0, true), "someCommand");
  28.126 +        button.getActionMap().put("someCommand", null);
  28.127 +        frame.getContentPane().add(button);
  28.128 +
  28.129 +        JLayeredPane layeredPane = (JLayeredPane) Util.findSubComponent(
  28.130 +                frame, "JLayeredPane");
  28.131 +        layeredPane.addContainerListener(new ContainerAdapter() {
  28.132 +
  28.133 +            @Override
  28.134 +            public void componentAdded(ContainerEvent e) {
  28.135 +                isTooltipAdded = true;
  28.136 +            }
  28.137 +        });
  28.138 +
  28.139 +        frame.setVisible(true);
  28.140 +    }
  28.141 +}
    29.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    29.2 +++ b/test/javax/swing/JTree/4330357/bug4330357.java	Mon Mar 05 17:04:10 2012 -0800
    29.3 @@ -0,0 +1,197 @@
    29.4 +/*
    29.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    29.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    29.7 + *
    29.8 + * This code is free software; you can redistribute it and/or modify it
    29.9 + * under the terms of the GNU General Public License version 2 only, as
   29.10 + * published by the Free Software Foundation.
   29.11 + *
   29.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   29.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   29.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   29.15 + * version 2 for more details (a copy is included in the LICENSE file that
   29.16 + * accompanied this code).
   29.17 + *
   29.18 + * You should have received a copy of the GNU General Public License version
   29.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   29.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   29.21 + *
   29.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   29.23 + * or visit www.oracle.com if you need additional information or have any
   29.24 + * questions.
   29.25 + */
   29.26 +
   29.27 +/*
   29.28 + * @test
   29.29 + * @bug 4330357
   29.30 + * @summary Tests that real editor in JTree cleans up after editing was stopped
   29.31 + * @library ../../regtesthelpers
   29.32 + * @build Util
   29.33 + * @author Peter Zhelezniakov
   29.34 + * @run main bug4330357
   29.35 + */
   29.36 +import java.awt.*;
   29.37 +import java.awt.event.*;
   29.38 +import javax.swing.*;
   29.39 +import javax.swing.tree.*;
   29.40 +import sun.awt.SunToolkit;
   29.41 +
   29.42 +public class bug4330357 {
   29.43 +
   29.44 +    private static JTree tree;
   29.45 +    private static JButton button;
   29.46 +    private static Robot robot;
   29.47 +
   29.48 +    public static void main(String[] args) throws Exception {
   29.49 +        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
   29.50 +        robot = new Robot();
   29.51 +        robot.setAutoDelay(50);
   29.52 +
   29.53 +        UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
   29.54 +
   29.55 +        javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
   29.56 +
   29.57 +            public void run() {
   29.58 +                createAndShowGUI();
   29.59 +            }
   29.60 +        });
   29.61 +
   29.62 +        toolkit.realSync();
   29.63 +
   29.64 +        clickMouse(getTreeRowClickPoint(1));
   29.65 +        Util.hitKeys(robot, KeyEvent.VK_F2);
   29.66 +        Util.hitKeys(robot, KeyEvent.VK_A, KeyEvent.VK_B, KeyEvent.VK_C);
   29.67 +        toolkit.realSync();
   29.68 +
   29.69 +        if (!hasComponent(JTextField.class)) {
   29.70 +            throw new RuntimeException("Cell editor is missed for path: color");
   29.71 +        }
   29.72 +
   29.73 +
   29.74 +        clickMouse(getButtonClickPoint());
   29.75 +        toolkit.realSync();
   29.76 +
   29.77 +        clickMouse(getTreeRowClickPoint(2));
   29.78 +        Util.hitKeys(robot, KeyEvent.VK_F2);
   29.79 +        toolkit.realSync();
   29.80 +
   29.81 +        if (!hasComponent(JComboBox.class)) {
   29.82 +            throw new RuntimeException("Cell editor is missed for path: sports");
   29.83 +        }
   29.84 +
   29.85 +        if (hasComponent(JTextField.class)) {
   29.86 +            throw new RuntimeException("Cell editor is wrongly shown for path: color");
   29.87 +        }
   29.88 +    }
   29.89 +
   29.90 +    static void clickMouse(Point point) {
   29.91 +        robot.mouseMove(point.x, point.y);
   29.92 +        robot.mousePress(InputEvent.BUTTON1_MASK);
   29.93 +        robot.mouseRelease(InputEvent.BUTTON1_MASK);
   29.94 +    }
   29.95 +
   29.96 +    private static Point getTreeRowClickPoint(final int row) throws Exception {
   29.97 +        final Point[] result = new Point[1];
   29.98 +
   29.99 +        SwingUtilities.invokeAndWait(new Runnable() {
  29.100 +
  29.101 +            @Override
  29.102 +            public void run() {
  29.103 +
  29.104 +                Rectangle rect = tree.getRowBounds(row);
  29.105 +                Point p = new Point(rect.x + rect.width / 2, rect.y + 2);
  29.106 +                SwingUtilities.convertPointToScreen(p, tree);
  29.107 +                result[0] = p;
  29.108 +            }
  29.109 +        });
  29.110 +
  29.111 +        return result[0];
  29.112 +    }
  29.113 +
  29.114 +    private static Point getButtonClickPoint() throws Exception {
  29.115 +        final Point[] result = new Point[1];
  29.116 +
  29.117 +        SwingUtilities.invokeAndWait(new Runnable() {
  29.118 +
  29.119 +            @Override
  29.120 +            public void run() {
  29.121 +                Point p = button.getLocationOnScreen();
  29.122 +                Dimension size = button.getSize();
  29.123 +                result[0] = new Point(p.x + size.width / 2, p.y + size.height / 2);
  29.124 +            }
  29.125 +        });
  29.126 +        return result[0];
  29.127 +    }
  29.128 +
  29.129 +    static boolean hasComponent(final Class cls) throws Exception {
  29.130 +        final boolean[] result = new boolean[1];
  29.131 +
  29.132 +        SwingUtilities.invokeAndWait(new Runnable() {
  29.133 +
  29.134 +            @Override
  29.135 +            public void run() {
  29.136 +                result[0] = Util.findSubComponent(tree, cls.getName()) != null;
  29.137 +            }
  29.138 +        });
  29.139 +
  29.140 +        return result[0];
  29.141 +    }
  29.142 +
  29.143 +    private static void createAndShowGUI() {
  29.144 +        JFrame frame = new JFrame("Test");
  29.145 +        frame.setSize(200, 200);
  29.146 +        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  29.147 +
  29.148 +        tree = new JTree();
  29.149 +        tree.setEditable(true);
  29.150 +
  29.151 +        final TestEditor testEditor = new TestEditor();
  29.152 +        tree.setCellEditor(new DefaultTreeCellEditor(tree,
  29.153 +                (DefaultTreeCellRenderer) tree.getCellRenderer(),
  29.154 +                testEditor));
  29.155 +
  29.156 +        button = new JButton("stop");
  29.157 +
  29.158 +        button.addActionListener(new ActionListener() {
  29.159 +
  29.160 +            public void actionPerformed(ActionEvent ae) {
  29.161 +                testEditor.stopCellEditing();
  29.162 +            }
  29.163 +        });
  29.164 +
  29.165 +        frame.getContentPane().add(new JScrollPane(tree), BorderLayout.CENTER);
  29.166 +        frame.getContentPane().add(button, BorderLayout.SOUTH);
  29.167 +        frame.setVisible(true);
  29.168 +    }
  29.169 +
  29.170 +    static class TestEditor extends AbstractCellEditor implements TreeCellEditor {
  29.171 +
  29.172 +        private JComboBox comboBox;
  29.173 +        private JTextField textField;
  29.174 +        private boolean comboBoxActive;
  29.175 +
  29.176 +        TestEditor() {
  29.177 +            comboBox = new JComboBox(new String[]{"one", "two"});
  29.178 +            textField = new JTextField();
  29.179 +        }
  29.180 +
  29.181 +        public Component getTreeCellEditorComponent(JTree tree, Object value,
  29.182 +                boolean isSelected,
  29.183 +                boolean expanded,
  29.184 +                boolean leaf, int row) {
  29.185 +            if (row % 2 == 0) {
  29.186 +                comboBoxActive = true;
  29.187 +                return comboBox;
  29.188 +            }
  29.189 +            comboBoxActive = false;
  29.190 +            return textField;
  29.191 +        }
  29.192 +
  29.193 +        public Object getCellEditorValue() {
  29.194 +            if (comboBoxActive) {
  29.195 +                return comboBox.getSelectedItem();
  29.196 +            }
  29.197 +            return textField.getText();
  29.198 +        }
  29.199 +    }
  29.200 +}
    30.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    30.2 +++ b/test/javax/swing/JViewport/7107099/bug7107099.java	Mon Mar 05 17:04:10 2012 -0800
    30.3 @@ -0,0 +1,104 @@
    30.4 +/*
    30.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    30.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    30.7 + *
    30.8 + * This code is free software; you can redistribute it and/or modify it
    30.9 + * under the terms of the GNU General Public License version 2 only, as
   30.10 + * published by the Free Software Foundation.
   30.11 + *
   30.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   30.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   30.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   30.15 + * version 2 for more details (a copy is included in the LICENSE file that
   30.16 + * accompanied this code).
   30.17 + *
   30.18 + * You should have received a copy of the GNU General Public License version
   30.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   30.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   30.21 + *
   30.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   30.23 + * or visit www.oracle.com if you need additional information or have any
   30.24 + * questions.
   30.25 + */
   30.26 +
   30.27 +/* @test
   30.28 +   @bug 7107099
   30.29 +   @summary JScrollBar does not show up even if there are enough lebgth of textstring in textField
   30.30 +   @author Pavel Porvatov
   30.31 +*/
   30.32 +
   30.33 +import sun.awt.SunToolkit;
   30.34 +
   30.35 +import javax.swing.*;
   30.36 +import java.awt.*;
   30.37 +
   30.38 +public class bug7107099 {
   30.39 +    private static JFrame frame;
   30.40 +    private static JTextArea textarea;
   30.41 +    private static JScrollPane scrollPane;
   30.42 +
   30.43 +    private static int value;
   30.44 +    private static int min;
   30.45 +    private static int max;
   30.46 +    private static int extent;
   30.47 +
   30.48 +    public static void main(String[] args) throws Exception {
   30.49 +        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
   30.50 +
   30.51 +        SwingUtilities.invokeAndWait(new Runnable() {
   30.52 +            @Override
   30.53 +            public void run() {
   30.54 +                textarea = new JTextArea("before###1###\nbefore###2###\nbefore###3###\nbefore###4###\nbefore###5###\n");
   30.55 +
   30.56 +                scrollPane = new JScrollPane(textarea);
   30.57 +                scrollPane.setPreferredSize(new Dimension(100, 50));
   30.58 +
   30.59 +                frame = new JFrame();
   30.60 +                frame.setLayout(new BorderLayout());
   30.61 +                frame.setSize(200, 200);
   30.62 +                frame.add(scrollPane, BorderLayout.SOUTH);
   30.63 +                frame.setVisible(true);
   30.64 +            }
   30.65 +        });
   30.66 +
   30.67 +        toolkit.realSync();
   30.68 +
   30.69 +        SwingUtilities.invokeAndWait(new Runnable() {
   30.70 +            @Override
   30.71 +            public void run() {
   30.72 +                BoundedRangeModel model = scrollPane.getVerticalScrollBar().getModel();
   30.73 +
   30.74 +                value = model.getValue();
   30.75 +                min = model.getMinimum();
   30.76 +                max = model.getMaximum();
   30.77 +                extent = model.getExtent();
   30.78 +
   30.79 +                // Do tricky manipulation for testing purpose
   30.80 +                textarea.setText(null);
   30.81 +                scrollPane.setViewportView(textarea);
   30.82 +                textarea.setText("after###1###\nafter###1###\nafter###1###\nafter###1###\nafter###1###\n");
   30.83 +                textarea.setCaretPosition(0);
   30.84 +            }
   30.85 +        });
   30.86 +
   30.87 +        toolkit.realSync();
   30.88 +
   30.89 +        SwingUtilities.invokeAndWait(new Runnable() {
   30.90 +            @Override
   30.91 +            public void run() {
   30.92 +                BoundedRangeModel model = scrollPane.getVerticalScrollBar().getModel();
   30.93 +
   30.94 +                if (value != model.getValue() ||
   30.95 +                        min != model.getMinimum() ||
   30.96 +                        max != model.getMaximum() ||
   30.97 +                        extent != model.getExtent()) {
   30.98 +                    throw new RuntimeException("Test bug7107099 failed");
   30.99 +                }
  30.100 +
  30.101 +                System.out.println("Test bug7107099 passed");
  30.102 +
  30.103 +                frame.dispose();
  30.104 +            }
  30.105 +        });
  30.106 +    }
  30.107 +}
    31.1 --- a/test/sun/management/AgentCheckTest.java	Thu Mar 01 12:23:25 2012 -0800
    31.2 +++ b/test/sun/management/AgentCheckTest.java	Mon Mar 05 17:04:10 2012 -0800
    31.3 @@ -1,5 +1,5 @@
    31.4  /*
    31.5 - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
    31.6 + * Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
    31.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    31.8   *
    31.9   * This code is free software; you can redistribute it and/or modify it
   31.10 @@ -35,10 +35,10 @@
   31.11      public static void main(String[] args){
   31.12          String [][] testStrings = {
   31.13              {"agent.err.error", "", ""},
   31.14 -            {"jmxremote.ConnectorBootstrap.initialize", "", ""},
   31.15 -            {"jmxremote.ConnectorBootstrap.initialize.noAuthentication", "", ""},
   31.16 -            {"jmxremote.ConnectorBootstrap.initialize.ready", "Phony JMXServiceURL", ""},
   31.17 -            {"jmxremote.ConnectorBootstrap.initialize.password.readonly", "Phony passwordFileName", ""},
   31.18 +            {"jmxremote.ConnectorBootstrap.starting", "", ""},
   31.19 +            {"jmxremote.ConnectorBootstrap.noAuthentication", "", ""},
   31.20 +            {"jmxremote.ConnectorBootstrap.ready", "Phony JMXServiceURL", ""},
   31.21 +            {"jmxremote.ConnectorBootstrap.password.readonly", "Phony passwordFileName", ""},
   31.22              {"jmxremote.AdaptorBootstrap.getTargetList.processing", "", ""},
   31.23              {"jmxremote.AdaptorBootstrap.getTargetList.adding", "Phony target", ""},
   31.24              {"jmxremote.AdaptorBootstrap.getTargetList.starting", "", ""},
    32.1 --- a/test/sun/management/jmxremote/bootstrap/GeneratePropertyPassword.sh	Thu Mar 01 12:23:25 2012 -0800
    32.2 +++ b/test/sun/management/jmxremote/bootstrap/GeneratePropertyPassword.sh	Mon Mar 05 17:04:10 2012 -0800
    32.3 @@ -1,5 +1,5 @@
    32.4  #
    32.5 -# Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
    32.6 +# Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
    32.7  # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    32.8  #
    32.9  # This code is free software; you can redistribute it and/or modify it
   32.10 @@ -34,6 +34,13 @@
   32.11  OS=`uname -s`
   32.12  UMASK=`umask`
   32.13  
   32.14 +if [[ $OS == CYGWIN_NT* ]] ; then
   32.15 +    OS="Windows_NT"
   32.16 +    if [ -z "$SystemRoot" ] ;  then
   32.17 +	SystemRoot=$SYSTEMROOT
   32.18 +    fi
   32.19 +fi
   32.20 +
   32.21  case $OS in
   32.22  SunOS | Linux)
   32.23      PATHSEP=":"
    33.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    33.2 +++ b/test/sun/management/jmxremote/startstop/JMXStartStopDoSomething.java	Mon Mar 05 17:04:10 2012 -0800
    33.3 @@ -0,0 +1,52 @@
    33.4 +/*
    33.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    33.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    33.7 + *
    33.8 + * This code is free software; you can redistribute it and/or modify it
    33.9 + * under the terms of the GNU General Public License version 2 only, as
   33.10 + * published by the Free Software Foundation.
   33.11 + *
   33.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   33.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   33.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   33.15 + * version 2 for more details (a copy is included in the LICENSE file that
   33.16 + * accompanied this code).
   33.17 + *
   33.18 + * You should have received a copy of the GNU General Public License version
   33.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   33.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   33.21 + *
   33.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   33.23 + * or visit www.oracle.com if you need additional information or have any
   33.24 + * questions.
   33.25 + */
   33.26 +
   33.27 +import java.io.RandomAccessFile;
   33.28 +
   33.29 +public class JMXStartStopDoSomething {
   33.30 +
   33.31 +
   33.32 +    public void doSomething(){
   33.33 +        try {
   33.34 +            for (int i=0; i < 10; ++i) {
   33.35 +                RandomAccessFile f = new RandomAccessFile("/dev/null","r");
   33.36 +                int n = f.read();
   33.37 +                f.close();
   33.38 +            }
   33.39 +
   33.40 +        } catch (Throwable e) {
   33.41 +            System.err.println("Something bad happens:" +e);
   33.42 +        }
   33.43 +    }
   33.44 +
   33.45 +    public static void main(String args[]) throws Exception {
   33.46 +        System.err.println("main enter");
   33.47 +        int count = 1;
   33.48 +        while(count > 0) {
   33.49 +            JMXStartStopDoSomething p = new JMXStartStopDoSomething();
   33.50 +            p.doSomething();
   33.51 +            Thread.sleep(1);
   33.52 +        }
   33.53 +        // System.err.println("main exit");
   33.54 +    }
   33.55 +}
    34.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    34.2 +++ b/test/sun/management/jmxremote/startstop/JMXStartStopTest.java	Mon Mar 05 17:04:10 2012 -0800
    34.3 @@ -0,0 +1,181 @@
    34.4 +/*
    34.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    34.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    34.7 + *
    34.8 + * This code is free software; you can redistribute it and/or modify it
    34.9 + * under the terms of the GNU General Public License version 2 only, as
   34.10 + * published by the Free Software Foundation.
   34.11 + *
   34.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   34.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   34.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   34.15 + * version 2 for more details (a copy is included in the LICENSE file that
   34.16 + * accompanied this code).
   34.17 + *
   34.18 + * You should have received a copy of the GNU General Public License version
   34.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   34.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   34.21 + *
   34.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   34.23 + * or visit www.oracle.com if you need additional information or have any
   34.24 + * questions.
   34.25 + */
   34.26 +
   34.27 +import java.io.File;
   34.28 +import java.io.FileInputStream;
   34.29 +import java.io.FilenameFilter;
   34.30 +import java.io.IOException;
   34.31 +import java.io.InputStream;
   34.32 +import java.rmi.registry.LocateRegistry;
   34.33 +import java.rmi.registry.Registry;
   34.34 +import java.util.ArrayList;
   34.35 +import java.util.Arrays;
   34.36 +import java.util.Enumeration;
   34.37 +import java.util.HashMap;
   34.38 +import java.util.Iterator;
   34.39 +import java.util.Map;
   34.40 +import java.util.Properties;
   34.41 +import java.util.Set;
   34.42 +
   34.43 +import javax.management.*;
   34.44 +import javax.management.remote.*;
   34.45 +
   34.46 +import sun.management.AgentConfigurationError;
   34.47 +import sun.management.jmxremote.ConnectorBootstrap;
   34.48 +
   34.49 +public class JMXStartStopTest {
   34.50 +
   34.51 +    static boolean verbose = false;
   34.52 +
   34.53 +    static void dbg_print(String msg){
   34.54 +        if (verbose) {
   34.55 +            System.err.println("DBG: " +msg);
   34.56 +        }
   34.57 +    }
   34.58 +
   34.59 +    static void dbg_print(String msg, Throwable ex){
   34.60 +        if (verbose) {
   34.61 +            System.err.println("DBG: " + msg + " " + ex.getMessage() );
   34.62 +            ex.printStackTrace(System.err);
   34.63 +        }
   34.64 +    }
   34.65 +
   34.66 +    public static int listMBeans(MBeanServerConnection server, ObjectName pattern, QueryExp query)
   34.67 +    throws Exception {
   34.68 +
   34.69 +        Set names = server.queryNames(pattern,query);
   34.70 +        for (Iterator i=names.iterator(); i.hasNext(); ) {
   34.71 +            ObjectName name = (ObjectName)i.next();
   34.72 +            MBeanInfo info = server.getMBeanInfo(name);
   34.73 +            dbg_print("Got MBean: " + name);
   34.74 +
   34.75 +            MBeanAttributeInfo[] attrs = info.getAttributes();
   34.76 +            if (attrs == null)
   34.77 +                continue;
   34.78 +
   34.79 +            for (int j=0; j<attrs.length; j++) {
   34.80 +                if (attrs[j].isReadable()) {
   34.81 +                    Object o = server.getAttribute(name,attrs[j].getName());
   34.82 +                }
   34.83 +            }
   34.84 +        }
   34.85 +        return names.size();
   34.86 +    }
   34.87 +
   34.88 +
   34.89 +    public void run_local(String strPid)
   34.90 +    throws Exception {
   34.91 +
   34.92 +        String jmxUrlStr = null;
   34.93 +        int pid = Integer.parseInt(strPid);
   34.94 +
   34.95 +        try {
   34.96 +            jmxUrlStr = sun.management.ConnectorAddressLink.importFrom(pid);
   34.97 +            dbg_print("Local Service URL: " +jmxUrlStr);
   34.98 +            if ( jmxUrlStr == null ) {
   34.99 +                throw new Exception("No Service URL. Local agent not started?");
  34.100 +            }
  34.101 +
  34.102 +            JMXServiceURL url = new JMXServiceURL(jmxUrlStr);
  34.103 +            Map m = new HashMap();
  34.104 +
  34.105 +            JMXConnector c = JMXConnectorFactory.connect(url,m);
  34.106 +
  34.107 +            MBeanServerConnection conn = c.getMBeanServerConnection();
  34.108 +            ObjectName pattern = new ObjectName("java.lang:type=Memory,*");
  34.109 +
  34.110 +            int count = listMBeans(conn,pattern,null);
  34.111 +            if (count == 0)
  34.112 +                throw new Exception("Expected at least one matching "+ "MBean for "+pattern);
  34.113 +
  34.114 +
  34.115 +        } catch (IOException e) {
  34.116 +            dbg_print("Cannot find process : " + pid);
  34.117 +            throw e;
  34.118 +        }
  34.119 +    }
  34.120 +
  34.121 +    public void run(String args[]) throws Exception {
  34.122 +
  34.123 +        dbg_print("RmiRegistry lookup...");
  34.124 +
  34.125 +        int port = 4567;
  34.126 +        if (args != null && args.length > 0) {
  34.127 +            port = Integer.parseInt(args[0]);
  34.128 +        }
  34.129 +        dbg_print("Using port: " + port);
  34.130 +
  34.131 +        int rmiPort = 0;
  34.132 +        if (args != null && args.length > 1) {
  34.133 +            rmiPort = Integer.parseInt(args[1]);
  34.134 +        }
  34.135 +        dbg_print("Using rmi port: " + rmiPort);
  34.136 +
  34.137 +        Registry registry = LocateRegistry.getRegistry(port);
  34.138 +
  34.139 +        // "jmxrmi"
  34.140 +        String[] relist = registry.list();
  34.141 +        for (int i = 0; i < relist.length; ++i) {
  34.142 +            dbg_print("Got registry: " + relist[i]);
  34.143 +        }
  34.144 +
  34.145 +        String jmxUrlStr = (rmiPort != 0) ?
  34.146 +                           String.format("service:jmx:rmi://localhost:%d/jndi/rmi://localhost:%d/jmxrmi", rmiPort, port) :
  34.147 +                           String.format("service:jmx:rmi:///jndi/rmi://localhost:%d/jmxrmi",port);
  34.148 +
  34.149 +        JMXServiceURL url = new JMXServiceURL(jmxUrlStr);
  34.150 +        Map m = new HashMap();
  34.151 +
  34.152 +        JMXConnector c = JMXConnectorFactory.connect(url,m);
  34.153 +
  34.154 +        MBeanServerConnection conn = c.getMBeanServerConnection();
  34.155 +        ObjectName pattern = new ObjectName("java.lang:type=Memory,*");
  34.156 +
  34.157 +        int count = listMBeans(conn,pattern,null);
  34.158 +        if (count == 0)
  34.159 +            throw new Exception("Expected at least one matching "+ "MBean for "+pattern);
  34.160 +    }
  34.161 +
  34.162 +
  34.163 +    public static void main(String args[]) {
  34.164 +        JMXStartStopTest manager = new JMXStartStopTest();
  34.165 +        try {
  34.166 +            if (args!=null && args[0].equals("local")) {
  34.167 +                manager.run_local(args[1]);
  34.168 +            } else {
  34.169 +                manager.run(args);
  34.170 +            }
  34.171 +        } catch (RuntimeException r) {
  34.172 +            dbg_print("No connection: ", r);
  34.173 +            System.out.println("NO_CONN");
  34.174 +            System.exit(1);
  34.175 +        } catch (Throwable t) {
  34.176 +            dbg_print("No connection: ", t);
  34.177 +            System.out.println("NO_CONN");
  34.178 +            System.exit(2);
  34.179 +        }
  34.180 +        System.out.println("OK_CONN");
  34.181 +        System.exit(0);
  34.182 +    }
  34.183 +
  34.184 +}
    35.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    35.2 +++ b/test/sun/management/jmxremote/startstop/JMXStartStopTest.sh	Mon Mar 05 17:04:10 2012 -0800
    35.3 @@ -0,0 +1,603 @@
    35.4 +#!/bin/sh
    35.5 +
    35.6 +# Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved.
    35.7 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    35.8 +# 
    35.9 +# This code is free software; you can redistribute it and/or modify it
   35.10 +# under the terms of the GNU General Public License version 2 only, as
   35.11 +# published by the Free Software Foundation.
   35.12 +# 
   35.13 +# This code is distributed in the hope that it will be useful, but WITHOUT
   35.14 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   35.15 +# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   35.16 +# version 2 for more details (a copy is included in the LICENSE file that
   35.17 +# accompanied this code).
   35.18 +# 
   35.19 +# You should have received a copy of the GNU General Public License version
   35.20 +# 2 along with this work; if not, write to the Free Software Foundation,
   35.21 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   35.22 +#
   35.23 +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   35.24 +# or visit www.oracle.com if you need additional information or have any
   35.25 +# questions.
   35.26 +
   35.27 +# @test
   35.28 +# @bug 7110104
   35.29 +# @build JMXStartStopTest JMXStartStopDoSomething
   35.30 +# @run shell JMXStartStopTest.sh --jtreg --no-compile
   35.31 +# @summary No word Failed expected in the test output
   35.32 +
   35.33 +_verbose=no
   35.34 +_server=no
   35.35 +_jtreg=no
   35.36 +_compile=yes
   35.37 +_testsuite="01,02,03,04,05,06,07,08,09,10,11,12,13"
   35.38 +_port_one=50234
   35.39 +_port_two=50235
   35.40 +
   35.41 +
   35.42 +_testclasses=".classes"
   35.43 +_testsrc=`pwd`
   35.44 +
   35.45 +_logname=".classes/JMXStartStopTest_output.txt"
   35.46 +
   35.47 +
   35.48 +_compile(){
   35.49 +
   35.50 +    if [ ! -e ${_testclasses} ]
   35.51 +    then
   35.52 +	  mkdir -p ${_testclasses} 
   35.53 +    fi   
   35.54 +
   35.55 +    rm -f ${_testclasses}/JMXStartStopTest.class
   35.56 +
   35.57 +    # Compile testcase
   35.58 +    ${TESTJAVA}/bin/javac -d ${_testclasses} JMXStartStopDoSomething.java JMXStartStopTest.java 
   35.59 +
   35.60 +    if [ ! -e ${_testclasses}/JMXStartStopTest.class ]
   35.61 +    then
   35.62 +      echo "ERROR: Can't compile"
   35.63 +      exit -1
   35.64 +    fi
   35.65 +}
   35.66 +
   35.67 +_app_start(){
   35.68 +
   35.69 +  if [ "${_verbose}" = "yes" ]
   35.70 +  then
   35.71 +     echo "RUN: ${TESTJAVA}/bin/java -server $* -cp ${_testclasses} JMXStartStopDoSomething "
   35.72 +  fi 
   35.73 +  ${TESTJAVA}/bin/java -server $* -cp ${_testclasses} JMXStartStopDoSomething  >> ${_logname} 2>&1 &
   35.74 +  sleep 1 
   35.75 +
   35.76 +  pid=`_get_pid`
   35.77 +  if [ "x${pid}" = "x" ]
   35.78 +  then
   35.79 +     echo "ERROR: Test app not started"
   35.80 +     exit -1
   35.81 +  fi
   35.82 +
   35.83 +}
   35.84 +
   35.85 +_get_pid(){
   35.86 +    ${TESTJAVA}/bin/jps | sed -n "/JMXStartStopDoSomething/s/ .*//p"
   35.87 +}
   35.88 +
   35.89 +_app_stop(){
   35.90 +    pid=`_get_pid`
   35.91 +    if [ "x${pid}" != "x" ]
   35.92 +    then
   35.93 +       kill $pid
   35.94 +    fi
   35.95 +
   35.96 +    # Stop on first failed test under jtreg
   35.97 +    if [ "x$1" = "xFailed" -a "${_jtreg}" = "yes" ]
   35.98 +    then
   35.99 +      exit -1
  35.100 +    fi
  35.101 +}
  35.102 +   
  35.103 +testme(){
  35.104 +    ${TESTJAVA}/bin/java -cp ${_testclasses} JMXStartStopTest $*
  35.105 +}   
  35.106 +
  35.107 +  
  35.108 +_jcmd(){
  35.109 +  if [ "${_verbose}" = "yes" ]
  35.110 +  then
  35.111 +     echo "RUN: ${TESTJAVA}/bin/jcmd JMXStartStopDoSomething $*"
  35.112 +     ${TESTJAVA}/bin/jcmd JMXStartStopDoSomething $* 
  35.113 +  else
  35.114 +     ${TESTJAVA}/bin/jcmd JMXStartStopDoSomething $* > /dev/null 2>/dev/null
  35.115 +  fi
  35.116 +} 
  35.117 +
  35.118 +_echo(){
  35.119 +    echo "$*"
  35.120 +    echo "$*" >> ${_logname}
  35.121 +}
  35.122 +   
  35.123 +# ============= TESTS ======================================
  35.124 +   
  35.125 +test_01(){
  35.126 +# Run an app with JMX enabled stop it and 
  35.127 +# restart on other port
  35.128 +		
  35.129 +    _echo "**** Test one ****"		
  35.130 +
  35.131 +    _app_start  -Dcom.sun.management.jmxremote.port=$1 \
  35.132 +                -Dcom.sun.management.jmxremote.authenticate=false \
  35.133 +	        -Dcom.sun.management.jmxremote.ssl=false 
  35.134 +
  35.135 +    res1=`testme $1`
  35.136 +
  35.137 +    _jcmd ManagementAgent.stop
  35.138 +
  35.139 +    res2=`testme $1`
  35.140 +
  35.141 +    _jcmd ManagementAgent.start jmxremote.port=$2
  35.142 +
  35.143 +    res3=`testme $2`
  35.144 +
  35.145 +
  35.146 +    if [ "${res1}" = "OK_CONN" -a "${res2}" = "NO_CONN" -a "${res3}" = "OK_CONN" ] 
  35.147 +    then
  35.148 +	_echo "Passed"
  35.149 +    else
  35.150 +	_echo "Failed r1(OK):${res1} r2(NO):${res2} r3(OK):${res3}"
  35.151 +    _app_stop "Failed"
  35.152 +    fi
  35.153 +
  35.154 +    _app_stop
  35.155 +
  35.156 +}  
  35.157 +   
  35.158 +test_02(){
  35.159 +# Run an app without JMX enabled 
  35.160 +# start JMX by jcmd
  35.161 +
  35.162 +_echo "**** Test two ****"		
  35.163 +_app_start  
  35.164 +
  35.165 +_jcmd ManagementAgent.start jmxremote.port=$1 jmxremote.authenticate=false jmxremote.ssl=false 
  35.166 +
  35.167 +res1=`testme $1`
  35.168 +
  35.169 +if [ "${res1}" = "OK_CONN" ] 
  35.170 +then
  35.171 +    _echo "Passed"
  35.172 +else
  35.173 +    _echo "Failed r1(OK):${res1}"
  35.174 +    _app_stop "Failed"
  35.175 +fi
  35.176 +
  35.177 +_app_stop
  35.178 +
  35.179 +}   
  35.180 +   
  35.181 +test_03(){
  35.182 +# Run an app without JMX enabled 
  35.183 +# start JMX by jcmd on one port than on other one
  35.184 +
  35.185 +_echo "**** Test three ****"		
  35.186 +_app_start  
  35.187 +
  35.188 +_jcmd ManagementAgent.start jmxremote.port=$1 jmxremote.authenticate=false jmxremote.ssl=false 
  35.189 +
  35.190 +# Second agent shouldn't start
  35.191 +_jcmd ManagementAgent.start jmxremote.port=$2 jmxremote.authenticate=false jmxremote.ssl=false
  35.192 +
  35.193 +# First agent should connect
  35.194 +res1=`testme $1`
  35.195 +
  35.196 +if [ "${res1}" = "OK_CONN" ] 
  35.197 +then
  35.198 +    _echo "Passed $1"
  35.199 +else
  35.200 +    _echo "Failed r1(NO):${res1}"
  35.201 +    _app_stop "Failed"
  35.202 +fi
  35.203 +
  35.204 +#Second agent shouldn't connect
  35.205 +res1=`testme $2`
  35.206 +
  35.207 +if [ "${res1}" = "NO_CONN" ] 
  35.208 +then
  35.209 +    _echo "Passed $2"
  35.210 +else
  35.211 +    _echo "Failed r1(OK):${res1}"
  35.212 +fi
  35.213 +
  35.214 +_app_stop
  35.215 +}   
  35.216 +   
  35.217 +test_04(){
  35.218 +# Run an app without JMX enabled 
  35.219 +# start JMX by jcmd on one port, specify rmi port explicitly
  35.220 +
  35.221 +_echo "**** Test four ****"		
  35.222 +_app_start  
  35.223 +
  35.224 +_jcmd ManagementAgent.start jmxremote.port=$1 jmxremote.rmi.port=$2 jmxremote.authenticate=false jmxremote.ssl=false 
  35.225 +
  35.226 +# First agent should connect
  35.227 +res1=`testme $1 $2`
  35.228 +
  35.229 +if [ "${res1}" = "OK_CONN" ] 
  35.230 +then
  35.231 +    _echo "Passed $1 $2"
  35.232 +else
  35.233 +    _echo "Failed r1(NO):${res1}"
  35.234 +    _app_stop "Failed"
  35.235 +fi
  35.236 +
  35.237 +_app_stop
  35.238 +}   
  35.239 +
  35.240 +test_05(){
  35.241 +# Run an app without JMX enabled, it will enable local server
  35.242 +# but should leave remote server disabled  
  35.243 +
  35.244 +_echo "**** Test five ****"		
  35.245 +_app_start  
  35.246 +
  35.247 +_jcmd ManagementAgent.start jmxremote=1 
  35.248 +
  35.249 +# First agent should connect
  35.250 +res1=`testme $1`
  35.251 +
  35.252 +if [ "${res1}" = "NO_CONN" ] 
  35.253 +then
  35.254 +    _echo "Passed $1 $2"
  35.255 +else
  35.256 +    _echo "Failed r1(OK):${res1}"
  35.257 +    _app_stop "Failed"
  35.258 +fi
  35.259 +
  35.260 +_app_stop
  35.261 +}   
  35.262 +
  35.263 +test_06(){
  35.264 +# Run an app without JMX enabled 
  35.265 +# start JMX by jcmd on one port, specify rmi port explicitly
  35.266 +# attempt to start it again
  35.267 +# 1) with the same port 
  35.268 +# 2) with other port
  35.269 +# 3) attempt to stop it twice
  35.270 +# Check for valid messages in the output	
  35.271 +
  35.272 +_echo "**** Test six ****"		
  35.273 +_app_start  
  35.274 +
  35.275 +_jcmd ManagementAgent.start jmxremote.port=$1 jmxremote.authenticate=false jmxremote.ssl=false 
  35.276 +
  35.277 +# First agent should connect
  35.278 +res1=`testme $1 $2`
  35.279 +
  35.280 +if [ "${res1}" = "OK_CONN" ] 
  35.281 +then
  35.282 +    _echo "Passed $1 $2"
  35.283 +else
  35.284 +    _echo "Failed r1(NO):${res1}"
  35.285 +    _app_stop "Failed"
  35.286 +fi
  35.287 +
  35.288 +_jcmd ManagementAgent.start jmxremote.port=$1 jmxremote.authenticate=false jmxremote.ssl=false 
  35.289 +
  35.290 +_jcmd ManagementAgent.start jmxremote.port=$2 jmxremote.authenticate=false jmxremote.ssl=false 
  35.291 +
  35.292 +_jcmd ManagementAgent.stop
  35.293 +
  35.294 +_jcmd ManagementAgent.stop
  35.295 +
  35.296 +_jcmd ManagementAgent.start jmxremote.port=22 jmxremote.rmi.port=$2 jmxremote.authenticate=false jmxremote.ssl=false 
  35.297 +
  35.298 +_app_stop
  35.299 +}   
  35.300 +
  35.301 +test_07(){
  35.302 +# Run an app without JMX enabled, but with some properties set 
  35.303 +# in command line.
  35.304 +# make sure these properties overriden corectly 
  35.305 +
  35.306 +_echo "**** Test seven ****"		
  35.307 +
  35.308 +_app_start   -Dcom.sun.management.jmxremote.authenticate=false \
  35.309 +             -Dcom.sun.management.jmxremote.ssl=true 
  35.310 +
  35.311 +res1=`testme $1`
  35.312 +
  35.313 +_jcmd ManagementAgent.start jmxremote.port=$2 jmxremote.authenticate=false jmxremote.ssl=false
  35.314 +
  35.315 +res2=`testme $2`
  35.316 +
  35.317 +
  35.318 +if [ "${res1}" = "NO_CONN" -a "${res2}" = "OK_CONN" ] 
  35.319 +then
  35.320 +   echo "Passed"
  35.321 +else
  35.322 +	_echo "Failed r1(NO):${res1} r2(OK):${res2}"
  35.323 +    _app_stop "Failed"
  35.324 +fi
  35.325 +
  35.326 +_app_stop
  35.327 +}   
  35.328 +
  35.329 +test_08(){
  35.330 +# Run an app with JMX enabled and with some properties set 
  35.331 +# in command line.
  35.332 +# stop JMX agent and then start it again with different property values
  35.333 +# make sure these properties overriden corectly 
  35.334 +
  35.335 +_echo "**** Test eight ****"		
  35.336 +
  35.337 +_app_start  -Dcom.sun.management.jmxremote.port=$1 \
  35.338 +	    -Dcom.sun.management.jmxremote.authenticate=false \
  35.339 +	    -Dcom.sun.management.jmxremote.ssl=true 
  35.340 +
  35.341 +res1=`testme $1`
  35.342 +
  35.343 +_jcmd ManagementAgent.stop
  35.344 +
  35.345 +res2=`testme $1`
  35.346 +
  35.347 +_jcmd ManagementAgent.start jmxremote.port=$2 jmxremote.authenticate=false jmxremote.ssl=false
  35.348 +
  35.349 +res3=`testme $2`
  35.350 +
  35.351 +
  35.352 +if [ "${res1}" = "NO_CONN" -a "${res2}" = "NO_CONN" -a "${res3}" = "OK_CONN" ] 
  35.353 +then
  35.354 +    _echo "Passed"
  35.355 +else
  35.356 +    _echo "Failed r1(NO):${res1} r2(NO):${res2} r3(OK):${res3}"
  35.357 +    _app_stop "Failed"
  35.358 +fi
  35.359 + 
  35.360 +_app_stop
  35.361 +}   
  35.362 +
  35.363 +test_09(){
  35.364 +# Run an app with JMX enabled and with some properties set 
  35.365 +# in command line.
  35.366 +# stop JMX agent and then start it again with different property values
  35.367 +# specifing some property in management config file and some of them
  35.368 +# in command line
  35.369 +# make sure these properties overriden corectly 
  35.370 +
  35.371 +_echo "**** Test nine ****"		
  35.372 +
  35.373 +_app_start -Dcom.sun.management.config.file=${_testsrc}/management_cl.properties \
  35.374 +           -Dcom.sun.management.jmxremote.authenticate=false 
  35.375 +
  35.376 +res1=`testme $1`
  35.377 +
  35.378 +_jcmd ManagementAgent.stop
  35.379 +
  35.380 +res2=`testme $1`
  35.381 +
  35.382 +_jcmd ManagementAgent.start config.file=${_testsrc}/management_jcmd.properties \
  35.383 +       jmxremote.authenticate=false jmxremote.port=$2
  35.384 +
  35.385 +res3=`testme $2`
  35.386 +
  35.387 +if [ "${res1}" = "NO_CONN" -a "${res2}" = "NO_CONN" -a "${res3}" = "OK_CONN" ] 
  35.388 +then
  35.389 +    _echo "Passed"
  35.390 +else
  35.391 +    _echo "Failed r1(NO):${res1} r2(NO):${res2} r3(OK):${res3}"
  35.392 +    _app_stop "Failed"
  35.393 +fi
  35.394 + 
  35.395 +_app_stop
  35.396 +}   
  35.397 +
  35.398 +test_10(){
  35.399 +# Run an app with JMX enabled and with some properties set 
  35.400 +# in command line.
  35.401 +# stop JMX agent and then start it again with different property values
  35.402 +# stop JMX agent again and then start it without property value
  35.403 +# make sure these properties overriden corectly 
  35.404 +
  35.405 +_echo "**** Test ten ****"		
  35.406 +
  35.407 +_app_start  -Dcom.sun.management.jmxremote.port=$1 \
  35.408 +	    -Dcom.sun.management.jmxremote.authenticate=false \
  35.409 +	    -Dcom.sun.management.jmxremote.ssl=true 
  35.410 +
  35.411 +res1=`testme $1`
  35.412 +
  35.413 +_jcmd ManagementAgent.stop
  35.414 +_jcmd ManagementAgent.start jmxremote.ssl=false jmxremote.port=$1
  35.415 +
  35.416 +
  35.417 +res2=`testme $1`
  35.418 +
  35.419 +_jcmd ManagementAgent.stop
  35.420 +_jcmd ManagementAgent.start jmxremote.port=$1
  35.421 +
  35.422 +res3=`testme $1`
  35.423 +
  35.424 +if [ "${res1}" = "NO_CONN" -a "${res2}" = "OK_CONN" -a "${res3}" = "NO_CONN" ] 
  35.425 +then
  35.426 +    _echo "Passed"
  35.427 +else
  35.428 +    _echo "Failed r1(NO):${res1} r2(OK):${res2} r3(NO):${res3}"
  35.429 +    _app_stop "Failed"
  35.430 +fi
  35.431 + 
  35.432 +_app_stop
  35.433 +}   
  35.434 +
  35.435 +test_11(){
  35.436 +# Run an app with JMX enabled 
  35.437 +# stop remote agent 
  35.438 +# make sure local agent is not affected
  35.439 +
  35.440 +_echo "**** Test eleven ****"		
  35.441 +
  35.442 +_app_start  -Dcom.sun.management.jmxremote.port=$2 \
  35.443 +	    -Dcom.sun.management.jmxremote.authenticate=false \
  35.444 +	    -Dcom.sun.management.jmxremote.ssl=false 
  35.445 +	  
  35.446 +res1=`testme $2`
  35.447 +
  35.448 +_jcmd ManagementAgent.stop
  35.449 +
  35.450 +pid=`${TESTJAVA}/bin/jps | sed -n "/JMXStartStopDoSomething/s/ .*//p"`
  35.451 +res2=`testme local ${pid}`
  35.452 +
  35.453 +if [ "${res1}" = "OK_CONN" -a "${res2}" = "OK_CONN" ] 
  35.454 +then
  35.455 +    _echo "Passed"
  35.456 +else
  35.457 +    _echo "Failed r1(OK):${res1} r2(OK):${res2}"
  35.458 +    _app_stop "Failed"
  35.459 +fi
  35.460 + 
  35.461 +_app_stop
  35.462 +}   
  35.463 +
  35.464 +test_12(){
  35.465 +# Run an app with JMX disabled 
  35.466 +# start local agent only
  35.467 +
  35.468 +_echo "**** Test twelve ****"		
  35.469 +
  35.470 +_app_start 
  35.471 +	  
  35.472 +res1=`testme $1`
  35.473 +
  35.474 +_jcmd ManagementAgent.start_local
  35.475 +
  35.476 +pid=`_get_pid`
  35.477 +if [ "x${pid}" = "x" ]
  35.478 +then
  35.479 +  res2="NO_CONN"
  35.480 +else
  35.481 +  res2=`testme local ${pid}`
  35.482 +fi
  35.483 +
  35.484 +if [ "${res1}" = "NO_CONN" -a "${res2}" = "OK_CONN" ] 
  35.485 +then
  35.486 +    _echo "Passed"
  35.487 +else
  35.488 +    _echo "Failed r1(NO):${res1} r2(OK):${res2}"
  35.489 +    _app_stop "Failed"
  35.490 +fi
  35.491 + 
  35.492 +_app_stop
  35.493 +}   
  35.494 +
  35.495 +test_13(){
  35.496 +# Run an app with -javaagent make sure it works as expected - system properties are ignored
  35.497 +
  35.498 +_echo "**** Test 13 ****"		
  35.499 +
  35.500 +AGENT="${TESTJAVA}/jre/lib/management-agent.jar"
  35.501 +if [ ! -f ${AGENT} ]
  35.502 + then
  35.503 +  AGENT="${TESTJAVA}/lib/management-agent.jar"
  35.504 +fi
  35.505 +
  35.506 +_app_start -javaagent:${AGENT}=com.sun.management.jmxremote.port=$1,com.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false 
  35.507 +	  
  35.508 +res1=`testme $1`
  35.509 +
  35.510 +if [ "${res1}" = "NO_CONN" ] 
  35.511 +then
  35.512 +    _echo "Passed"
  35.513 +else
  35.514 +    _echo "Failed r1(NO):${res1}"
  35.515 +    _app_stop "Failed"
  35.516 +fi
  35.517 + 
  35.518 +_app_stop
  35.519 +}   
  35.520 +
  35.521 +
  35.522 +#============== Server tests =======================
  35.523 +
  35.524 +server_test_01(){
  35.525 +		
  35.526 +    _echo "**** Server test one ****"		
  35.527 +
  35.528 +    _app_start  -Dcom.sun.management.jmxremote.port=$1 \
  35.529 +                -Dcom.sun.management.jmxremote.rmi.port=$2 \
  35.530 +                -Dcom.sun.management.jmxremote.authenticate=false \
  35.531 +                -Dcom.sun.management.jmxremote.ssl=false 
  35.532 +
  35.533 +}  
  35.534 +
  35.535 + 
  35.536 +# ============= MAIN =======================================
  35.537 +
  35.538 +if [ "x${TESTJAVA}" = "x" ]
  35.539 +then
  35.540 +  echo "TESTJAVA env have to be set"
  35.541 +  exit
  35.542 +fi
  35.543 +
  35.544 +if [ ! -x "${TESTJAVA}/bin/jcmd" ]
  35.545 +then
  35.546 +  echo "${TESTJAVA}/bin/jcmd"
  35.547 +  echo "Doesn't exist or not an executable"
  35.548 +
  35.549 +  if [ "${_verbose}" != "yes" ]
  35.550 +  then
  35.551 +    exit
  35.552 +  fi
  35.553 +fi
  35.554 +
  35.555 +
  35.556 +#------------------------------------------------------------------------------
  35.557 +# reading parameters 
  35.558 +
  35.559 +for parm in "$@"  
  35.560 +do
  35.561 +   case $parm in
  35.562 +  --verbose)      _verbose=yes  ;;
  35.563 +  --server)       _server=yes   ;;
  35.564 +  --jtreg)        _jtreg=yes    ;;
  35.565 +  --no-compile)   _compile=no   ;;
  35.566 +  --testsuite=*)  _testsuite=`_echo $parm | sed "s,^--.*=\(.*\),\1,"`  ;;
  35.567 +  --port-one=*)   _port_one=`_echo $parm | sed "s,^--.*=\(.*\),\1,"`  ;;
  35.568 +  --port-two=*)   _port_two=`_echo $parm | sed "s,^--.*=\(.*\),\1,"`  ;;
  35.569 +  *) 
  35.570 +     echo "Undefined parameter $parm. Try --help for help" 
  35.571 +     exit 
  35.572 +   ;;
  35.573 + esac 
  35.574 +done
  35.575 +
  35.576 +if [ ${_compile} = "yes" ]
  35.577 +then
  35.578 + _compile
  35.579 +fi
  35.580 +
  35.581 +if [ ${_jtreg} = "yes" ]
  35.582 +then
  35.583 + _testclasses=${TESTCLASSES}
  35.584 + _testsrc=${TESTSRC}
  35.585 + _logname="JMXStartStopTest_output.txt"
  35.586 +fi
  35.587 +
  35.588 +rm -f ${_logname}
  35.589 +
  35.590 +# Start server mode tests
  35.591 +# All of them require manual cleanup
  35.592 +if [ "x${_server}" = "xyes" ]
  35.593 +then
  35.594 +  
  35.595 + server_test_01 ${_port_one} ${_port_two}
  35.596 +
  35.597 +else
  35.598 +
  35.599 + # Local mode tests
  35.600 + for i in `echo ${_testsuite} | sed -e "s/,/ /g"`
  35.601 + do
  35.602 +  test_${i} ${_port_one} ${_port_two}
  35.603 + done
  35.604 +
  35.605 +fi
  35.606 +
    36.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    36.2 +++ b/test/sun/management/jmxremote/startstop/REMOTE_TESTING.txt	Mon Mar 05 17:04:10 2012 -0800
    36.3 @@ -0,0 +1,11 @@
    36.4 +1. Setup two hosts
    36.5 +2. Make sure tcp connection between them works
    36.6 +3. run tcpdump -i <interface> host <host2_name> and 'tcp[13] & 2!=0'
    36.7 +   on host 1
    36.8 +4. run JMXStartStopTest.sh --server on host2
    36.9 +5. run jconsole on host1
   36.10 +6. connect jconsole to host2:50234
   36.11 +   Make sure jconsole works
   36.12 +   Make sure only host2.50234 and host2.50235 appears in tcpdump output.
   36.13 +
   36.14 +
    37.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    37.2 +++ b/test/sun/management/jmxremote/startstop/management_cl.properties	Mon Mar 05 17:04:10 2012 -0800
    37.3 @@ -0,0 +1,2 @@
    37.4 +com.sun.management.jmxremote.ssl=true
    37.5 +com.sun.management.internal.read_from_config_file_cl=true
    38.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    38.2 +++ b/test/sun/management/jmxremote/startstop/management_jcmd.properties	Mon Mar 05 17:04:10 2012 -0800
    38.3 @@ -0,0 +1,3 @@
    38.4 +com.sun.management.jmxremote.ssl=false
    38.5 +jmxremote.authenticate=true
    38.6 +com.sun.management.internal.read_from_config_file_jcmd=true
    39.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    39.2 +++ b/test/sun/security/provider/PolicyFile/NullCodeSource.java	Mon Mar 05 17:04:10 2012 -0800
    39.3 @@ -0,0 +1,44 @@
    39.4 +/*
    39.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    39.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    39.7 + *
    39.8 + * This code is free software; you can redistribute it and/or modify it
    39.9 + * under the terms of the GNU General Public License version 2 only, as
   39.10 + * published by the Free Software Foundation.
   39.11 + *
   39.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   39.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   39.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   39.15 + * version 2 for more details (a copy is included in the LICENSE file that
   39.16 + * accompanied this code).
   39.17 + *
   39.18 + * You should have received a copy of the GNU General Public License version
   39.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   39.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   39.21 + *
   39.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   39.23 + * or visit www.oracle.com if you need additional information or have any
   39.24 + * questions.
   39.25 + */
   39.26 +
   39.27 +/*
   39.28 + * @test
   39.29 + * @bug 7147830
   39.30 + * @summary PolicyFile.getPermissions(CodeSource) should return
   39.31 + *          empty permissions when passed in null code source
   39.32 + */
   39.33 +
   39.34 +import java.security.CodeSource;
   39.35 +import java.security.PermissionCollection;
   39.36 +import java.security.Policy;
   39.37 +
   39.38 +public class NullCodeSource {
   39.39 +    public static void main(String[] args) throws Exception {
   39.40 +        Policy policy = Policy.getPolicy();
   39.41 +        PermissionCollection perms = policy.getPermissions((CodeSource)null);
   39.42 +        if (perms.elements().hasMoreElements()) {
   39.43 +            System.err.println(perms);
   39.44 +            throw new Exception("PermissionCollection is not empty");
   39.45 +        }
   39.46 +    }
   39.47 +}
    40.1 --- a/test/tools/launcher/Settings.java	Thu Mar 01 12:23:25 2012 -0800
    40.2 +++ b/test/tools/launcher/Settings.java	Mon Mar 05 17:04:10 2012 -0800
    40.3 @@ -75,14 +75,14 @@
    40.4      static void runTestOptionDefault() throws IOException {
    40.5          TestResult tr = null;
    40.6          tr = doExec(javaCmd, "-Xms64m", "-Xmx512m",
    40.7 -                "-Xss128k", "-XshowSettings", "-jar", testJar.getAbsolutePath());
    40.8 +                "-Xss256k", "-XshowSettings", "-jar", testJar.getAbsolutePath());
    40.9          containsAllOptions(tr);
   40.10          if (!tr.isOK()) {
   40.11              System.out.println(tr.status);
   40.12              throw new RuntimeException("test fails");
   40.13          }
   40.14          tr = doExec(javaCmd, "-Xms65536k", "-Xmx712m",
   40.15 -                "-Xss122880", "-XshowSettings", "-jar", testJar.getAbsolutePath());
   40.16 +                "-Xss256000", "-XshowSettings", "-jar", testJar.getAbsolutePath());
   40.17          containsAllOptions(tr);
   40.18          if (!tr.isOK()) {
   40.19              System.out.println(tr.status);