1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * https://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20 package org.apache.bcel.verifier;
21
22 import org.apache.bcel.AbstractTest;
23 import org.junit.jupiter.api.Disabled;
24 import org.junit.jupiter.api.Test;
25
26 /**
27 * Tests BCEL-369.
28 */
29 class JiraBcel369Test extends AbstractTest {
30
31 @Test
32 void testCompileAndVerify() throws ClassNotFoundException {
33 Verifier.verifyType(org.apache.bcel.verifier.JiraBcel369TestFixture.class.getName());
34 }
35
36 /**
37 * 3.7.0 fails with
38 * <pre>{@code
39 * org.apache.bcel.verifier.exc.AssertionViolatedException:
40 * INTERNAL ERROR: Some RuntimeException occurred while verify()ing class 'issue369.Test', method 'public void <init>(int arg1)'.
41 * Original RuntimeException's stack trace:
42 ---
43 org.apache.bcel.verifier.exc.AssertionViolatedException: INTERNAL ERROR: outFrame not set! This:
44 24: return [InstructionContext]
45 ExecutionChain: 24: return [InstructionContext]
46 OutFrames: '{ 7: jsr -> 19 [InstructionContext]=Local Variables:
47 0: issue369.Test
48 1: int
49 2: <unknown object>
50 3: <return address targeting 10: goto[167](3) -> 34>
51 4: <unknown object>
52 OperandStack:
53 Slots used: 0 MaxStack: 1.
54 , 14: jsr -> 19 [InstructionContext]=Local Variables:
55 0: issue369.Test
56 1: int
57 2: java.lang.Throwable
58 3: <return address targeting 17: aload_2[44](1)>
59 4: <unknown object>
60 OperandStack:
61 Slots used: 0 MaxStack: 1.
62 }'.
63 at org.apache.bcel.verifier.structurals.ControlFlowGraph$InstructionContextImpl.getOutFrame(ControlFlowGraph.java:282)
64 at org.apache.bcel.verifier.structurals.Pass3bVerifier.circulationPump(Pass3bVerifier.java:275)
65 at org.apache.bcel.verifier.structurals.Pass3bVerifier.do_verify(Pass3bVerifier.java:386)
66 at org.apache.bcel.verifier.PassVerifier.verify(PassVerifier.java:98)
67 at org.apache.bcel.verifier.Verifier.doPass3b(Verifier.java:166)
68 at org.apache.bcel.verifier.Verifier.verifyType(Verifier.java:90)
69 at org.apache.bcel.verifier.JiraBcel369TestCase.testCompiledClass(JiraBcel369TestCase.java:35)
70 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
71 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
72 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
73 at java.lang.reflect.Method.invoke(Method.java:498)
74 at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:727)
75 ...
76 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)
77 ---
78
79 at org.apache.bcel.verifier.structurals.Pass3bVerifier.do_verify(Pass3bVerifier.java:398)
80 at org.apache.bcel.verifier.PassVerifier.verify(PassVerifier.java:98)
81 at org.apache.bcel.verifier.Verifier.doPass3b(Verifier.java:166)
82 at org.apache.bcel.verifier.Verifier.verifyType(Verifier.java:90)
83 at org.apache.bcel.verifier.JiraBcel369TestCase.testCompiledClass(JiraBcel369TestCase.java:35)
84 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
85 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
86 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
87 at java.lang.reflect.Method.invoke(Method.java:498)
88 at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:727)
89 ...
90 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)
91 Caused by: org.apache.bcel.verifier.exc.AssertionViolatedException: INTERNAL ERROR: outFrame not set! This:
92 24: return [InstructionContext]
93 ExecutionChain: 24: return [InstructionContext]
94 OutFrames: '{ 7: jsr -> 19 [InstructionContext]=Local Variables:
95 0: issue369.Test
96 1: int
97 2: <unknown object>
98 3: <return address targeting 10: goto[167](3) -> 34>
99 4: <unknown object>
100 OperandStack:
101 Slots used: 0 MaxStack: 1.
102 , 14: jsr -> 19 [InstructionContext]=Local Variables:
103 0: issue369.Test
104 1: int
105 2: java.lang.Throwable
106 3: <return address targeting 17: aload_2[44](1)>
107 4: <unknown object>
108 OperandStack:
109 Slots used: 0 MaxStack: 1.
110 }'.
111 at org.apache.bcel.verifier.structurals.ControlFlowGraph$InstructionContextImpl.getOutFrame(ControlFlowGraph.java:282)
112 at org.apache.bcel.verifier.structurals.Pass3bVerifier.circulationPump(Pass3bVerifier.java:275)
113 at org.apache.bcel.verifier.structurals.Pass3bVerifier.do_verify(Pass3bVerifier.java:386)
114 ... 74 more
115 * }</pre>
116 *
117 * @throws ClassNotFoundException
118 */
119 @Test
120 @Disabled
121 void testCompiledClass() throws ClassNotFoundException {
122 Verifier.verifyType("issue369.Issue369");
123 }
124
125 }