xref: /aosp_15_r20/external/javassist/src/test/test3/NewExprTryCatch.java (revision f1fbf3c2ab775ce834e0af96b7a85bdc7a0eac65)
1*f1fbf3c2SXin Li package test3;
2*f1fbf3c2SXin Li 
3*f1fbf3c2SXin Li class NewExprTryCatch2 {
4*f1fbf3c2SXin Li }
5*f1fbf3c2SXin Li 
6*f1fbf3c2SXin Li public class NewExprTryCatch {
instrumentMe()7*f1fbf3c2SXin Li     public void instrumentMe() {
8*f1fbf3c2SXin Li         // we need a 'new' expression to instrument, the exact type is not important
9*f1fbf3c2SXin Li         new Object();
10*f1fbf3c2SXin Li         // if the try/catch block below is removed, the error does not occur
11*f1fbf3c2SXin Li         try {
12*f1fbf3c2SXin Li             System.out.println();
13*f1fbf3c2SXin Li         } catch (Throwable t) {
14*f1fbf3c2SXin Li         }
15*f1fbf3c2SXin Li     }
16*f1fbf3c2SXin Li 
me2()17*f1fbf3c2SXin Li     public void me2() throws Exception {
18*f1fbf3c2SXin Li         // the error is somehow related to the string concatenation and local variables,
19*f1fbf3c2SXin Li         // when the code below is replaced with something else, the error does not occur.
20*f1fbf3c2SXin Li         String s1 = "a";
21*f1fbf3c2SXin Li         @SuppressWarnings("unused")
22*f1fbf3c2SXin Li         String s2 = s1 + "b";
23*f1fbf3c2SXin Li     }
24*f1fbf3c2SXin Li 
test()25*f1fbf3c2SXin Li     public int test() throws Exception {
26*f1fbf3c2SXin Li         instrumentMe();
27*f1fbf3c2SXin Li         me2();
28*f1fbf3c2SXin Li         return 0;
29*f1fbf3c2SXin Li     }
30*f1fbf3c2SXin Li }
31