4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE
authormalenkov
Wed, 07 May 2008 23:20:32 +0400
changeset 466 6acd5ec503a8
parent 465 507ce3a1af17
child 467 3bcc915c0925
4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE Summary: Add the Transient annotation and support it (JSR-273) Reviewed-by: peterz, loneid
jdk/src/share/classes/java/awt/Component.java
jdk/src/share/classes/java/awt/Dimension.java
jdk/src/share/classes/java/awt/Point.java
jdk/src/share/classes/java/awt/Rectangle.java
jdk/src/share/classes/java/awt/ScrollPane.java
jdk/src/share/classes/java/awt/geom/RectangularShape.java
jdk/src/share/classes/java/awt/im/InputContext.java
jdk/src/share/classes/java/beans/DefaultPersistenceDelegate.java
jdk/src/share/classes/java/beans/EventSetDescriptor.java
jdk/src/share/classes/java/beans/FeatureDescriptor.java
jdk/src/share/classes/java/beans/IndexedPropertyDescriptor.java
jdk/src/share/classes/java/beans/MetaData.java
jdk/src/share/classes/java/beans/PropertyDescriptor.java
jdk/src/share/classes/java/beans/Transient.java
jdk/src/share/classes/javax/swing/AbstractButton.java
jdk/src/share/classes/javax/swing/DefaultListSelectionModel.java
jdk/src/share/classes/javax/swing/ImageIcon.java
jdk/src/share/classes/javax/swing/JComboBox.java
jdk/src/share/classes/javax/swing/JComponent.java
jdk/src/share/classes/javax/swing/JLabel.java
jdk/src/share/classes/javax/swing/JList.java
jdk/src/share/classes/javax/swing/JMenuBar.java
jdk/src/share/classes/javax/swing/JScrollPane.java
jdk/src/share/classes/javax/swing/JTabbedPane.java
jdk/src/share/classes/javax/swing/JViewport.java
jdk/src/share/classes/javax/swing/table/JTableHeader.java
jdk/src/share/classes/javax/swing/text/JTextComponent.java
jdk/test/java/beans/Introspector/BeanUtils.java
jdk/test/java/beans/Introspector/Test4896879.java
jdk/test/java/beans/Introspector/Test4935607.java
jdk/test/java/beans/XMLEncoder/Test4935607.java
--- a/jdk/src/share/classes/java/awt/Component.java	Wed May 07 21:54:03 2008 +0400
+++ b/jdk/src/share/classes/java/awt/Component.java	Wed May 07 23:20:32 2008 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright 1995-2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1995-2008 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -49,6 +49,7 @@
 import java.io.IOException;
 import java.beans.PropertyChangeListener;
 import java.beans.PropertyChangeSupport;
+import java.beans.Transient;
 import java.awt.event.InputMethodListener;
 import java.awt.event.InputMethodEvent;
 import java.awt.im.InputContext;
@@ -1100,6 +1101,7 @@
      * @see #setVisible
      * @since JDK1.0
      */
+    @Transient
     public boolean isVisible() {
         return isVisible_NoClientCode();
     }
@@ -1531,6 +1533,7 @@
      * @beaninfo
      *       bound: true
      */
+    @Transient
     public Color getForeground() {
         Color foreground = this.foreground;
         if (foreground != null) {
@@ -1585,6 +1588,7 @@
      * @see #setBackground
      * @since JDK1.0
      */
+    @Transient
     public Color getBackground() {
         Color background = this.background;
         if (background != null) {
@@ -1644,6 +1648,7 @@
      * @see #setFont
      * @since JDK1.0
      */
+    @Transient
     public Font getFont() {
         return getFont_NoClientCode();
     }
--- a/jdk/src/share/classes/java/awt/Dimension.java	Wed May 07 21:54:03 2008 +0400
+++ b/jdk/src/share/classes/java/awt/Dimension.java	Wed May 07 23:20:32 2008 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright 1995-2006 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1995-2008 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
 package java.awt;
 
 import java.awt.geom.Dimension2D;
+import java.beans.Transient;
 
 /**
  * The <code>Dimension</code> class encapsulates the width and
@@ -165,6 +166,7 @@
      * @see      java.awt.Component#getSize
      * @since    1.1
      */
+    @Transient
     public Dimension getSize() {
         return new Dimension(width, height);
     }
--- a/jdk/src/share/classes/java/awt/Point.java	Wed May 07 21:54:03 2008 +0400
+++ b/jdk/src/share/classes/java/awt/Point.java	Wed May 07 23:20:32 2008 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright 1995-2006 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1995-2008 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
 package java.awt;
 
 import java.awt.geom.Point2D;
+import java.beans.Transient;
 
 /**
  * A point representing a location in {@code (x,y)} coordinate space,
@@ -119,6 +120,7 @@
      * @see         java.awt.Point#setLocation(int, int)
      * @since       1.1
      */
+    @Transient
     public Point getLocation() {
         return new Point(x, y);
     }
--- a/jdk/src/share/classes/java/awt/Rectangle.java	Wed May 07 21:54:03 2008 +0400
+++ b/jdk/src/share/classes/java/awt/Rectangle.java	Wed May 07 23:20:32 2008 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright 1995-2006 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1995-2008 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
 package java.awt;
 
 import java.awt.geom.Rectangle2D;
+import java.beans.Transient;
 
 /**
  * A <code>Rectangle</code> specifies an area in a coordinate space that is
@@ -308,6 +309,7 @@
      * @see       #setBounds(int, int, int, int)
      * @since     1.1
      */
+    @Transient
     public Rectangle getBounds() {
         return new Rectangle(x, y, width, height);
     }
--- a/jdk/src/share/classes/java/awt/ScrollPane.java	Wed May 07 21:54:03 2008 +0400
+++ b/jdk/src/share/classes/java/awt/ScrollPane.java	Wed May 07 23:20:32 2008 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright 1996-2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1996-2008 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,6 +32,7 @@
 import sun.awt.SunToolkit;
 
 import java.beans.ConstructorProperties;
+import java.beans.Transient;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.io.IOException;
@@ -390,6 +391,7 @@
      * @throws NullPointerException if the scrollpane does not contain
      *     a child
      */
+    @Transient
     public Point getScrollPosition() {
         if (ncomponents <= 0) {
             throw new NullPointerException("child is null");
--- a/jdk/src/share/classes/java/awt/geom/RectangularShape.java	Wed May 07 21:54:03 2008 +0400
+++ b/jdk/src/share/classes/java/awt/geom/RectangularShape.java	Wed May 07 23:20:32 2008 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright 1997-2006 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1997-2008 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
 
 import java.awt.Shape;
 import java.awt.Rectangle;
+import java.beans.Transient;
 
 /**
  * <code>RectangularShape</code> is the base class for a number of
@@ -171,6 +172,7 @@
      * @see #setFrame(Rectangle2D)
      * @since 1.2
      */
+    @Transient
     public Rectangle2D getFrame() {
         return new Rectangle2D.Double(getX(), getY(), getWidth(), getHeight());
     }
--- a/jdk/src/share/classes/java/awt/im/InputContext.java	Wed May 07 21:54:03 2008 +0400
+++ b/jdk/src/share/classes/java/awt/im/InputContext.java	Wed May 07 23:20:32 2008 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright 1997-2005 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1997-2008 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,7 @@
 import java.awt.Component;
 import java.util.Locale;
 import java.awt.AWTEvent;
+import java.beans.Transient;
 import java.lang.Character.Subset;
 import sun.awt.im.InputMethodContext;
 
@@ -231,6 +232,7 @@
      * @see #setCompositionEnabled
      * @since 1.3
      */
+    @Transient
     public boolean isCompositionEnabled() {
         // real implementation is in sun.awt.im.InputContext
         return false;
--- a/jdk/src/share/classes/java/beans/DefaultPersistenceDelegate.java	Wed May 07 21:54:03 2008 +0400
+++ b/jdk/src/share/classes/java/beans/DefaultPersistenceDelegate.java	Wed May 07 23:20:32 2008 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2006 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2000-2008 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -164,53 +164,19 @@
         return new Expression(oldInstance, oldInstance.getClass(), "new", constructorArgs);
     }
 
-    private Method findMethod(Class type, String property) throws IntrospectionException {
+    private Method findMethod(Class type, String property) {
         if (property == null) {
             throw new IllegalArgumentException("Property name is null");
         }
-        BeanInfo info = Introspector.getBeanInfo(type);
-        for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
-            if (property.equals(pd.getName())) {
-                Method method = pd.getReadMethod();
-                if (method != null) {
-                    return method;
-                }
-                throw new IllegalStateException("Could not find getter for the property " + property);
-            }
-        }
-        throw new IllegalStateException("Could not find property by the name " + property);
-    }
-
-    // This is a workaround for a bug in the introspector.
-    // PropertyDescriptors are not shared amongst subclasses.
-    private boolean isTransient(Class type, PropertyDescriptor pd) {
-        if (type == null) {
-            return false;
+        PropertyDescriptor pd = getPropertyDescriptor(type, property);
+        if (pd == null) {
+            throw new IllegalStateException("Could not find property by the name " + property);
         }
-        // This code was mistakenly deleted - it may be fine and
-        // is more efficient than the code below. This should
-        // all disappear anyway when property descriptors are shared
-        // by the introspector.
-        /*
-        Method getter = pd.getReadMethod();
-        Class declaringClass = getter.getDeclaringClass();
-        if (declaringClass == type) {
-            return Boolean.TRUE.equals(pd.getValue("transient"));
+        Method method = pd.getReadMethod();
+        if (method == null) {
+            throw new IllegalStateException("Could not find getter for the property " + property);
         }
-        */
-        String pName = pd.getName();
-        BeanInfo info = MetaData.getBeanInfo(type);
-        PropertyDescriptor[] propertyDescriptors = info.getPropertyDescriptors();
-        for (int i = 0; i < propertyDescriptors.length; ++i ) {
-            PropertyDescriptor pd2 = propertyDescriptors[i];
-            if (pName.equals(pd2.getName())) {
-                Object value = pd2.getValue("transient");
-                if (value != null) {
-                    return Boolean.TRUE.equals(value);
-                }
-            }
-        }
-        return isTransient(type.getSuperclass(), pd);
+        return method;
     }
 
     private static boolean equals(Object o1, Object o2) {
@@ -221,7 +187,7 @@
         Method getter = pd.getReadMethod();
         Method setter = pd.getWriteMethod();
 
-        if (getter != null && setter != null && !isTransient(type, pd)) {
+        if (getter != null && setter != null) {
             Expression oldGetExp = new Expression(oldInstance, getter.getName(), new Object[]{});
             Expression newGetExp = new Expression(newInstance, getter.getName(), new Object[]{});
             Object oldValue = oldGetExp.getValue();
@@ -254,14 +220,19 @@
 
     // Write out the properties of this instance.
     private void initBean(Class type, Object oldInstance, Object newInstance, Encoder out) {
-        // System.out.println("initBean: " + oldInstance);
-        BeanInfo info = MetaData.getBeanInfo(type);
-
+        BeanInfo info;
+        try {
+            info = Introspector.getBeanInfo(type);
+        } catch (IntrospectionException exception) {
+            return;
+        }
         // Properties
-        PropertyDescriptor[] propertyDescriptors = info.getPropertyDescriptors();
-        for (int i = 0; i < propertyDescriptors.length; ++i ) {
+        for (PropertyDescriptor d : info.getPropertyDescriptors()) {
+            if (d.isTransient()) {
+                continue;
+            }
             try {
-                doProperty(type, propertyDescriptors[i], oldInstance, newInstance, out);
+                doProperty(type, d, oldInstance, newInstance, out);
             }
             catch (Exception e) {
                 out.getExceptionListener().exceptionThrown(e);
@@ -295,9 +266,10 @@
         if (!java.awt.Component.class.isAssignableFrom(type)) {
             return; // Just handle the listeners of Components for now.
         }
-        EventSetDescriptor[] eventSetDescriptors = info.getEventSetDescriptors();
-        for (int e = 0; e < eventSetDescriptors.length; e++) {
-            EventSetDescriptor d = eventSetDescriptors[e];
+        for (EventSetDescriptor d : info.getEventSetDescriptors()) {
+            if (d.isTransient()) {
+                continue;
+            }
             Class listenerType = d.getListenerType();
 
 
@@ -408,4 +380,15 @@
             initBean(type, oldInstance, newInstance, out);
         }
     }
+
+    private static PropertyDescriptor getPropertyDescriptor(Class type, String property) {
+        try {
+            for (PropertyDescriptor pd : Introspector.getBeanInfo(type).getPropertyDescriptors()) {
+                if (property.equals(pd.getName()))
+                    return pd;
+            }
+        } catch (IntrospectionException exception) {
+        }
+        return null;
+    }
 }
--- a/jdk/src/share/classes/java/beans/EventSetDescriptor.java	Wed May 07 21:54:03 2008 +0400
+++ b/jdk/src/share/classes/java/beans/EventSetDescriptor.java	Wed May 07 23:20:32 2008 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright 1996-2005 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1996-2008 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -369,6 +369,7 @@
             setClass0(method.getDeclaringClass());
         }
         addMethodDescriptor = new MethodDescriptor(method);
+        setTransient(method.getAnnotation(Transient.class));
     }
 
     /**
@@ -389,6 +390,7 @@
             setClass0(method.getDeclaringClass());
         }
         removeMethodDescriptor = new MethodDescriptor(method);
+        setTransient(method.getAnnotation(Transient.class));
     }
 
     /**
@@ -411,6 +413,7 @@
             setClass0(method.getDeclaringClass());
         }
         getMethodDescriptor = new MethodDescriptor(method);
+        setTransient(method.getAnnotation(Transient.class));
     }
 
     /**
--- a/jdk/src/share/classes/java/beans/FeatureDescriptor.java	Wed May 07 21:54:03 2008 +0400
+++ b/jdk/src/share/classes/java/beans/FeatureDescriptor.java	Wed May 07 23:20:32 2008 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright 1996-2004 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1996-2008 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,7 +32,9 @@
 import java.lang.ref.SoftReference;
 
 import java.lang.reflect.Method;
-import java.lang.reflect.Type;
+
+import java.util.Enumeration;
+import java.util.Hashtable;
 
 /**
  * The FeatureDescriptor class is the common baseclass for PropertyDescriptor,
@@ -46,6 +48,7 @@
  */
 
 public class FeatureDescriptor {
+    private static final String TRANSIENT = "transient";
 
     private Reference<Class> classRef;
 
@@ -187,10 +190,7 @@
      * @param value  The value.
      */
     public void setValue(String attributeName, Object value) {
-        if (table == null) {
-            table = new java.util.Hashtable();
-        }
-        table.put(attributeName, value);
+        getTable().put(attributeName, value);
     }
 
     /**
@@ -201,10 +201,9 @@
      *     the attribute is unknown.
      */
     public Object getValue(String attributeName) {
-        if (table == null) {
-           return null;
-        }
-        return table.get(attributeName);
+        return (this.table != null)
+                ? this.table.get(attributeName)
+                : null;
     }
 
     /**
@@ -214,11 +213,8 @@
      * @return  An enumeration of the locale-independent names of any
      *    attributes that have been registered with setValue.
      */
-    public java.util.Enumeration<String> attributeNames() {
-        if (table == null) {
-            table = new java.util.Hashtable();
-        }
-        return table.keys();
+    public Enumeration<String> attributeNames() {
+        return getTable().keys();
     }
 
     /**
@@ -268,18 +264,56 @@
         addTable(old.table);
     }
 
-    private void addTable(java.util.Hashtable t) {
-        if (t == null) {
-            return;
+    /**
+     * Copies all values from the specified attribute table.
+     * If some attribute is exist its value should be overridden.
+     *
+     * @param table  the attribute table with new values
+     */
+    private void addTable(Hashtable<String, Object> table) {
+        if ((table != null) && !table.isEmpty()) {
+            getTable().putAll(table);
+        }
+    }
+
+    /**
+     * Returns the initialized attribute table.
+     *
+     * @return the initialized attribute table
+     */
+    private Hashtable<String, Object> getTable() {
+        if (this.table == null) {
+            this.table = new Hashtable<String, Object>();
         }
-        java.util.Enumeration keys = t.keys();
-        while (keys.hasMoreElements()) {
-            String key = (String)keys.nextElement();
-            Object value = t.get(key);
-            setValue(key, value);
+        return this.table;
+    }
+
+    /**
+     * Sets the "transient" attribute according to the annotation.
+     * If the "transient" attribute is already set
+     * it should not be changed.
+     *
+     * @param annotation  the annotation of the element of the feature
+     */
+    void setTransient(Transient annotation) {
+        if ((annotation != null) && (null == getValue(TRANSIENT))) {
+            setValue(TRANSIENT, annotation.value());
         }
     }
 
+    /**
+     * Indicates whether the feature is transient.
+     *
+     * @return {@code true} if the feature is transient,
+     *         {@code false} otherwise
+     */
+    boolean isTransient() {
+        Object value = getValue(TRANSIENT);
+        return (value instanceof Boolean)
+                ? (Boolean) value
+                : false;
+    }
+
     // Package private methods for recreating the weak/soft referent
 
     void setClass0(Class cls) {
@@ -293,39 +327,6 @@
     }
 
     /**
-     * Create a Reference wrapper for the object.
-     *
-     * @param obj object that will be wrapped
-     * @param soft true if a SoftReference should be created; otherwise Soft
-     * @return a Reference or null if obj is null.
-     */
-    static Reference createReference(Object obj, boolean soft) {
-        Reference ref = null;
-        if (obj != null) {
-            if (soft) {
-                ref = new SoftReference(obj);
-            } else {
-                ref = new WeakReference(obj);
-            }
-        }
-        return ref;
-    }
-
-    // Convenience method which creates a WeakReference.
-    static Reference createReference(Object obj) {
-        return createReference(obj, false);
-    }
-
-    /**
-     * Returns an object from a Reference wrapper.
-     *
-     * @return the Object in a wrapper or null.
-     */
-    static Object getObject(Reference ref) {
-        return (ref == null) ? null : (Object)ref.get();
-    }
-
-    /**
      * Creates a new soft reference that refers to the given object.
      *
      * @return a new soft reference or <code>null</code> if object is <code>null</code>
@@ -391,5 +392,5 @@
     private String shortDescription;
     private String name;
     private String displayName;
-    private java.util.Hashtable table;
+    private Hashtable<String, Object> table;
 }
--- a/jdk/src/share/classes/java/beans/IndexedPropertyDescriptor.java	Wed May 07 21:54:03 2008 +0400
+++ b/jdk/src/share/classes/java/beans/IndexedPropertyDescriptor.java	Wed May 07 23:20:32 2008 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright 1996-2004 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1996-2008 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -231,6 +231,7 @@
 
         indexedReadMethodName = readMethod.getName();
         this.indexedReadMethodRef = getSoftReference(readMethod);
+        setTransient(readMethod.getAnnotation(Transient.class));
     }
 
 
@@ -303,6 +304,7 @@
 
         indexedWriteMethodName = writeMethod.getName();
         this.indexedWriteMethodRef = getSoftReference(writeMethod);
+        setTransient(writeMethod.getAnnotation(Transient.class));
     }
 
     /**
--- a/jdk/src/share/classes/java/beans/MetaData.java	Wed May 07 21:54:03 2008 +0400
+++ b/jdk/src/share/classes/java/beans/MetaData.java	Wed May 07 23:20:32 2008 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2000-2008 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1352,7 +1352,6 @@
 
 class MetaData {
     private static Hashtable internalPersistenceDelegates = new Hashtable();
-    private static Hashtable transientProperties = new Hashtable();
 
     private static PersistenceDelegate nullPersistenceDelegate = new NullPersistenceDelegate();
     private static PersistenceDelegate enumPersistenceDelegate = new EnumPersistenceDelegate();
@@ -1383,94 +1382,6 @@
 
         internalPersistenceDelegates.put("java.util.JumboEnumSet", new java_util_EnumSet_PersistenceDelegate());
         internalPersistenceDelegates.put("java.util.RegularEnumSet", new java_util_EnumSet_PersistenceDelegate());
-
-// Transient properties
-
-  // awt
-
-    // Infinite graphs.
-        removeProperty("java.awt.geom.RectangularShape", "frame");
-        // removeProperty("java.awt.Rectangle2D", "frame");
-        // removeProperty("java.awt.Rectangle", "frame");
-
-        removeProperty("java.awt.Rectangle", "bounds");
-        removeProperty("java.awt.Dimension", "size");
-        removeProperty("java.awt.Point", "location");
-
-        // The color and font properties in Component need special treatment, see above.
-        removeProperty("java.awt.Component", "foreground");
-        removeProperty("java.awt.Component", "background");
-        removeProperty("java.awt.Component", "font");
-
-        // The visible property of Component needs special treatment because of Windows.
-        removeProperty("java.awt.Component", "visible");
-
-        // This property throws an exception if accessed when there is no child.
-        removeProperty("java.awt.ScrollPane", "scrollPosition");
-
-        // 4917458 this should be removed for XAWT since it may throw
-        // an unsupported exception if there isn't any input methods.
-        // This shouldn't be a problem since these are added behind
-        // the scenes automatically.
-        removeProperty("java.awt.im.InputContext", "compositionEnabled");
-
-  // swing
-
-        // The size properties in JComponent need special treatment, see above.
-        removeProperty("javax.swing.JComponent", "minimumSize");
-        removeProperty("javax.swing.JComponent", "preferredSize");
-        removeProperty("javax.swing.JComponent", "maximumSize");
-
-        // These properties have platform specific implementations
-        // and should not appear in archives.
-        removeProperty("javax.swing.ImageIcon", "image");
-        removeProperty("javax.swing.ImageIcon", "imageObserver");
-
-        // This property unconditionally throws a "not implemented" exception.
-        removeProperty("javax.swing.JMenuBar", "helpMenu");
-
-        // The scrollBars in a JScrollPane are dynamic and should not
-        // be archived. The row and columns headers are changed by
-        // components like JTable on "addNotify".
-        removeProperty("javax.swing.JScrollPane", "verticalScrollBar");
-        removeProperty("javax.swing.JScrollPane", "horizontalScrollBar");
-        removeProperty("javax.swing.JScrollPane", "rowHeader");
-        removeProperty("javax.swing.JScrollPane", "columnHeader");
-
-        removeProperty("javax.swing.JViewport", "extentSize");
-
-        // Renderers need special treatment, since their properties
-        // change during rendering.
-        removeProperty("javax.swing.table.JTableHeader", "defaultRenderer");
-        removeProperty("javax.swing.JList", "cellRenderer");
-
-        removeProperty("javax.swing.JList", "selectedIndices");
-
-        // The lead and anchor selection indexes are best ignored.
-        // Selection is rarely something that should persist from
-        // development to deployment.
-        removeProperty("javax.swing.DefaultListSelectionModel", "leadSelectionIndex");
-        removeProperty("javax.swing.DefaultListSelectionModel", "anchorSelectionIndex");
-
-        // The selection must come after the text itself.
-        removeProperty("javax.swing.JComboBox", "selectedIndex");
-
-        // All selection information should come after the JTabbedPane is built
-        removeProperty("javax.swing.JTabbedPane", "selectedIndex");
-        removeProperty("javax.swing.JTabbedPane", "selectedComponent");
-
-        // PENDING: The "disabledIcon" property is often computed from the icon property.
-        removeProperty("javax.swing.AbstractButton", "disabledIcon");
-        removeProperty("javax.swing.JLabel", "disabledIcon");
-
-        // The caret property throws errors when it it set beyond
-        // the extent of the text. We could just set it after the
-        // text, but this is probably not something we want to archive anyway.
-        removeProperty("javax.swing.text.JTextComponent", "caret");
-        removeProperty("javax.swing.text.JTextComponent", "caretPosition");
-        // The selectionStart must come after the text itself.
-        removeProperty("javax.swing.text.JTextComponent", "selectionStart");
-        removeProperty("javax.swing.text.JTextComponent", "selectionEnd");
     }
 
     /*pp*/ static boolean equals(Object o1, Object o2) {
@@ -1509,18 +1420,6 @@
         // }
 
         String typeName = type.getName();
-
-        // Check to see if there are properties that have been lazily registered for removal.
-        if (getBeanAttribute(type, "transient_init") == null) {
-            Vector tp = (Vector)transientProperties.get(typeName);
-            if (tp != null) {
-                for(int i = 0; i < tp.size(); i++) {
-                    setPropertyAttribute(type, (String)tp.get(i), "transient", Boolean.TRUE);
-                }
-            }
-            setBeanAttribute(type, "transient_init", Boolean.TRUE);
-        }
-
         PersistenceDelegate pd = (PersistenceDelegate)getBeanAttribute(type, "persistenceDelegate");
         if (pd == null) {
             pd = (PersistenceDelegate)internalPersistenceDelegates.get(typeName);
@@ -1583,55 +1482,11 @@
         return true;
     }
 
-    // Wrapper for Introspector.getBeanInfo to handle exception handling.
-    // Note: this relys on new 1.4 Introspector semantics which cache the BeanInfos
-    public static BeanInfo getBeanInfo(Class type) {
-        BeanInfo info = null;
+    private static Object getBeanAttribute(Class type, String attribute) {
         try {
-            info = Introspector.getBeanInfo(type);
-        } catch (Throwable e) {
-            e.printStackTrace();
-        }
-
-        return info;
-    }
-
-    private static PropertyDescriptor getPropertyDescriptor(Class type, String propertyName) {
-        BeanInfo info = getBeanInfo(type);
-        PropertyDescriptor[] propertyDescriptors = info.getPropertyDescriptors();
-        // System.out.println("Searching for: " + propertyName + " in " + type);
-        for(int i = 0; i < propertyDescriptors.length; i++) {
-            PropertyDescriptor pd  = propertyDescriptors[i];
-            if (propertyName.equals(pd.getName())) {
-                return pd;
-            }
+            return Introspector.getBeanInfo(type).getBeanDescriptor().getValue(attribute);
+        } catch (IntrospectionException exception) {
+            return null;
         }
-        return null;
-    }
-
-    private static void setPropertyAttribute(Class type, String property, String attribute, Object value) {
-        PropertyDescriptor pd = getPropertyDescriptor(type, property);
-        if (pd == null) {
-            System.err.println("Warning: property " + property + " is not defined on " + type);
-            return;
-        }
-        pd.setValue(attribute, value);
-    }
-
-    private static void setBeanAttribute(Class type, String attribute, Object value) {
-        getBeanInfo(type).getBeanDescriptor().setValue(attribute, value);
-    }
-
-    private static Object getBeanAttribute(Class type, String attribute) {
-        return getBeanInfo(type).getBeanDescriptor().getValue(attribute);
-    }
-
-    private static void removeProperty(String typeName, String property) {
-        Vector tp = (Vector)transientProperties.get(typeName);
-        if (tp == null) {
-            tp = new Vector();
-            transientProperties.put(typeName, tp);
-        }
-        tp.add(property);
     }
 }
--- a/jdk/src/share/classes/java/beans/PropertyDescriptor.java	Wed May 07 21:54:03 2008 +0400
+++ b/jdk/src/share/classes/java/beans/PropertyDescriptor.java	Wed May 07 23:20:32 2008 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright 1996-2004 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1996-2008 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -256,6 +256,7 @@
 
         readMethodName = readMethod.getName();
         this.readMethodRef = getSoftReference(readMethod);
+        setTransient(readMethod.getAnnotation(Transient.class));
     }
 
     /**
@@ -320,7 +321,7 @@
 
         writeMethodName = writeMethod.getName();
         this.writeMethodRef = getSoftReference(writeMethod);
-
+        setTransient(writeMethod.getAnnotation(Transient.class));
     }
 
     private Method getReadMethod0() {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/beans/Transient.java	Wed May 07 23:20:32 2008 +0400
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package java.beans;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * Indicates that an attribute called "transient"
+ * should be declared with the given {@code value}
+ * when the {@link Introspector} constructs
+ * a {@link PropertyDescriptor} or {@link EventSetDescriptor}
+ * classes associated with the annotated code element.
+ * A {@code true} value for the "transient" attribute
+ * indicates to encoders derived from {@link Encoder}
+ * that this feature should be ignored.
+ * <p/>
+ * The {@code Transient} annotation may be be used
+ * in any of the methods that are involved
+ * in a {@link FeatureDescriptor} subclass
+ * to identify the transient feature in the annotated class and its subclasses.
+ * Normally, the method that starts with "get" is the best place
+ * to put the annotation and it is this declaration
+ * that takes precedence in the case of multiple annotations
+ * being defined for the same feature.
+ * <p/>
+ * To declare a feature non-transient in a class
+ * whose superclass declares it transient,
+ * use {@code @Transient(false)}.
+ * In all cases, the {@link Introspector} decides
+ * if a feature is transient by referring to the annotation
+ * on the most specific superclass.
+ * If no {@code Transient} annotation is present
+ * in any superclass the feature is not transient.
+ *
+ * @since 1.7
+ */
+@Target({METHOD})
+@Retention(RUNTIME)
+public @interface Transient {
+    boolean value() default true;
+}
--- a/jdk/src/share/classes/javax/swing/AbstractButton.java	Wed May 07 21:54:03 2008 +0400
+++ b/jdk/src/share/classes/javax/swing/AbstractButton.java	Wed May 07 23:20:32 2008 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright 1997-2006 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1997-2008 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,9 @@
 import java.awt.image.*;
 import java.text.*;
 import java.awt.geom.*;
-import java.beans.*;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.Transient;
 import java.util.Enumeration;
 import java.util.Vector;
 import java.io.Serializable;
@@ -645,6 +647,7 @@
      * @see #setDisabledIcon
      * @see javax.swing.LookAndFeel#getDisabledIcon
      */
+    @Transient
     public Icon getDisabledIcon() {
         if (disabledIcon == null) {
             disabledIcon = UIManager.getLookAndFeel().getDisabledIcon(this, getIcon());
--- a/jdk/src/share/classes/javax/swing/DefaultListSelectionModel.java	Wed May 07 21:54:03 2008 +0400
+++ b/jdk/src/share/classes/javax/swing/DefaultListSelectionModel.java	Wed May 07 23:20:32 2008 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright 1997-2006 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1997-2008 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,7 @@
 import java.util.EventListener;
 import java.util.BitSet;
 import java.io.Serializable;
+import java.beans.Transient;
 
 import javax.swing.event.*;
 
@@ -714,11 +715,13 @@
     }
 
     /** {@inheritDoc} */
+    @Transient
     public int getAnchorSelectionIndex() {
         return anchorIndex;
     }
 
     /** {@inheritDoc} */
+    @Transient
     public int getLeadSelectionIndex() {
         return leadIndex;
     }
--- a/jdk/src/share/classes/javax/swing/ImageIcon.java	Wed May 07 21:54:03 2008 +0400
+++ b/jdk/src/share/classes/javax/swing/ImageIcon.java	Wed May 07 23:20:32 2008 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright 1997-2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1997-2008 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
 import java.awt.*;
 import java.awt.image.*;
 import java.beans.ConstructorProperties;
+import java.beans.Transient;
 import java.net.URL;
 
 import java.io.Serializable;
@@ -336,6 +337,7 @@
      * Returns this icon's <code>Image</code>.
      * @return the <code>Image</code> object for this <code>ImageIcon</code>
      */
+    @Transient
     public Image getImage() {
         return image;
     }
@@ -436,6 +438,7 @@
      *
      * @return the image observer, which may be null
      */
+    @Transient
     public ImageObserver getImageObserver() {
         return imageObserver;
     }
--- a/jdk/src/share/classes/javax/swing/JComboBox.java	Wed May 07 21:54:03 2008 +0400
+++ b/jdk/src/share/classes/javax/swing/JComboBox.java	Wed May 07 23:20:32 2008 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright 1997-2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1997-2008 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,7 +24,9 @@
  */
 package javax.swing;
 
-import java.beans.*;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.Transient;
 import java.util.*;
 
 import java.awt.*;
@@ -636,6 +638,7 @@
      *                  or -1 if no item is selected or if
      *                  the currently selected item is not in the list
      */
+    @Transient
     public int getSelectedIndex() {
         Object sObject = dataModel.getSelectedItem();
         int i,c;
--- a/jdk/src/share/classes/javax/swing/JComponent.java	Wed May 07 21:54:03 2008 +0400
+++ b/jdk/src/share/classes/javax/swing/JComponent.java	Wed May 07 23:20:32 2008 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright 1997-2006 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1997-2008 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -43,7 +43,10 @@
 import java.awt.peer.LightweightPeer;
 import java.awt.dnd.DropTarget;
 import java.awt.font.FontRenderContext;
-import java.beans.*;
+import java.beans.PropertyChangeListener;
+import java.beans.VetoableChangeListener;
+import java.beans.VetoableChangeSupport;
+import java.beans.Transient;
 
 import java.applet.Applet;
 
@@ -1634,6 +1637,7 @@
      * @see #setPreferredSize
      * @see ComponentUI
      */
+    @Transient
     public Dimension getPreferredSize() {
         if (isPreferredSizeSet()) {
             return super.getPreferredSize();
@@ -1675,6 +1679,7 @@
      * @see #setMaximumSize
      * @see ComponentUI
      */
+    @Transient
     public Dimension getMaximumSize() {
         if (isMaximumSizeSet()) {
             return super.getMaximumSize();
@@ -1714,6 +1719,7 @@
      * @see #setMinimumSize
      * @see ComponentUI
      */
+    @Transient
     public Dimension getMinimumSize() {
         if (isMinimumSizeSet()) {
             return super.getMinimumSize();
--- a/jdk/src/share/classes/javax/swing/JLabel.java	Wed May 07 21:54:03 2008 +0400
+++ b/jdk/src/share/classes/javax/swing/JLabel.java	Wed May 07 23:20:32 2008 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright 1997-2006 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1997-2008 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,7 @@
 import java.awt.*;
 import java.text.*;
 import java.awt.geom.*;
+import java.beans.Transient;
 
 import java.io.ObjectOutputStream;
 import java.io.ObjectInputStream;
@@ -422,6 +423,7 @@
      * @see javax.swing.LookAndFeel#getDisabledIcon
      * @see ImageIcon
      */
+    @Transient
     public Icon getDisabledIcon() {
         if (!disabledIconSet && disabledIcon == null && defaultIcon != null) {
             disabledIcon = UIManager.getLookAndFeel().getDisabledIcon(this, defaultIcon);
--- a/jdk/src/share/classes/javax/swing/JList.java	Wed May 07 21:54:03 2008 +0400
+++ b/jdk/src/share/classes/javax/swing/JList.java	Wed May 07 23:20:32 2008 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright 1997-2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1997-2008 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,7 +31,9 @@
 import java.util.Vector;
 import java.util.Locale;
 
-import java.beans.*;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.Transient;
 
 import javax.swing.event.*;
 import javax.accessibility.*;
@@ -724,6 +726,7 @@
      * @return the value of the {@code cellRenderer} property
      * @see #setCellRenderer
      */
+    @Transient
     public ListCellRenderer getCellRenderer() {
         return cellRenderer;
     }
@@ -2153,6 +2156,7 @@
      * @see #removeSelectionInterval
      * @see #addListSelectionListener
      */
+    @Transient
     public int[] getSelectedIndices() {
         ListSelectionModel sm = getSelectionModel();
         int iMin = sm.getMinSelectionIndex();
--- a/jdk/src/share/classes/javax/swing/JMenuBar.java	Wed May 07 21:54:03 2008 +0400
+++ b/jdk/src/share/classes/javax/swing/JMenuBar.java	Wed May 07 23:20:32 2008 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright 1997-2006 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1997-2008 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,6 +32,7 @@
 import java.awt.Point;
 import java.awt.Rectangle;
 import java.awt.event.*;
+import java.beans.Transient;
 import java.util.Vector;
 import java.util.Enumeration;
 
@@ -236,6 +237,7 @@
      *
      * @return the <code>JMenu</code> that delivers help to the user
      */
+    @Transient
     public JMenu getHelpMenu() {
         throw new Error("getHelpMenu() not yet implemented.");
     }
--- a/jdk/src/share/classes/javax/swing/JScrollPane.java	Wed May 07 21:54:03 2008 +0400
+++ b/jdk/src/share/classes/javax/swing/JScrollPane.java	Wed May 07 23:20:32 2008 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright 1997-2006 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1997-2008 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -43,8 +43,9 @@
 import java.io.ObjectInputStream;
 import java.io.IOException;
 
-import java.beans.*;
-
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.Transient;
 
 /**
  * Provides a scrollable view of a lightweight component.
@@ -822,6 +823,7 @@
      * @return the <code>horizontalScrollBar</code> property
      * @see #setHorizontalScrollBar
      */
+    @Transient
     public JScrollBar getHorizontalScrollBar() {
         return horizontalScrollBar;
     }
@@ -880,6 +882,7 @@
      * @return the <code>verticalScrollBar</code> property
      * @see #setVerticalScrollBar
      */
+    @Transient
     public JScrollBar getVerticalScrollBar() {
         return verticalScrollBar;
     }
@@ -1012,6 +1015,7 @@
      * @return the <code>rowHeader</code> property
      * @see #setRowHeader
      */
+    @Transient
     public JViewport getRowHeader() {
         return rowHeader;
     }
@@ -1081,6 +1085,7 @@
      * @return the <code>columnHeader</code> property
      * @see #setColumnHeader
      */
+    @Transient
     public JViewport getColumnHeader() {
         return columnHeader;
     }
--- a/jdk/src/share/classes/javax/swing/JTabbedPane.java	Wed May 07 21:54:03 2008 +0400
+++ b/jdk/src/share/classes/javax/swing/JTabbedPane.java	Wed May 07 23:20:32 2008 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright 1997-2006 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1997-2008 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,7 @@
 
 import java.awt.*;
 import java.awt.event.*;
-import java.beans.*;
+import java.beans.Transient;
 import java.util.*;
 import javax.swing.event.*;
 import javax.swing.plaf.*;
@@ -563,6 +563,7 @@
      * @return the index of the selected tab
      * @see #setSelectedIndex
      */
+    @Transient
     public int getSelectedIndex() {
         return model.getSelectedIndex();
     }
@@ -648,6 +649,7 @@
      * @return the component corresponding to the selected tab
      * @see #setSelectedComponent
      */
+    @Transient
     public Component getSelectedComponent() {
         int index = getSelectedIndex();
         if (index == -1) {
--- a/jdk/src/share/classes/javax/swing/JViewport.java	Wed May 07 21:54:03 2008 +0400
+++ b/jdk/src/share/classes/javax/swing/JViewport.java	Wed May 07 23:20:32 2008 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright 1997-2006 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1997-2008 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,6 +30,7 @@
 import java.awt.image.VolatileImage;
 import java.awt.peer.ComponentPeer;
 import java.applet.Applet;
+import java.beans.Transient;
 import javax.swing.plaf.ViewportUI;
 
 import javax.swing.event.*;
@@ -1257,6 +1258,7 @@
      *
      * @return a <code>Dimension</code> object giving the size of the view
      */
+    @Transient
     public Dimension getExtentSize() {
         return getSize();
     }
--- a/jdk/src/share/classes/javax/swing/table/JTableHeader.java	Wed May 07 21:54:03 2008 +0400
+++ b/jdk/src/share/classes/javax/swing/table/JTableHeader.java	Wed May 07 23:20:32 2008 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright 1997-2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1997-2008 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,6 +37,7 @@
 import javax.accessibility.*;
 
 import java.beans.PropertyChangeListener;
+import java.beans.Transient;
 
 import java.io.ObjectOutputStream;
 import java.io.ObjectInputStream;
@@ -325,6 +326,7 @@
      * @return the default renderer
      * @since 1.3
      */
+    @Transient
     public TableCellRenderer getDefaultRenderer() {
         return defaultRenderer;
     }
--- a/jdk/src/share/classes/javax/swing/text/JTextComponent.java	Wed May 07 21:54:03 2008 +0400
+++ b/jdk/src/share/classes/javax/swing/text/JTextComponent.java	Wed May 07 23:20:32 2008 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright 1997-2006 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1997-2008 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,7 @@
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 
+import java.beans.Transient;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Hashtable;
@@ -571,6 +572,7 @@
      *
      * @return the caret
      */
+    @Transient
     public Caret getCaret() {
         return caret;
     }
@@ -1672,6 +1674,7 @@
      * @return the position of the text insertion caret for the
      *  text component >= 0
      */
+    @Transient
     public int getCaretPosition() {
         return caret.getDot();
     }
@@ -1797,6 +1800,7 @@
      *
      * @return the start position >= 0
      */
+    @Transient
     public int getSelectionStart() {
         int start = Math.min(caret.getDot(), caret.getMark());
         return start;
@@ -1829,6 +1833,7 @@
      *
      * @return the end position >= 0
      */
+    @Transient
     public int getSelectionEnd() {
         int end = Math.max(caret.getDot(), caret.getMark());
         return end;
--- a/jdk/test/java/beans/Introspector/BeanUtils.java	Wed May 07 21:54:03 2008 +0400
+++ b/jdk/test/java/beans/Introspector/BeanUtils.java	Wed May 07 23:20:32 2008 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright 2003-2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2003-2008 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,6 +21,7 @@
  * have any questions.
  */
 
+import java.beans.BeanDescriptor;
 import java.beans.EventSetDescriptor;
 import java.beans.IndexedPropertyDescriptor;
 import java.beans.IntrospectionException;
@@ -39,13 +40,26 @@
     }
 
     /**
+     * Returns a bean descriptor for specified class.
+     *
+     * @param type  the class to introspect
+     * @return a bean descriptor
+     */
+    public static BeanDescriptor getBeanDescriptor(Class type) {
+        try {
+            return Introspector.getBeanInfo(type).getBeanDescriptor();
+        } catch (IntrospectionException exception) {
+            throw new Error("unexpected exception", exception);
+        }
+    }
+
+    /**
      * Returns an array of property descriptors for specified class.
      *
      * @param type  the class to introspect
      * @return an array of property descriptors
      */
     public static PropertyDescriptor[] getPropertyDescriptors(Class type) {
-        System.out.println(type);
         try {
             return Introspector.getBeanInfo(type).getPropertyDescriptors();
         } catch (IntrospectionException exception) {
@@ -54,6 +68,38 @@
     }
 
     /**
+     * Returns an array of event set descriptors for specified class.
+     *
+     * @param type  the class to introspect
+     * @return an array of event set descriptors
+     */
+    public static EventSetDescriptor[] getEventSetDescriptors(Class type) {
+        try {
+            return Introspector.getBeanInfo(type).getEventSetDescriptors();
+        } catch (IntrospectionException exception) {
+            throw new Error("unexpected exception", exception);
+        }
+    }
+
+    /**
+     * Finds an event set descriptor for the class
+     * that matches the event set name.
+     *
+     * @param type  the class to introspect
+     * @param name  the name of the event set to search
+     * @return the {@code EventSetDescriptor} or {@code null}
+     */
+    public static EventSetDescriptor findEventSetDescriptor(Class type, String name) {
+        EventSetDescriptor[] esds = getEventSetDescriptors(type);
+        for (EventSetDescriptor esd : esds) {
+            if (esd.getName().equals(name)) {
+                return esd;
+            }
+        }
+        return null;
+    }
+
+    /**
      * Finds a property descriptor for the class
      * that matches the property name.
      *
@@ -72,6 +118,22 @@
     }
 
     /**
+     * Returns a event set descriptor for the class
+     * that matches the property name.
+     *
+     * @param type the class to introspect
+     * @param name the name of the event set to search
+     * @return the {@code EventSetDescriptor}
+     */
+    public static EventSetDescriptor getEventSetDescriptor(Class type, String name) {
+        EventSetDescriptor esd = findEventSetDescriptor(type, name);
+        if (esd != null) {
+            return esd;
+        }
+        throw new Error("could not find event set '" + name + "' in " + type);
+    }
+
+    /**
      * Returns a property descriptor for the class
      * that matches the property name.
      *
--- a/jdk/test/java/beans/Introspector/Test4896879.java	Wed May 07 21:54:03 2008 +0400
+++ b/jdk/test/java/beans/Introspector/Test4896879.java	Wed May 07 23:20:32 2008 +0400
@@ -28,22 +28,16 @@
  * @author Mark Davidson
  */
 
-import java.beans.BeanInfo;
-import java.beans.EventSetDescriptor;
-import java.beans.IntrospectionException;
-import java.beans.Introspector;
 import java.util.EventListener;
 
 public class Test4896879 {
-    public static void main(String[] args) throws IntrospectionException {
+    public static void main(String[] args) {
         test(A.class);
         test(B.class);
     }
 
-    private static void test(Class type) throws IntrospectionException {
-        BeanInfo info = Introspector.getBeanInfo(type);
-        EventSetDescriptor[] descriptors = info.getEventSetDescriptors();
-        if (descriptors.length != 0) {
+    private static void test(Class type) {
+        if (BeanUtils.getEventSetDescriptors(type).length != 0) {
             throw new Error("Should not have any EventSetDescriptors");
         }
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/Introspector/Test4935607.java	Wed May 07 23:20:32 2008 +0400
@@ -0,0 +1,404 @@
+/*
+ * Copyright 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test %I% %G%
+ * @bug 4935607
+ * @summary Tests transient properties
+ * @author Sergey Malenkov
+ */
+
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.ScrollPane;
+import java.awt.geom.RectangularShape;
+import java.awt.im.InputContext;
+
+import java.beans.FeatureDescriptor;
+import java.beans.Transient;
+
+import java.util.EventListener;
+
+import javax.swing.AbstractButton;
+import javax.swing.DefaultListSelectionModel;
+import javax.swing.ImageIcon;
+import javax.swing.JComboBox;
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JList;
+import javax.swing.JMenuBar;
+import javax.swing.JScrollPane;
+import javax.swing.JTabbedPane;
+import javax.swing.JViewport;
+import javax.swing.table.JTableHeader;
+import javax.swing.text.JTextComponent;
+
+public class Test4935607 {
+    public static void main(String[] args) {
+        // test all possible cases
+        test(Null.class);
+        test(True.class);
+        test(False.class);
+        test(NullNull.class);
+        test(TrueNull.class);
+        test(FalseNull.class);
+        test(NullTrue.class);
+        test(TrueTrue.class);
+        test(FalseTrue.class);
+        test(NullFalse.class);
+        test(TrueFalse.class);
+        test(FalseFalse.class);
+        // test transient properties in AWT
+        test(RectangularShape.class, "frame"); // NON-NLS: getFrame()
+        test(Rectangle.class, "bounds"); // NON-NLS: getBounds()
+        test(Dimension.class, "size"); // NON-NLS: getSize()
+        test(Point.class, "location"); // NON-NLS: getLocation()
+        test(Component.class, "foreground"); // NON-NLS: getForeground()
+        test(Component.class, "background"); // NON-NLS: getBackground()
+        test(Component.class, "font"); // NON-NLS: getFont()
+        test(Component.class, "visible"); // NON-NLS: getVisible()
+        test(ScrollPane.class, "scrollPosition"); // NON-NLS: getScrollPosition()
+        test(InputContext.class, "compositionEnabled"); // NON-NLS: getCompositionEnabled()
+        // test transient properties in Swing
+        test(JComponent.class, "minimumSize"); // NON-NLS: getMinimumSize()
+        test(JComponent.class, "preferredSize"); // NON-NLS: getPreferredSize()
+        test(JComponent.class, "maximumSize"); // NON-NLS: getMaximumSize()
+        test(ImageIcon.class, "image"); // NON-NLS: getImage()
+        test(ImageIcon.class, "imageObserver"); // NON-NLS: getImageObserver()
+        test(JMenuBar.class, "helpMenu"); // NON-NLS: getHelpMenu()
+        test(JScrollPane.class, "verticalScrollBar"); // NON-NLS: getVerticalScrollBar()
+        test(JScrollPane.class, "horizontalScrollBar"); // NON-NLS: getHorizontalScrollBar()
+        test(JScrollPane.class, "rowHeader"); // NON-NLS: getRowHeader()
+        test(JScrollPane.class, "columnHeader"); // NON-NLS: getColumnHeader()
+        test(JViewport.class, "extentSize"); // NON-NLS: getExtentSize()
+        test(JTableHeader.class, "defaultRenderer"); // NON-NLS: getDefaultRenderer()
+        test(JList.class, "cellRenderer"); // NON-NLS: getCellRenderer()
+        test(JList.class, "selectedIndices"); // NON-NLS: getSelectedIndices()
+        test(DefaultListSelectionModel.class, "leadSelectionIndex"); // NON-NLS: getLeadSelectionIndex()
+        test(DefaultListSelectionModel.class, "anchorSelectionIndex"); // NON-NLS: getAnchorSelectionIndex()
+        test(JComboBox.class, "selectedIndex"); // NON-NLS: getSelectedIndex()
+        test(JTabbedPane.class, "selectedIndex"); // NON-NLS: getSelectedIndex()
+        test(JTabbedPane.class, "selectedComponent"); // NON-NLS: getSelectedComponent()
+        test(AbstractButton.class, "disabledIcon"); // NON-NLS: getDisabledIcon()
+        test(JLabel.class, "disabledIcon"); // NON-NLS: getDisabledIcon()
+        test(JTextComponent.class, "caret"); // NON-NLS: getCaret()
+        test(JTextComponent.class, "caretPosition"); // NON-NLS: getCaretPosition()
+        test(JTextComponent.class, "selectionStart"); // NON-NLS: getSelectionStart()
+        test(JTextComponent.class, "selectionEnd"); // NON-NLS: getSelectionEnd()
+    }
+
+    private static void test(Class type) {
+        Object value = getExpectedValue(type);
+        test(value, BeanUtils.getPropertyDescriptor(type, "property")); // NON-NLS: the property to check
+        test(value, BeanUtils.getEventSetDescriptor(type, "eventSet")); // NON-NLS: the event set to check
+        System.out.println();
+    }
+
+    private static void test(Class type, String property) {
+        System.out.print(type.getName() + ": ");
+        test(Boolean.TRUE, BeanUtils.getPropertyDescriptor(type, property));
+    }
+
+    private static void test(Object expected, FeatureDescriptor fd) {
+        System.out.println(fd.getName());
+        Object actual = fd.getValue("transient"); // NON-NLS: the attribute name
+        if ((actual == null) ? (expected != null) : !actual.equals(expected))
+            throw new Error("expected " + expected + " value, but actual value is " + actual);
+    }
+
+    private static Object getExpectedValue(Class type) {
+        try {
+            return type.getField("VALUE").get(type); // NON-NLS: the field name with expected value
+        } catch (NoSuchFieldException exception) {
+            return null;
+        } catch (IllegalAccessException exception) {
+            throw new Error("unexpected error", exception);
+        }
+    }
+
+
+    public static class Null {
+        public Object getProperty() {
+            return this;
+        }
+
+        public void setProperty(Object object) {
+        }
+
+        public void addEventSetListener(EventSetListener listener) {
+        }
+
+        public void removeEventSetListener(EventSetListener listener) {
+        }
+    }
+
+    public static class True {
+        public static final Boolean VALUE = Boolean.TRUE;
+
+        @Transient
+        public Object getProperty() {
+            return this;
+        }
+
+        @Transient
+        public void setProperty(Object object) {
+        }
+
+        @Transient
+        public void addEventSetListener(EventSetListener listener) {
+        }
+
+        @Transient
+        public void removeEventSetListener(EventSetListener listener) {
+        }
+    }
+
+    public static class False {
+        public static final Boolean VALUE = Boolean.FALSE;
+
+        @Transient(false)
+        public Object getProperty() {
+            return this;
+        }
+
+        @Transient(false)
+        public void setProperty(Object object) {
+        }
+
+        @Transient(false)
+        public void addEventSetListener(EventSetListener listener) {
+        }
+
+        @Transient(false)
+        public void removeEventSetListener(EventSetListener listener) {
+        }
+    }
+
+    public static class NullNull extends Null {
+        @Override
+        public Object getProperty() {
+            return this;
+        }
+
+        @Override
+        public void setProperty(Object object) {
+        }
+
+        @Override
+        public void addEventSetListener(EventSetListener listener) {
+        }
+
+        @Override
+        public void removeEventSetListener(EventSetListener listener) {
+        }
+    }
+
+    public static class TrueNull extends Null {
+        public static final Boolean VALUE = Boolean.TRUE;
+
+        @Override
+        @Transient
+        public Object getProperty() {
+            return this;
+        }
+
+        @Override
+        @Transient
+        public void setProperty(Object object) {
+        }
+
+        @Override
+        @Transient
+        public void addEventSetListener(EventSetListener listener) {
+        }
+
+        @Override
+        @Transient
+        public void removeEventSetListener(EventSetListener listener) {
+        }
+    }
+
+    public static class FalseNull extends Null {
+        public static final Boolean VALUE = Boolean.FALSE;
+
+        @Override
+        @Transient(false)
+        public Object getProperty() {
+            return this;
+        }
+
+        @Override
+        @Transient(false)
+        public void setProperty(Object object) {
+        }
+
+        @Override
+        @Transient(false)
+        public void addEventSetListener(EventSetListener listener) {
+        }
+
+        @Override
+        @Transient(false)
+        public void removeEventSetListener(EventSetListener listener) {
+        }
+    }
+
+    public static class NullTrue extends True {
+        @Override
+        public Object getProperty() {
+            return this;
+        }
+
+        @Override
+        public void setProperty(Object object) {
+        }
+
+        @Override
+        public void addEventSetListener(EventSetListener listener) {
+        }
+
+        @Override
+        public void removeEventSetListener(EventSetListener listener) {
+        }
+    }
+
+    public static class TrueTrue extends True {
+        @Override
+        @Transient
+        public Object getProperty() {
+            return this;
+        }
+
+        @Override
+        @Transient
+        public void setProperty(Object object) {
+        }
+
+        @Override
+        @Transient
+        public void addEventSetListener(EventSetListener listener) {
+        }
+
+        @Override
+        @Transient
+        public void removeEventSetListener(EventSetListener listener) {
+        }
+    }
+
+    public static class FalseTrue extends True {
+        public static final Boolean VALUE = Boolean.FALSE;
+
+        @Override
+        @Transient(false)
+        public Object getProperty() {
+            return this;
+        }
+
+        @Override
+        @Transient(false)
+        public void setProperty(Object object) {
+        }
+
+        @Override
+        @Transient(false)
+        public void addEventSetListener(EventSetListener listener) {
+        }
+
+        @Override
+        @Transient(false)
+        public void removeEventSetListener(EventSetListener listener) {
+        }
+    }
+
+    public static class NullFalse extends False {
+        @Override
+        public Object getProperty() {
+            return this;
+        }
+
+        @Override
+        public void setProperty(Object object) {
+        }
+
+        @Override
+        public void addEventSetListener(EventSetListener listener) {
+        }
+
+        @Override
+        public void removeEventSetListener(EventSetListener listener) {
+        }
+    }
+
+    public static class TrueFalse extends False {
+        public static final Boolean VALUE = Boolean.TRUE;
+
+        @Override
+        @Transient
+        public Object getProperty() {
+            return this;
+        }
+
+        @Override
+        @Transient
+        public void setProperty(Object object) {
+        }
+
+        @Override
+        @Transient
+        public void addEventSetListener(EventSetListener listener) {
+        }
+
+        @Override
+        @Transient
+        public void removeEventSetListener(EventSetListener listener) {
+        }
+    }
+
+    public static class FalseFalse extends False {
+        @Override
+        @Transient(false)
+        public Object getProperty() {
+            return this;
+        }
+
+        @Override
+        @Transient(false)
+        public void setProperty(Object object) {
+        }
+
+        @Override
+        @Transient(false)
+        public void addEventSetListener(EventSetListener listener) {
+        }
+
+        @Override
+        @Transient(false)
+        public void removeEventSetListener(EventSetListener listener) {
+        }
+    }
+
+    public static final class EventSetListener implements EventListener {
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/XMLEncoder/Test4935607.java	Wed May 07 23:20:32 2008 +0400
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test %I% %G%
+ * @bug 4935607
+ * @summary Tests transient properties
+ * @author Sergey Malenkov
+ */
+
+import java.beans.Transient;
+
+public class Test4935607 extends AbstractTest<Test4935607.TransientBean> {
+    public static void main(String[] args) {
+        new Test4935607().test(true);
+    }
+
+    @Override
+    protected TransientBean getObject() {
+        TransientBean bean = new TransientBean();
+        bean.setName("some string"); // NON-NLS: some string
+        return bean;
+    }
+
+    @Override
+    protected TransientBean getAnotherObject() {
+        TransientBean bean = new TransientBean();
+        bean.setName("another string"); // NON-NLS: another string
+        bean.setComment("some comment"); // NON-NLS: some comment
+        return bean;
+    }
+
+    @Override
+    protected void validate(TransientBean before, TransientBean after) {
+        if (!before.getName().equals(after.getName()))
+            throw new Error("the name property incorrectly encoded");
+
+        if (null != after.getComment())
+            throw new Error("the comment property should be encoded");
+    }
+
+    public static class TransientBean {
+        private String name;
+        private String comment;
+
+        public String getName() {
+            return this.name;
+        }
+
+        public void setName(String name) {
+            this.name = name;
+        }
+
+        @Transient
+        public String getComment() {
+            return this.comment;
+        }
+
+        public void setComment(String comment) {
+            this.comment = comment;
+        }
+    }
+}