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