[hg] main-silver: #222288: Check for SecurityException, that can...

  • From:
  • To:
  • Subject: [hg] main-silver: #222288: Check for SecurityException, that can...
  • Date: Tue, 20 Nov 2012 20:38:14 -0800

changeset d5caaffba3bb in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/d5caaffba3bb
description:
        #222288: Check for SecurityException, that can be thrown from 
Toolkit.addAWTEventListener().

diffstat:

 debugger.jpda.visual/nbproject/project.xml                                   
                         |   8 +++++
 
debugger.jpda.visual/remotesrc/org/netbeans/modules/debugger/jpda/visual/remote/RemoteAWTService.java
 |   8 +++++-
 
debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/Bundle.properties
                  |   2 +
 
debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/RemoteServices.java
                |  11 ++++++-
 
debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/VisualDebuggerListener.java
        |  14 ++++++++-
 5 files changed, 38 insertions(+), 5 deletions(-)

diffs (113 lines):

diff --git a/debugger.jpda.visual/nbproject/project.xml 
b/debugger.jpda.visual/nbproject/project.xml
--- a/debugger.jpda.visual/nbproject/project.xml
+++ b/debugger.jpda.visual/nbproject/project.xml
@@ -183,6 +183,14 @@
                     </run-dependency>
                 </dependency>
                 <dependency>
+                    <code-name-base>org.openide.io</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <specification-version>1.35</specification-version>
+                    </run-dependency>
+                </dependency>
+                <dependency>
                     <code-name-base>org.openide.nodes</code-name-base>
                     <build-prerequisite/>
                     <compile-dependency/>
diff --git 
a/debugger.jpda.visual/remotesrc/org/netbeans/modules/debugger/jpda/visual/remote/RemoteAWTService.java
 
b/debugger.jpda.visual/remotesrc/org/netbeans/modules/debugger/jpda/visual/remote/RemoteAWTService.java
--- 
a/debugger.jpda.visual/remotesrc/org/netbeans/modules/debugger/jpda/visual/remote/RemoteAWTService.java
+++ 
b/debugger.jpda.visual/remotesrc/org/netbeans/modules/debugger/jpda/visual/remote/RemoteAWTService.java
@@ -94,12 +94,18 @@
         awtAccessLoop = false;
     }
     
-    static void startHierarchyListener() {
+    static String startHierarchyListener() {
         if (hierarchyListener == null) {
             hierarchyListener = new RemoteAWTHierarchyListener();
+            try {
             
Toolkit.getDefaultToolkit().addAWTEventListener(hierarchyListener, 
AWTEvent.HIERARCHY_EVENT_MASK);
+            } catch (SecurityException se) {
+                hierarchyListener = null;
+                return "Toolkit.addAWTEventListener() threw "+se.toString();
         }
     }
+        return null;
+    }
     
     static void stopHierarchyListener() {
         if (hierarchyListener != null) {
diff --git 
a/debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/Bundle.properties
 
b/debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/Bundle.properties
--- 
a/debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/Bundle.properties
+++ 
b/debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/Bundle.properties
@@ -65,3 +65,5 @@
 MSG_ComponentPropBoundsDescr=The bounds of the component in the window
 MSG_ComponentProps=Properties
 MSG_ComponentPropsDescr=All component properties
+
+MSG_NoTrackingOfComponentChanges=Can not track locations of component 
hierarchy changes in visual debugging, reason: {0}
diff --git 
a/debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/RemoteServices.java
 
b/debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/RemoteServices.java
--- 
a/debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/RemoteServices.java
+++ 
b/debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/RemoteServices.java
@@ -112,8 +112,10 @@
 import org.netbeans.modules.debugger.jpda.jdi.VirtualMachineWrapper;
 import org.netbeans.modules.debugger.jpda.models.JPDAThreadImpl;
 import org.openide.util.Exceptions;
+import org.openide.util.NbBundle;
 import org.openide.util.RequestProcessor;
 import org.openide.util.WeakSet;
+import org.openide.windows.InputOutput;
 
 /**
  *
@@ -941,8 +943,13 @@
                         public void run() {
                             try {
                                 if (attach) {
-                                    Method startHierarchyListenerMethod = 
ClassTypeWrapper.concreteMethodByName(serviceClass, "startHierarchyListener", 
"()V");
-                                    
ClassTypeWrapper.invokeMethod(serviceClass, tr, startHierarchyListenerMethod, 
Collections.EMPTY_LIST, ObjectReference.INVOKE_SINGLE_THREADED);
+                                    Method startHierarchyListenerMethod = 
ClassTypeWrapper.concreteMethodByName(serviceClass, "startHierarchyListener", 
"()Ljava/lang/String;");
+                                    Value res = 
ClassTypeWrapper.invokeMethod(serviceClass, tr, startHierarchyListenerMethod, 
Collections.EMPTY_LIST, ObjectReference.INVOKE_SINGLE_THREADED);
+                                    if (res instanceof StringReference) {
+                                        String reason = ((StringReference) 
res).value();
+                                        InputOutput io = ((JPDAThreadImpl) 
t).getDebugger().getIO();
+                                        
io.getErr().println(NbBundle.getMessage(VisualDebuggerListener.class, 
"MSG_NoTrackingOfComponentChanges", reason));
+                                    }
                                 } else {
                                     Method stopHierarchyListenerMethod = 
ClassTypeWrapper.concreteMethodByName(serviceClass, "stopHierarchyListener", 
"()V");
                                     
ClassTypeWrapper.invokeMethod(serviceClass, tr, stopHierarchyListenerMethod, 
Collections.EMPTY_LIST, ObjectReference.INVOKE_SINGLE_THREADED);
diff --git 
a/debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/VisualDebuggerListener.java
 
b/debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/VisualDebuggerListener.java
--- 
a/debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/VisualDebuggerListener.java
+++ 
b/debugger.jpda.visual/src/org/netbeans/modules/debugger/jpda/visual/VisualDebuggerListener.java
@@ -112,7 +112,9 @@
 import org.netbeans.modules.debugger.jpda.visual.ui.ScreenshotComponent;
 import org.netbeans.spi.debugger.DebuggerServiceRegistration;
 import org.openide.util.Exceptions;
+import org.openide.util.NbBundle;
 import org.openide.util.RequestProcessor;
+import org.openide.windows.InputOutput;
 
 /**
  *
@@ -296,9 +298,17 @@
                 boolean trackComponentChanges = 
properties.getBoolean(PROPERTIES_TCC, true);
                 isTrackComponentChanges = trackComponentChanges;
                 if (trackComponentChanges && 
RemoteAWTScreenshot.FAST_SNAPSHOT_RETRIEVAL) {
-                    Method startHierarchyListenerMethod = 
ClassTypeWrapper.concreteMethodByName(serviceClass, "startHierarchyListener", 
"()V");
+                    Method startHierarchyListenerMethod = 
ClassTypeWrapper.concreteMethodByName(serviceClass, "startHierarchyListener", 
"()Ljava/lang/String;");
                     if (startHierarchyListenerMethod != null) {
-                        ClassTypeWrapper.invokeMethod(serviceClass, tr, 
startHierarchyListenerMethod, Collections.EMPTY_LIST, 
ObjectReference.INVOKE_SINGLE_THREADED);
+                        Value res = 
ClassTypeWrapper.invokeMethod(serviceClass, tr, startHierarchyListenerMethod, 
Collections.EMPTY_LIST, ObjectReference.INVOKE_SINGLE_THREADED);
+                        if (res instanceof StringReference) {
+                            String reason = ((StringReference) res).value();
+                            InputOutput io = t.getDebugger().getIO();
+                            
io.getErr().println(NbBundle.getMessage(VisualDebuggerListener.class, 
"MSG_NoTrackingOfComponentChanges", reason));
+                            //System.err.println("isHierarchyListenerAdded = 
false, reason = "+reason);
+                        } else {
+                            //System.err.println("isHierarchyListenerAdded = 
"+true);
+                        }
                     }
                 }
             } catch (VMDisconnectedExceptionWrapper vmd) {

[hg] main-silver: #222288: Check for SecurityException, that can...

mentlicher 11/21/2012

Project Features

About this Project

Debugger was started in November 2009, is owned by tpavek, and has 29 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20140418.2d69abc). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close