You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by em...@apache.org on 2021/08/12 20:53:35 UTC

[groovy] branch GROOVY-10191 created (now 072512b)

This is an automated email from the ASF dual-hosted git repository.

emilles pushed a change to branch GROOVY-10191
in repository https://gitbox.apache.org/repos/asf/groovy.git.


      at 072512b  GROOVY-10191: catch LinkageError during static inline

This branch includes the following new commits:

     new 072512b  GROOVY-10191: catch LinkageError during static inline

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[groovy] 01/01: GROOVY-10191: catch LinkageError during static inline

Posted by em...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

emilles pushed a commit to branch GROOVY-10191
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 072512bb6d94703146018759a47b542e7224fb1e
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Thu Aug 12 15:53:22 2021 -0500

    GROOVY-10191: catch LinkageError during static inline
---
 .../apache/groovy/ast/tools/ExpressionUtils.java   |  4 +-
 src/test/groovy/bugs/Groovy10191.groovy            | 43 ++++++++++++++++++++++
 2 files changed, 45 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/groovy/ast/tools/ExpressionUtils.java b/src/main/java/org/apache/groovy/ast/tools/ExpressionUtils.java
index bb9790c..c3af88e 100644
--- a/src/main/java/org/apache/groovy/ast/tools/ExpressionUtils.java
+++ b/src/main/java/org/apache/groovy/ast/tools/ExpressionUtils.java
@@ -240,7 +240,7 @@ public final class ExpressionUtils {
                             configure(exp, ce3);
                             return ce3;
                         }
-                    } catch(Exception e) {
+                    } catch (Exception | LinkageError e) {
                         // ignore, leave property expression in place and we'll report later
                     }
                 }
@@ -282,7 +282,7 @@ public final class ExpressionUtils {
                 Expression transformed = transformInlineConstants(e, attrType);
                 newList.addExpression(transformed);
                 if (transformed != e) changed = true;
-            } catch(Exception ignored) {
+            } catch (Exception ignored) {
                 newList.addExpression(e);
             }
         }
diff --git a/src/test/groovy/bugs/Groovy10191.groovy b/src/test/groovy/bugs/Groovy10191.groovy
new file mode 100644
index 0000000..96cab84
--- /dev/null
+++ b/src/test/groovy/bugs/Groovy10191.groovy
@@ -0,0 +1,43 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package groovy.bugs
+
+import org.junit.Test
+
+import static groovy.test.GroovyAssert.assertScript
+
+final class Groovy10191 {
+
+    static class Foo {
+        public static final BAR = 'baz'
+        static {
+            throw new NoSuchMethodError('simulate complex init')
+        }
+    }
+
+    @Test
+    void testStaticInlining() {
+        assertScript """
+            class C {
+                private static final x = ${getClass().getName()}.Foo.BAR
+            }
+            assert true
+        """
+    }
+}