8043627: NPE in SynthContext in plugin mode
authormalenkov
Thu, 22 May 2014 21:05:30 +0400
changeset 25100 d527cc827d7d
parent 25099 ba8a24b2576f
child 25101 2b07b28079a1
8043627: NPE in SynthContext in plugin mode Reviewed-by: alexsch, serb, pchelko
jdk/src/share/classes/javax/swing/plaf/synth/SynthButtonUI.java
jdk/src/share/classes/javax/swing/plaf/synth/SynthColorChooserUI.java
jdk/src/share/classes/javax/swing/plaf/synth/SynthComboBoxUI.java
jdk/src/share/classes/javax/swing/plaf/synth/SynthContext.java
jdk/src/share/classes/javax/swing/plaf/synth/SynthDesktopIconUI.java
jdk/src/share/classes/javax/swing/plaf/synth/SynthDesktopPaneUI.java
jdk/src/share/classes/javax/swing/plaf/synth/SynthEditorPaneUI.java
jdk/src/share/classes/javax/swing/plaf/synth/SynthInternalFrameTitlePane.java
jdk/src/share/classes/javax/swing/plaf/synth/SynthInternalFrameUI.java
jdk/src/share/classes/javax/swing/plaf/synth/SynthLabelUI.java
jdk/src/share/classes/javax/swing/plaf/synth/SynthListUI.java
jdk/src/share/classes/javax/swing/plaf/synth/SynthMenuBarUI.java
jdk/src/share/classes/javax/swing/plaf/synth/SynthMenuItemUI.java
jdk/src/share/classes/javax/swing/plaf/synth/SynthMenuUI.java
jdk/src/share/classes/javax/swing/plaf/synth/SynthOptionPaneUI.java
jdk/src/share/classes/javax/swing/plaf/synth/SynthPanelUI.java
jdk/src/share/classes/javax/swing/plaf/synth/SynthPopupMenuUI.java
jdk/src/share/classes/javax/swing/plaf/synth/SynthProgressBarUI.java
jdk/src/share/classes/javax/swing/plaf/synth/SynthRootPaneUI.java
jdk/src/share/classes/javax/swing/plaf/synth/SynthScrollBarUI.java
jdk/src/share/classes/javax/swing/plaf/synth/SynthScrollPaneUI.java
jdk/src/share/classes/javax/swing/plaf/synth/SynthSeparatorUI.java
jdk/src/share/classes/javax/swing/plaf/synth/SynthSliderUI.java
jdk/src/share/classes/javax/swing/plaf/synth/SynthSpinnerUI.java
jdk/src/share/classes/javax/swing/plaf/synth/SynthSplitPaneUI.java
jdk/src/share/classes/javax/swing/plaf/synth/SynthTabbedPaneUI.java
jdk/src/share/classes/javax/swing/plaf/synth/SynthTableHeaderUI.java
jdk/src/share/classes/javax/swing/plaf/synth/SynthTableUI.java
jdk/src/share/classes/javax/swing/plaf/synth/SynthTextAreaUI.java
jdk/src/share/classes/javax/swing/plaf/synth/SynthTextFieldUI.java
jdk/src/share/classes/javax/swing/plaf/synth/SynthToolBarUI.java
jdk/src/share/classes/javax/swing/plaf/synth/SynthToolTipUI.java
jdk/src/share/classes/javax/swing/plaf/synth/SynthTreeUI.java
jdk/src/share/classes/javax/swing/plaf/synth/SynthViewportUI.java
jdk/test/javax/swing/plaf/synth/Test8043627.java
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthButtonUI.java	Thu May 22 15:46:50 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthButtonUI.java	Thu May 22 21:05:30 2014 +0400
@@ -138,9 +138,7 @@
     }
 
     SynthContext getContext(JComponent c, int state) {
-        Region region = SynthLookAndFeel.getRegion(c);
-        return SynthContext.getContext(SynthContext.class, c, region,
-                                       style, state);
+        return SynthContext.getContext(c, style, state);
     }
 
     /**
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthColorChooserUI.java	Thu May 22 15:46:50 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthColorChooserUI.java	Thu May 22 21:05:30 2014 +0400
@@ -128,8 +128,7 @@
     }
 
     private SynthContext getContext(JComponent c, int state) {
-        return SynthContext.getContext(SynthContext.class, c,
-                    SynthLookAndFeel.getRegion(c), style, state);
+        return SynthContext.getContext(c, style, state);
     }
 
     private int getComponentState(JComponent c) {
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthComboBoxUI.java	Thu May 22 15:46:50 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthComboBoxUI.java	Thu May 22 21:05:30 2014 +0400
@@ -208,8 +208,7 @@
     }
 
     private SynthContext getContext(JComponent c, int state) {
-        return SynthContext.getContext(SynthContext.class, c,
-                    SynthLookAndFeel.getRegion(c), style, state);
+        return SynthContext.getContext(c, style, state);
     }
 
     private int getComponentState(JComponent c) {
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthContext.java	Thu May 22 15:46:50 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthContext.java	Thu May 22 21:05:30 2014 +0400
@@ -24,9 +24,9 @@
  */
 package javax.swing.plaf.synth;
 
-import javax.swing.*;
-import java.util.*;
-import sun.reflect.misc.ReflectUtil;
+import java.util.Queue;
+import java.util.concurrent.ConcurrentLinkedQueue;
+import javax.swing.JComponent;
 
 /**
  * An immutable transient object containing contextual information about
@@ -40,59 +40,32 @@
  * @author Scott Violet
  */
 public class SynthContext {
-    private static final Map<Class, List<SynthContext>> contextMap;
+    private static final Queue<SynthContext> queue = new ConcurrentLinkedQueue<>();
 
     private JComponent component;
     private Region region;
     private SynthStyle style;
     private int state;
 
-
-    static {
-        contextMap = new HashMap<Class, List<SynthContext>>();
+    static SynthContext getContext(JComponent c, SynthStyle style, int state) {
+        return getContext(c, SynthLookAndFeel.getRegion(c), style, state);
     }
 
-
-    static SynthContext getContext(Class type, JComponent component,
+    static SynthContext getContext(JComponent component,
                                    Region region, SynthStyle style,
                                    int state) {
-        SynthContext context = null;
-
-        synchronized(contextMap) {
-            List<SynthContext> instances = contextMap.get(type);
-
-            if (instances != null) {
-                int size = instances.size();
-
-                if (size > 0) {
-                    context = instances.remove(size - 1);
-                }
-            }
-        }
+        SynthContext context = queue.poll();
         if (context == null) {
-            try {
-                context = (SynthContext) ReflectUtil.newInstance(type);
-            } catch (IllegalAccessException iae) {
-            } catch (InstantiationException ie) {
-            }
+            context = new SynthContext();
         }
         context.reset(component, region, style, state);
         return context;
     }
 
     static void releaseContext(SynthContext context) {
-        synchronized(contextMap) {
-            List<SynthContext> instances = contextMap.get(context.getClass());
-
-            if (instances == null) {
-                instances = new ArrayList<SynthContext>(5);
-                contextMap.put(context.getClass(), instances);
-            }
-            instances.add(context);
-        }
+        queue.offer(context);
     }
 
-
     SynthContext() {
     }
 
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthDesktopIconUI.java	Thu May 22 15:46:50 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthDesktopIconUI.java	Thu May 22 21:05:30 2014 +0400
@@ -144,9 +144,7 @@
     }
 
     private SynthContext getContext(JComponent c, int state) {
-        Region region = SynthLookAndFeel.getRegion(c);
-        return SynthContext.getContext(SynthContext.class, c, region,
-                                       style, state);
+        return SynthContext.getContext(c, style, state);
     }
 
     private int getComponentState(JComponent c) {
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthDesktopPaneUI.java	Thu May 22 15:46:50 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthDesktopPaneUI.java	Thu May 22 21:05:30 2014 +0400
@@ -432,8 +432,7 @@
     }
 
     private SynthContext getContext(JComponent c, int state) {
-        return SynthContext.getContext(SynthContext.class, c,
-                     SynthLookAndFeel.getRegion(c), style, state);
+        return SynthContext.getContext(c, style, state);
     }
 
     private int getComponentState(JComponent c) {
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthEditorPaneUI.java	Thu May 22 15:46:50 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthEditorPaneUI.java	Thu May 22 21:05:30 2014 +0400
@@ -139,8 +139,7 @@
     }
 
     private SynthContext getContext(JComponent c, int state) {
-        return SynthContext.getContext(SynthContext.class, c,
-                    SynthLookAndFeel.getRegion(c), style, state);
+        return SynthContext.getContext(c, style, state);
     }
 
     private int getComponentState(JComponent c) {
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthInternalFrameTitlePane.java	Thu May 22 15:46:50 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthInternalFrameTitlePane.java	Thu May 22 21:05:30 2014 +0400
@@ -68,8 +68,7 @@
     }
 
     public SynthContext getContext(JComponent c, int state) {
-        return SynthContext.getContext(SynthContext.class, c,
-                    SynthLookAndFeel.getRegion(c), style, state);
+        return SynthContext.getContext(c, style, state);
     }
 
     private Region getRegion(JComponent c) {
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthInternalFrameUI.java	Thu May 22 15:46:50 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthInternalFrameUI.java	Thu May 22 21:05:30 2014 +0400
@@ -141,8 +141,7 @@
     }
 
     private SynthContext getContext(JComponent c, int state) {
-        return SynthContext.getContext(SynthContext.class, c,
-                            SynthLookAndFeel.getRegion(c), style, state);
+        return SynthContext.getContext(c, style, state);
     }
 
     private int getComponentState(JComponent c) {
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthLabelUI.java	Thu May 22 15:46:50 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthLabelUI.java	Thu May 22 21:05:30 2014 +0400
@@ -91,8 +91,7 @@
     }
 
     private SynthContext getContext(JComponent c, int state) {
-        return SynthContext.getContext(SynthContext.class, c,
-                    SynthLookAndFeel.getRegion(c), style, state);
+        return SynthContext.getContext(c, style, state);
     }
 
     private int getComponentState(JComponent c) {
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthListUI.java	Thu May 22 15:46:50 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthListUI.java	Thu May 22 21:05:30 2014 +0400
@@ -188,8 +188,7 @@
     }
 
     private SynthContext getContext(JComponent c, int state) {
-        return SynthContext.getContext(SynthContext.class, c,
-                    SynthLookAndFeel.getRegion(c), style, state);
+        return SynthContext.getContext(c, style, state);
     }
 
     private int getComponentState(JComponent c) {
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthMenuBarUI.java	Thu May 22 15:46:50 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthMenuBarUI.java	Thu May 22 21:05:30 2014 +0400
@@ -116,8 +116,7 @@
     }
 
     private SynthContext getContext(JComponent c, int state) {
-        return SynthContext.getContext(SynthContext.class, c,
-                    SynthLookAndFeel.getRegion(c), style, state);
+        return SynthContext.getContext(c, style, state);
     }
 
     private int getComponentState(JComponent c) {
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthMenuItemUI.java	Thu May 22 15:46:50 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthMenuItemUI.java	Thu May 22 21:05:30 2014 +0400
@@ -170,8 +170,7 @@
     }
 
     SynthContext getContext(JComponent c, int state) {
-        return SynthContext.getContext(SynthContext.class, c,
-                    SynthLookAndFeel.getRegion(c), style, state);
+        return SynthContext.getContext(c, style, state);
     }
 
     SynthContext getContext(JComponent c, Region region) {
@@ -179,8 +178,7 @@
     }
 
     private SynthContext getContext(JComponent c, Region region, int state) {
-        return SynthContext.getContext(SynthContext.class, c,
-                                       region, accStyle, state);
+        return SynthContext.getContext(c, region, accStyle, state);
     }
 
     private int getComponentState(JComponent c) {
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthMenuUI.java	Thu May 22 15:46:50 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthMenuUI.java	Thu May 22 21:05:30 2014 +0400
@@ -170,9 +170,7 @@
     }
 
     SynthContext getContext(JComponent c, int state) {
-        Region region = SynthLookAndFeel.getRegion(c);
-        return SynthContext.getContext(SynthContext.class, c, region,
-                                       style, state);
+        return SynthContext.getContext(c, style, state);
     }
 
     SynthContext getContext(JComponent c, Region region) {
@@ -180,8 +178,7 @@
     }
 
     private SynthContext getContext(JComponent c, Region region, int state) {
-        return SynthContext.getContext(SynthContext.class, c,
-                                       region, accStyle, state);
+        return SynthContext.getContext(c, region, accStyle, state);
     }
 
     private int getComponentState(JComponent c) {
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthOptionPaneUI.java	Thu May 22 15:46:50 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthOptionPaneUI.java	Thu May 22 21:05:30 2014 +0400
@@ -140,8 +140,7 @@
     }
 
     private SynthContext getContext(JComponent c, int state) {
-        return SynthContext.getContext(SynthContext.class, c,
-                    SynthLookAndFeel.getRegion(c), style, state);
+        return SynthContext.getContext(c, style, state);
     }
 
     private int getComponentState(JComponent c) {
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthPanelUI.java	Thu May 22 15:46:50 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthPanelUI.java	Thu May 22 21:05:30 2014 +0400
@@ -127,8 +127,7 @@
     }
 
     private SynthContext getContext(JComponent c, int state) {
-        return SynthContext.getContext(SynthContext.class, c,
-                    SynthLookAndFeel.getRegion(c), style, state);
+        return SynthContext.getContext(c, style, state);
     }
 
     private int getComponentState(JComponent c) {
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthPopupMenuUI.java	Thu May 22 15:46:50 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthPopupMenuUI.java	Thu May 22 21:05:30 2014 +0400
@@ -123,8 +123,7 @@
     }
 
     private SynthContext getContext(JComponent c, int state) {
-        return SynthContext.getContext(SynthContext.class, c,
-                    SynthLookAndFeel.getRegion(c), style, state);
+        return SynthContext.getContext(c, style, state);
     }
 
     private int getComponentState(JComponent c) {
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthProgressBarUI.java	Thu May 22 15:46:50 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthProgressBarUI.java	Thu May 22 21:05:30 2014 +0400
@@ -138,8 +138,7 @@
     }
 
     private SynthContext getContext(JComponent c, int state) {
-        return SynthContext.getContext(SynthContext.class, c,
-                            SynthLookAndFeel.getRegion(c), style, state);
+        return SynthContext.getContext(c, style, state);
     }
 
     private int getComponentState(JComponent c) {
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthRootPaneUI.java	Thu May 22 15:46:50 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthRootPaneUI.java	Thu May 22 21:05:30 2014 +0400
@@ -80,8 +80,7 @@
     }
 
     private SynthContext getContext(JComponent c, int state) {
-        return SynthContext.getContext(SynthContext.class, c,
-                    SynthLookAndFeel.getRegion(c), style, state);
+        return SynthContext.getContext(c, style, state);
     }
 
     private int getComponentState(JComponent c) {
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthScrollBarUI.java	Thu May 22 15:46:50 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthScrollBarUI.java	Thu May 22 21:05:30 2014 +0400
@@ -185,8 +185,7 @@
     }
 
     private SynthContext getContext(JComponent c, int state) {
-        return SynthContext.getContext(SynthContext.class, c,
-                    SynthLookAndFeel.getRegion(c), style, state);
+        return SynthContext.getContext(c, style, state);
     }
 
     private SynthContext getContext(JComponent c, Region region) {
@@ -199,8 +198,7 @@
         if (region == Region.SCROLL_BAR_THUMB) {
             style = thumbStyle;
         }
-        return SynthContext.getContext(SynthContext.class, c, region, style,
-                                       state);
+        return SynthContext.getContext(c, region, style, state);
     }
 
     private int getComponentState(JComponent c, Region region) {
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthScrollPaneUI.java	Thu May 22 15:46:50 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthScrollPaneUI.java	Thu May 22 21:05:30 2014 +0400
@@ -211,8 +211,7 @@
     }
 
     private SynthContext getContext(JComponent c, int state) {
-        return SynthContext.getContext(SynthContext.class, c,
-                    SynthLookAndFeel.getRegion(c), style, state);
+        return SynthContext.getContext(c, style, state);
     }
 
     private int getComponentState(JComponent c) {
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthSeparatorUI.java	Thu May 22 15:46:50 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthSeparatorUI.java	Thu May 22 21:05:30 2014 +0400
@@ -248,8 +248,7 @@
     }
 
     private SynthContext getContext(JComponent c, int state) {
-        return SynthContext.getContext(SynthContext.class, c,
-                    SynthLookAndFeel.getRegion(c), style, state);
+        return SynthContext.getContext(c, style, state);
     }
 
     public void propertyChange(PropertyChangeEvent evt) {
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthSliderUI.java	Thu May 22 15:46:50 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthSliderUI.java	Thu May 22 21:05:30 2014 +0400
@@ -722,8 +722,7 @@
     }
 
     private SynthContext getContext(JComponent c, int state) {
-        return SynthContext.getContext(SynthContext.class, c,
-                            SynthLookAndFeel.getRegion(c), style, state);
+        return SynthContext.getContext(c, style, state);
     }
 
     private SynthContext getContext(JComponent c, Region subregion) {
@@ -732,14 +731,13 @@
 
     private SynthContext getContext(JComponent c, Region subregion, int state) {
         SynthStyle style = null;
-        Class klass = SynthContext.class;
 
         if (subregion == Region.SLIDER_TRACK) {
             style = sliderTrackStyle;
         } else if (subregion == Region.SLIDER_THUMB) {
             style = sliderThumbStyle;
         }
-        return SynthContext.getContext(klass, c, subregion, style, state);
+        return SynthContext.getContext(c, subregion, style, state);
     }
 
     private int getComponentState(JComponent c, Region region) {
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthSpinnerUI.java	Thu May 22 15:46:50 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthSpinnerUI.java	Thu May 22 21:05:30 2014 +0400
@@ -278,8 +278,7 @@
     }
 
     private SynthContext getContext(JComponent c, int state) {
-        return SynthContext.getContext(SynthContext.class, c,
-                    SynthLookAndFeel.getRegion(c), style, state);
+        return SynthContext.getContext(c, style, state);
     }
 
     /**
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthSplitPaneUI.java	Thu May 22 15:46:50 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthSplitPaneUI.java	Thu May 22 21:05:30 2014 +0400
@@ -209,8 +209,7 @@
     }
 
     private SynthContext getContext(JComponent c, int state) {
-        return SynthContext.getContext(SynthContext.class, c,
-                    SynthLookAndFeel.getRegion(c), style, state);
+        return SynthContext.getContext(c, style, state);
     }
 
     SynthContext getContext(JComponent c, Region region) {
@@ -219,11 +218,9 @@
 
     private SynthContext getContext(JComponent c, Region region, int state) {
         if (region == Region.SPLIT_PANE_DIVIDER) {
-            return SynthContext.getContext(SynthContext.class, c, region,
-                                           dividerStyle, state);
+            return SynthContext.getContext(c, region, dividerStyle, state);
         }
-        return SynthContext.getContext(SynthContext.class, c, region,
-                                       style, state);
+        return SynthContext.getContext(c, region, style, state);
     }
 
     private int getComponentState(JComponent c, Region subregion) {
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthTabbedPaneUI.java	Thu May 22 15:46:50 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthTabbedPaneUI.java	Thu May 22 21:05:30 2014 +0400
@@ -235,13 +235,11 @@
     }
 
     private SynthContext getContext(JComponent c, int state) {
-        return SynthContext.getContext(SynthContext.class, c,
-                    SynthLookAndFeel.getRegion(c),style, state);
+        return SynthContext.getContext(c, style, state);
     }
 
     private SynthContext getContext(JComponent c, Region subregion, int state){
         SynthStyle style = null;
-        Class klass = SynthContext.class;
 
         if (subregion == Region.TABBED_PANE_TAB) {
             style = tabStyle;
@@ -252,7 +250,7 @@
         else if (subregion == Region.TABBED_PANE_CONTENT) {
             style = tabContentStyle;
         }
-        return SynthContext.getContext(klass, c, subregion, style, state);
+        return SynthContext.getContext(c, subregion, style, state);
     }
 
     /**
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthTableHeaderUI.java	Thu May 22 15:46:50 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthTableHeaderUI.java	Thu May 22 21:05:30 2014 +0400
@@ -193,8 +193,7 @@
     }
 
     private SynthContext getContext(JComponent c, int state) {
-        return SynthContext.getContext(SynthContext.class, c,
-                    SynthLookAndFeel.getRegion(c), style, state);
+        return SynthContext.getContext(c, style, state);
     }
 
     /**
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthTableUI.java	Thu May 22 15:46:50 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthTableUI.java	Thu May 22 21:05:30 2014 +0400
@@ -246,8 +246,7 @@
     }
 
     private SynthContext getContext(JComponent c, int state) {
-        return SynthContext.getContext(SynthContext.class, c,
-                    SynthLookAndFeel.getRegion(c), style, state);
+        return SynthContext.getContext(c, style, state);
     }
 
 //
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthTextAreaUI.java	Thu May 22 15:46:50 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthTextAreaUI.java	Thu May 22 21:05:30 2014 +0400
@@ -119,8 +119,7 @@
     }
 
     private SynthContext getContext(JComponent c, int state) {
-        return SynthContext.getContext(SynthContext.class, c,
-                    SynthLookAndFeel.getRegion(c), style, state);
+        return SynthContext.getContext(c, style, state);
     }
 
     /**
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthTextFieldUI.java	Thu May 22 15:46:50 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthTextFieldUI.java	Thu May 22 21:05:30 2014 +0400
@@ -157,8 +157,7 @@
     }
 
     private SynthContext getContext(JComponent c, int state) {
-        return SynthContext.getContext(SynthContext.class, c,
-                    SynthLookAndFeel.getRegion(c), style, state);
+        return SynthContext.getContext(c, style, state);
     }
 
     /**
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthToolBarUI.java	Thu May 22 15:46:50 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthToolBarUI.java	Thu May 22 21:05:30 2014 +0400
@@ -178,19 +178,17 @@
     }
 
     private SynthContext getContext(JComponent c, int state) {
-        return SynthContext.getContext(SynthContext.class, c,
-                    SynthLookAndFeel.getRegion(c), style, state);
+        return SynthContext.getContext(c, style, state);
     }
 
     private SynthContext getContext(JComponent c, Region region, SynthStyle style) {
-        return SynthContext.getContext(SynthContext.class, c, region,
+        return SynthContext.getContext(c, region,
                                        style, getComponentState(c, region));
     }
 
     private SynthContext getContext(JComponent c, Region region,
                                     SynthStyle style, int state) {
-        return SynthContext.getContext(SynthContext.class, c, region,
-                                       style, state);
+        return SynthContext.getContext(c, region, style, state);
     }
 
     private int getComponentState(JComponent c, Region region) {
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthToolTipUI.java	Thu May 22 15:46:50 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthToolTipUI.java	Thu May 22 21:05:30 2014 +0400
@@ -107,8 +107,7 @@
     }
 
     private SynthContext getContext(JComponent c, int state) {
-        return SynthContext.getContext(SynthContext.class, c,
-                    SynthLookAndFeel.getRegion(c), style, state);
+        return SynthContext.getContext(c, style, state);
     }
 
     private int getComponentState(JComponent c) {
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthTreeUI.java	Thu May 22 15:46:50 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthTreeUI.java	Thu May 22 21:05:30 2014 +0400
@@ -173,8 +173,7 @@
     }
 
     private SynthContext getContext(JComponent c, int state) {
-        return SynthContext.getContext(SynthContext.class, c,
-                    SynthLookAndFeel.getRegion(c), style, state);
+        return SynthContext.getContext(c, style, state);
     }
 
     private SynthContext getContext(JComponent c, Region region) {
@@ -182,8 +181,7 @@
     }
 
     private SynthContext getContext(JComponent c, Region region, int state) {
-        return SynthContext.getContext(SynthContext.class, c,
-                                       region, cellStyle, state);
+        return SynthContext.getContext(c, region, cellStyle, state);
     }
 
     private int getComponentState(JComponent c, Region region) {
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthViewportUI.java	Thu May 22 15:46:50 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthViewportUI.java	Thu May 22 21:05:30 2014 +0400
@@ -141,8 +141,7 @@
     }
 
     private SynthContext getContext(JComponent c, int state) {
-        return SynthContext.getContext(SynthContext.class, c,
-                                       getRegion(c), style, state);
+        return SynthContext.getContext(c, style, state);
     }
 
     private Region getRegion(JComponent c) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/plaf/synth/Test8043627.java	Thu May 22 21:05:30 2014 +0400
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import javax.swing.JButton;
+import javax.swing.plaf.synth.SynthButtonUI;
+
+/*
+ * @test
+ * @bug 8043627
+ * @summary Tests that SynthContext can be created with SecurityManager installed
+ * @author Sergey Malenkov
+ */
+
+public class Test8043627 {
+    public static void main(String[] args) {
+        System.setSecurityManager(new SecurityManager());
+        new SynthButtonUI().getContext(new JButton());
+    }
+}