groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject [groovy] branch master updated: GROOVY-8339: hack to remove some remaining JDK 9+ illegal access warnings from the Console
Date Thu, 02 May 2019 06:11:39 GMT
This is an automated email from the ASF dual-hosted git repository.

paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/master by this push:
     new 6622e25  GROOVY-8339: hack to remove some remaining JDK 9+ illegal access warnings
from the Console
6622e25 is described below

commit 6622e257e99b321e16d3de7b3418a896eca7c580
Author: Paul King <paulk@asert.com.au>
AuthorDate: Thu May 2 16:11:28 2019 +1000

    GROOVY-8339: hack to remove some remaining JDK 9+ illegal access warnings from the Console
---
 .../inspect/swingui/ScriptToTreeNodeAdapter.groovy       | 11 +++++++++--
 .../src/main/groovy/groovy/ui/Console.groovy             | 16 ++++++++++++++--
 .../main/groovy/groovy/ui/view/BasicContentPane.groovy   |  4 ++--
 3 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/subprojects/groovy-console/src/main/groovy/groovy/inspect/swingui/ScriptToTreeNodeAdapter.groovy
b/subprojects/groovy-console/src/main/groovy/groovy/inspect/swingui/ScriptToTreeNodeAdapter.groovy
index ac51fcc..7a460ba 100644
--- a/subprojects/groovy-console/src/main/groovy/groovy/inspect/swingui/ScriptToTreeNodeAdapter.groovy
+++ b/subprojects/groovy-console/src/main/groovy/groovy/inspect/swingui/ScriptToTreeNodeAdapter.groovy
@@ -20,6 +20,7 @@ package groovy.inspect.swingui
 
 import groovy.text.GStringTemplateEngine
 import groovy.text.Template
+import groovy.transform.CompileStatic
 import groovy.transform.PackageScope
 import org.apache.groovy.io.StringBuilderWriter
 import org.codehaus.groovy.GroovyBugError
@@ -230,9 +231,9 @@ class ScriptToTreeNodeAdapter {
                     // instead reference the value through the leftExpression property, which
is the same
                     if (node instanceof DeclarationExpression &&
                             (name == 'variableExpression' || name == 'tupleExpression'))
{
-                        value = node.leftExpression.toString()
+                        value = toString(node.leftExpression)
                     } else {
-                        value = it.getProperty(node).toString()
+                        value = toString(it.getProperty(node))
                     }
                 } catch (GroovyBugError reflectionArtefact) {
                     // compiler throws error if it thinks a field is being accessed
@@ -246,6 +247,12 @@ class ScriptToTreeNodeAdapter {
             sort { it[0] }
     }
 
+    // GROOVY-8339: to avoid illegal access to a non-visible implementation class - can be
removed if a more general solution is found
+    @CompileStatic
+    String toString(Object o) {
+        o.toString()
+    }
+
     /**
      * Handles the property file templating for node types.
      */
diff --git a/subprojects/groovy-console/src/main/groovy/groovy/ui/Console.groovy b/subprojects/groovy-console/src/main/groovy/groovy/ui/Console.groovy
index a426bac..c121ac5 100644
--- a/subprojects/groovy-console/src/main/groovy/groovy/ui/Console.groovy
+++ b/subprojects/groovy-console/src/main/groovy/groovy/ui/Console.groovy
@@ -739,11 +739,23 @@ class Console implements CaretListener, HyperlinkListener, ComponentListener,
Fo
     }
 
     void caretUpdate(CaretEvent e){
-        textSelectionStart = Math.min(e.dot,e.mark)
-        textSelectionEnd = Math.max(e.dot,e.mark)
+        textSelectionStart = Math.min(dot(e), mark(e))
+        textSelectionEnd = Math.max(dot(e), mark(e))
         setRowNumAndColNum()
     }
 
+    // GROOVY-8339: to avoid illegal access to a non-visible implementation class - can be
removed if a more general solution is found
+    @CompileStatic
+    int dot(CaretEvent e) {
+        e.dot
+    }
+
+    // GROOVY-8339: to avoid illegal access to a non-visible implementation class - can be
removed if a more general solution is found
+    @CompileStatic
+    int mark(CaretEvent e) {
+        e.mark
+    }
+
     void clearOutput(EventObject evt = null) {
         outputArea.text = ''
     }
diff --git a/subprojects/groovy-console/src/main/groovy/groovy/ui/view/BasicContentPane.groovy
b/subprojects/groovy-console/src/main/groovy/groovy/ui/view/BasicContentPane.groovy
index 57cd37f..d7794b8 100644
--- a/subprojects/groovy-console/src/main/groovy/groovy/ui/view/BasicContentPane.groovy
+++ b/subprojects/groovy-console/src/main/groovy/groovy/ui/view/BasicContentPane.groovy
@@ -140,12 +140,12 @@ FontMetrics fm = g.getFontMetrics(outputArea.font)
 
 outputArea.preferredSize = [
     prefs.getInt('outputAreaWidth', fm.charWidth(0x77) * 81),
-    prefs.getInt('outputAreaHeight', (fm.getHeight() + fm.leading) * 12)
+    prefs.getInt('outputAreaHeight', (fm.getHeight() + fm.getLeading()) * 12)
 ] as Dimension
 
 inputEditor.preferredSize = [
     prefs.getInt('inputAreaWidth', fm.charWidth(0x77) * 81),
-    prefs.getInt('inputAreaHeight', (fm.getHeight() + fm.leading) * 12)
+    prefs.getInt('inputAreaHeight', (fm.getHeight() + fm.getLeading()) * 12)
 ] as Dimension
 
 origDividerSize = -1


Mime
View raw message