You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (JIRA)" <ji...@apache.org> on 2019/01/02 18:30:00 UTC
[jira] [Updated] (GROOVY-8944) groovyc: invalid constant pool entry
[ https://issues.apache.org/jira/browse/GROOVY-8944?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles updated GROOVY-8944:
--------------------------------
Description:
Updated our projects to Groovy 2.4.16 today and ran into a problem with one of our test helpers. This functional interface performs a similar function to {{GroovyAssert.shouldFail}}. Whenever it is referenced from statically compiled Groovy, there is a bytecode error for the reference to {{java.lang.Throwable}}. This error is not present in Groovy 2.4.15, which should help isolate the cause.
{code}
java.lang.VerifyError: Illegal type at constant pool entry 53 in class CatchableTest
Exception Details:
Location:
CatchableTest.testTryCatch()V @14: invokestatic
Reason:
Constant pool index 53 is invalid
Bytecode:
0x0000000: bb00 1e59 2a2a b700 21ba 002f 0000 b800
0x0000010: 354c 2b57 1237 2bb6 003b b800 4001 57b1
0x0000020:
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
{code}
{code:groovy}
import org.junit.Assert
import org.junit.Test
@groovy.transform.CompileStatic
final class CatchableTest {
@Test
void testTryCatch() {
Throwable t = Catchable.tryCatch {
println 'throwing new exception'
throw new IllegalStateException()
}
Assert.assertEquals(IllegalStateException, t.getClass())
}
}
{code}
{code:java}
/**
* <code>
* Throwable t = Catchable.tryCatch(() -> obj.method(params));<br>
* assertThat(t).isInstanceOf(SomeException.class).hasMessage("whatevs");
* </code>
* <p>
* Adapted from http://www.codeaffine.com/2014/07/28/clean-junit-throwable-tests-with-java-8-lambdas/
*/
@FunctionalInterface
public interface Catchable {
void op() throws Throwable;
static Throwable tryCatch(final Catchable thrower) {
try {
thrower.op();
return null;
} catch (final Throwable thrown) {
return thrown;
}
}
}
{code}
was:
Updated our projects to Groovy 2.4.16 today and ran into a problem with one of our test helpers. This functional interface performs a similar function to {{GroovyAssert.shouldFail}}. Whenever it is referenced from statically compiled Groovy, there is a bytecode error for the reference to {{java.lang.Throwable}}. This error is not present in Groovy 2.4.15, which should help isolate the cause.
{code}
java.lang.VerifyError: Illegal type at constant pool entry 53 in class CatchableTest
Exception Details:
Location:
CatchableTest.testTryCatch()V @14: invokestatic
Reason:
Constant pool index 53 is invalid
Bytecode:
0x0000000: bb00 1e59 2a2a b700 21ba 002f 0000 b800
0x0000010: 354c 2b57 1237 2bb6 003b b800 4001 57b1
0x0000020:
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
{code}
{code:groovy}
import org.junit.Assert
import org.junit.Test
@groovy.transform.CompileStatic
final class CatchableTest {
@Test
void testTryCatch() {
Throwable t = Catchable.tryCatch {
println 'throwing new exception'
throw new IllegalStateException()
}
Assert.assertEquals(IllegalStateException.class, t.getClass())
}
}
{code}
{code:java}
/**
* <code>
* Throwable t = Catchable.tryCatch(() -> obj.method(params));<br>
* assertThat(t).isInstanceOf(SomeException.class).hasMessage("whatevs");
* </code>
* <p>
* Adapted from http://www.codeaffine.com/2014/07/28/clean-junit-throwable-tests-with-java-8-lambdas/
*/
@FunctionalInterface
public interface Catchable {
void op() throws Throwable;
static Throwable tryCatch(final Catchable thrower) {
try {
thrower.op();
return null;
} catch (final Throwable thrown) {
return thrown;
}
}
}
{code}
> groovyc: invalid constant pool entry
> ------------------------------------
>
> Key: GROOVY-8944
> URL: https://issues.apache.org/jira/browse/GROOVY-8944
> Project: Groovy
> Issue Type: Bug
> Components: Compiler
> Affects Versions: 2.4.16
> Reporter: Eric Milles
> Priority: Critical
>
> Updated our projects to Groovy 2.4.16 today and ran into a problem with one of our test helpers. This functional interface performs a similar function to {{GroovyAssert.shouldFail}}. Whenever it is referenced from statically compiled Groovy, there is a bytecode error for the reference to {{java.lang.Throwable}}. This error is not present in Groovy 2.4.15, which should help isolate the cause.
> {code}
> java.lang.VerifyError: Illegal type at constant pool entry 53 in class CatchableTest
> Exception Details:
> Location:
> CatchableTest.testTryCatch()V @14: invokestatic
> Reason:
> Constant pool index 53 is invalid
> Bytecode:
> 0x0000000: bb00 1e59 2a2a b700 21ba 002f 0000 b800
> 0x0000010: 354c 2b57 1237 2bb6 003b b800 4001 57b1
> 0x0000020:
> at java.lang.Class.getDeclaredMethods0(Native Method)
> at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
> at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
> at java.lang.Class.getMethod0(Class.java:3018)
> at java.lang.Class.getMethod(Class.java:1784)
> {code}
> {code:groovy}
> import org.junit.Assert
> import org.junit.Test
> @groovy.transform.CompileStatic
> final class CatchableTest {
> @Test
> void testTryCatch() {
> Throwable t = Catchable.tryCatch {
> println 'throwing new exception'
> throw new IllegalStateException()
> }
> Assert.assertEquals(IllegalStateException, t.getClass())
> }
> }
> {code}
> {code:java}
> /**
> * <code>
> * Throwable t = Catchable.tryCatch(() -> obj.method(params));<br>
> * assertThat(t).isInstanceOf(SomeException.class).hasMessage("whatevs");
> * </code>
> * <p>
> * Adapted from http://www.codeaffine.com/2014/07/28/clean-junit-throwable-tests-with-java-8-lambdas/
> */
> @FunctionalInterface
> public interface Catchable {
> void op() throws Throwable;
> static Throwable tryCatch(final Catchable thrower) {
> try {
> thrower.op();
> return null;
> } catch (final Throwable thrown) {
> return thrown;
> }
> }
> }
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)