From 5ecbf1a3ae7fd14858fb59cab2cfaec48c534e80 Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Wed, 25 Sep 2024 15:02:10 -0400 Subject: [PATCH 1/2] [JENKINS-73031] Print hint that a `static` `interface` method may be to blame --- .../jenkinsci/plugins/workflow/cps/CpsThreadGroup.java | 10 ++++++++++ .../jenkinsci/plugins/workflow/cps/CpsScriptTest.java | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/plugin/src/main/java/org/jenkinsci/plugins/workflow/cps/CpsThreadGroup.java b/plugin/src/main/java/org/jenkinsci/plugins/workflow/cps/CpsThreadGroup.java index 19981832c..2e4724386 100644 --- a/plugin/src/main/java/org/jenkinsci/plugins/workflow/cps/CpsThreadGroup.java +++ b/plugin/src/main/java/org/jenkinsci/plugins/workflow/cps/CpsThreadGroup.java @@ -435,6 +435,16 @@ private boolean run() { if (fn != null) { t.head.get().addAction(new ErrorAction(error)); } + if (error instanceof VerifyError) { + var msg = error.getMessage(); + if (msg != null && msg.contains("Illegal type in constant pool")) { + try { + execution.getOwner().getListener().getLogger().println("May be JENKINS-73031: static interface methods not yet supported in Groovy"); + } catch (IOException x) { + LOGGER.log(Level.WARNING, null, x); + } + } + } } if (!t.isAlive()) { diff --git a/plugin/src/test/java/org/jenkinsci/plugins/workflow/cps/CpsScriptTest.java b/plugin/src/test/java/org/jenkinsci/plugins/workflow/cps/CpsScriptTest.java index 3d94dbd22..06522003d 100644 --- a/plugin/src/test/java/org/jenkinsci/plugins/workflow/cps/CpsScriptTest.java +++ b/plugin/src/test/java/org/jenkinsci/plugins/workflow/cps/CpsScriptTest.java @@ -75,6 +75,14 @@ public void evaluateShallSandbox() throws Exception { r.assertLogContains("Scripts not permitted to use new java.io.File java.lang.String", b); } + @Issue("JENKINS-73031") + @Test public void staticInterfaceMethod() throws Exception { + var p = r.createProject(WorkflowJob.class); + p.setDefinition(new CpsFlowDefinition("def x = List.of(1, 2, 3); echo(/x=$x/)", false)); + var b = r.buildAndAssertStatus(Result.FAILURE, p); + r.assertLogContains("JENKINS-73031", b); + } + @Test public void blockRun() throws Exception { WorkflowJob p = r.createProject(WorkflowJob.class); p.setDefinition(new CpsFlowDefinition("run(null, ['test'] as String[])\n", true)); From 492a2b57fd043c3b4a5ea71ba0ffe0b8221b0b9c Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Thu, 26 Sep 2024 13:20:10 -0400 Subject: [PATCH 2/2] Refined warning --- .../java/org/jenkinsci/plugins/workflow/cps/CpsThreadGroup.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/src/main/java/org/jenkinsci/plugins/workflow/cps/CpsThreadGroup.java b/plugin/src/main/java/org/jenkinsci/plugins/workflow/cps/CpsThreadGroup.java index 2e4724386..c2d188f37 100644 --- a/plugin/src/main/java/org/jenkinsci/plugins/workflow/cps/CpsThreadGroup.java +++ b/plugin/src/main/java/org/jenkinsci/plugins/workflow/cps/CpsThreadGroup.java @@ -439,7 +439,7 @@ private boolean run() { var msg = error.getMessage(); if (msg != null && msg.contains("Illegal type in constant pool")) { try { - execution.getOwner().getListener().getLogger().println("May be JENKINS-73031: static interface methods not yet supported in Groovy"); + execution.getOwner().getListener().getLogger().println("May be JENKINS-73031: calling static interface methods from Groovy is not currently supported by Jenkins"); } catch (IOException x) { LOGGER.log(Level.WARNING, null, x); }