JNDI cannot depend on Swing either, so using reflection to read parameters of applet
1.1 --- a/src/share/classes/com/sun/naming/internal/ResourceManager.java Mon Jun 22 13:15:21 2009 +0200
1.2 +++ b/src/share/classes/com/sun/naming/internal/ResourceManager.java Mon Jun 22 14:00:07 2009 +0200
1.3 @@ -25,11 +25,10 @@
1.4
1.5 package com.sun.naming.internal;
1.6
1.7 -import java.awt.Component;
1.8 import java.io.InputStream;
1.9 import java.io.IOException;
1.10 -import java.net.URL;
1.11 import java.lang.ref.WeakReference;
1.12 +import java.lang.reflect.Method;
1.13 import java.util.Enumeration;
1.14 import java.util.HashMap;
1.15 import java.util.Hashtable;
1.16 @@ -41,7 +40,6 @@
1.17 import java.util.WeakHashMap;
1.18
1.19 import javax.naming.*;
1.20 -import sun.swing.SwingUtilities2;
1.21
1.22 /**
1.23 * The ResourceManager class facilitates the reading of JNDI resource files.
1.24 @@ -144,7 +142,7 @@
1.25 if (env == null) {
1.26 env = new Hashtable(11);
1.27 }
1.28 - Component applet = (Component)env.get(Context.APPLET);
1.29 + Object applet = env.get(Context.APPLET);
1.30
1.31 // Merge property values from env param, applet params, and system
1.32 // properties. The first value wins: there's no concatenation of
1.33 @@ -158,7 +156,7 @@
1.34 Object val = env.get(props[i]);
1.35 if (val == null) {
1.36 if (applet != null) {
1.37 - val = SwingUtilities2.getAppletParameter(applet, props[i]);
1.38 + val = getAppletParameter(applet, props[i]);
1.39 }
1.40 if (val == null) {
1.41 // Read system property.
1.42 @@ -559,4 +557,16 @@
1.43 }
1.44 return false;
1.45 }
1.46 +
1.47 + public static String getAppletParameter(Object applet, String name) {
1.48 + try {
1.49 + Class<?> appletC = Class.forName("java.applet.Applet");
1.50 + Method get = appletC.getMethod("getParameter", String.class);
1.51 + return (String)get.invoke(applet, name);
1.52 + } catch (Exception ex) {
1.53 + ex.printStackTrace();
1.54 + return null;
1.55 + }
1.56 + }
1.57 +
1.58 }
2.1 --- a/src/share/classes/sun/swing/SwingUtilities2.java Mon Jun 22 13:15:21 2009 +0200
2.2 +++ b/src/share/classes/sun/swing/SwingUtilities2.java Mon Jun 22 14:00:07 2009 +0200
2.3 @@ -32,25 +32,18 @@
2.4 import static java.awt.RenderingHints.*;
2.5 import java.awt.event.*;
2.6 import java.awt.font.*;
2.7 -import java.awt.geom.*;
2.8 import java.awt.print.PrinterGraphics;
2.9 -import java.text.Bidi;
2.10 import java.text.AttributedCharacterIterator;
2.11 import java.text.AttributedString;
2.12
2.13 import javax.swing.*;
2.14 -import javax.swing.plaf.*;
2.15 import javax.swing.text.Highlighter;
2.16 import javax.swing.text.JTextComponent;
2.17 import javax.swing.text.DefaultHighlighter;
2.18 import javax.swing.text.DefaultCaret;
2.19 import javax.swing.table.TableCellRenderer;
2.20 -import sun.swing.PrintColorUIResource;
2.21 -import sun.swing.ImageIconUIResource;
2.22 import sun.print.ProxyPrintGraphics;
2.23 import sun.awt.*;
2.24 -import sun.security.action.GetPropertyAction;
2.25 -import sun.security.util.SecurityConstants;
2.26 import java.io.*;
2.27 import java.util.*;
2.28 import sun.font.FontDesignMetrics;
2.29 @@ -1881,9 +1874,4 @@
2.30 }
2.31 return false;
2.32 }
2.33 -
2.34 - public static String getAppletParameter(Component applet, String name) {
2.35 - // JST-TBD: some trick, maybe reflection, may code injection
2.36 - return null;
2.37 - }
2.38 }