Problem resolved, I'll post the testcase later.
On Thu, Feb 2, 2012 at 2:31 PM, Sean Chou <[email protected]> wrote: > Hi Artem, Alexander and Pavel , > > I'm writing the testcase, but while testing it, I > got IllegalAccessError . > Compilation of the testcase is successful. The spec says > " this error can only occur at run time if the definition of a > class has incompatibly changed." I'm using jdk8 built on > 2012_02_01_17_01 and I changed nothing about that class. > Do you have any idea about the error ? Thanks. > > The test case and error are as follow: > > ////////// includes two classes. > > package sun.awt.X11 ; > import java.awt.TextArea; > import javax.swing.text.Caret; > import javax.swing.JTextArea; > import java.lang.reflect.Field; > > public class XPeerTestHelper extends XTextAreaPeer{ > > public XPeerTestHelper(TextArea target) { > super(target); > } > > public Caret getCaret() { > return jtext.getCaret(); // Exception reported to this line. > } > > } > > ///// > > > import java.awt.FlowLayout; > import java.awt.TextArea; > import java.awt.Toolkit; > > import javax.swing.JButton; > import javax.swing.JFrame; > import javax.swing.JTextField; > import javax.swing.SwingUtilities; > import javax.swing.text.DefaultCaret; > > import sun.awt.SunToolkit; > import sun.awt.X11.XPeerTestHelper; > > public class bug7129742 { > public static boolean passed = false; > > public static JFrame frame = null; > public static JButton button = null; > public static TextArea textArea = null; > > public static DefaultCaret caret = null; > > public static void main(String[] args) throws Exception { > SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); > SwingUtilities.invokeAndWait(new Runnable() { > @Override > public void run() { > frame = new JFrame("Test"); > > button = new JButton("JButton"); > textArea = new TextArea("Non-editable textArea"); > textArea.setEditable(false); > > frame.setLayout(new FlowLayout()); > frame.getContentPane().add(button); > frame.getContentPane().add(textArea); > > frame.pack(); > frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); > frame.setVisible(true); > } > }); > toolkit.realSync(); > > SwingUtilities.invokeAndWait(new Runnable() { > @Override > public void run() { > //caret = (DefaultCaret) > try { > XPeerTestHelper helper = new XPeerTestHelper(textArea); > caret = (DefaultCaret) helper.getCaret(); > } catch (ClassCastException e ){ > // If it is not XTextAreaPeer, the test case is skipped > System.out.println("It is not it is not XTextAreaPeer, > testcase skipped"); > passed = true; > } > } > }); > toolkit.realSync(); > > if (passed){ > SwingUtilities.invokeAndWait(new Runnable() { > @Override > public void run() { > frame.dispose(); > } > }); > toolkit.realSync(); > return; > } > > SwingUtilities.invokeAndWait(new Runnable() { > @Override > public void run() { > button.requestFocusInWindow(); > } > }); > toolkit.realSync(); > > SwingUtilities.invokeAndWait(new Runnable() { > @Override > public void run() { > textArea.requestFocusInWindow(); > } > }); > toolkit.realSync(); > > SwingUtilities.invokeAndWait(new Runnable() { > @Override > public void run() { > passed = caret.isVisible(); > frame.dispose(); > } > }); > toolkit.realSync(); > > if (!passed) { > throw new RuntimeException("The test for bug 71297422 failed"); > } > > } > } > > ///////////////////////// end testcase > > > Error information is: > Exception in thread "main" java.lang.reflect.InvocationTargetException > at java.awt.EventQueue.invokeAndWait(EventQueue.java:1238) > at javax.swing.SwingUtilities.invokeAndWait(SwingUtilities.java:1344) > at bug7129742.main(bug7129742.java:80) > Caused by: java.lang.IllegalAccessError: class sun.awt.X11.XPeerTestHelper > cannot access its superclass sun.awt.X11.XTextAreaPeer > at java.lang.ClassLoader.defineClass1(Native Method) > at java.lang.ClassLoader.defineClass(ClassLoader.java:791) > at > java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) > at java.net.URLClassLoader.defineClass(URLClassLoader.java:442) > at java.net.URLClassLoader.access$100(URLClassLoader.java:64) > at java.net.URLClassLoader$1.run(URLClassLoader.java:354) > at java.net.URLClassLoader$1.run(URLClassLoader.java:348) > at java.security.AccessController.doPrivileged(Native Method) > at java.net.URLClassLoader.findClass(URLClassLoader.java:347) > at java.lang.ClassLoader.loadClass(ClassLoader.java:423) > at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) > at java.lang.ClassLoader.loadClass(ClassLoader.java:356) > at bug7129742$2.run(bug7129742.java:85) > at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:241) > at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:701) > at java.awt.EventQueue.access$000(EventQueue.java:102) > at java.awt.EventQueue$3.run(EventQueue.java:662) > at java.awt.EventQueue$3.run(EventQueue.java:660) > at java.security.AccessController.doPrivileged(Native Method) > at > java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75) > at java.awt.EventQueue.dispatchEvent(EventQueue.java:671) > at > java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:216) > at > java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:135) > at > java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:123) > at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:119) > at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:111) > at java.awt.EventDispatchThread.run(EventDispatchThread.java:97) > > > > > > On Mon, Jan 16, 2012 at 11:56 PM, Artem Ananiev > <[email protected]>wrote: > >> Hi, Sean, >> >> text components in XToolkit use Swing peers, so this change should better >> be reviewed on the swing-dev alias. To save everybody's time, I've asked >> Alex and Pavel from the Swing team (in CC) to take a look and they confirm >> the fix looks fine. >> >> Did you consider creating a new regression test for this fix? I'm not >> sure it's easy to detect if caret is visible in the text component or not, >> though. >> >> Thanks, >> >> Artem >> >> >> On 1/16/2012 7:08 AM, Sean Chou wrote: >> >>> Hi all, >>> >>> I made a patch for bug 7129742, >>> http://bugs.sun.com/**bugdatabase/view_bug.do?bug_**id=7129742<http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7129742>. >>> The webrev link is : http://cr.openjdk.java.net/~** >>> zhouyx/7129742/webrev.00/<http://cr.openjdk.java.net/~zhouyx/7129742/webrev.00/> >>> >>> The solution is very simple, just set the cursor visible. >>> >>> Please have a look and give some comments. Thanks. >>> >>> -- >>> Best Regards, >>> Sean Chou >>> >>> > > > -- > Best Regards, > Sean Chou > > -- Best Regards, Sean Chou
