• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // ASM: a very small and fast Java bytecode manipulation framework
2 // Copyright (c) 2000-2011 INRIA, France Telecom
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions
7 // are met:
8 // 1. Redistributions of source code must retain the above copyright
9 //    notice, this list of conditions and the following disclaimer.
10 // 2. Redistributions in binary form must reproduce the above copyright
11 //    notice, this list of conditions and the following disclaimer in the
12 //    documentation and/or other materials provided with the distribution.
13 // 3. Neither the name of the copyright holders nor the names of its
14 //    contributors may be used to endorse or promote products derived from
15 //    this software without specific prior written permission.
16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27 // THE POSSIBILITY OF SUCH DAMAGE.
28 package jdk5;
29 
30 import java.io.IOException;
31 import java.lang.annotation.Retention;
32 import java.lang.annotation.RetentionPolicy;
33 import java.util.Comparator;
34 import java.util.List;
35 
36 /**
37  * Class which, compiled with the JDK 1.5.0, produces the new class file structures from that
38  * version (compared to JDK 1.3.0). Must be compiled with "javac -g".
39  */
40 @Deprecated
41 @AllStructures.InvisibleAnnotation(
42   byteValue = 0,
43   charValue = 0,
44   booleanValue = false,
45   intValue = 0,
46   shortValue = 0,
47   longValue = 0L,
48   floatValue = 0f,
49   doubleValue = 0d,
50   stringValue = "0",
51   classValue = AllStructures.class,
52   enumValue = AllStructures.EnumClass.VALUE0,
53   annotationValue = @Deprecated,
54   byteArrayValue = {0},
55   charArrayValue = {'0'},
56   booleanArrayValue = {false},
57   intArrayValue = {0},
58   shortArrayValue = {0},
59   longArrayValue = {0L},
60   floatArrayValue = {0f},
61   doubleArrayValue = {0d},
62   stringArrayValue = {"0"},
63   classArrayValue = {AllStructures.class, int.class, int[].class},
64   enumArrayValue = {AllStructures.EnumClass.VALUE0},
65   annotationArrayValue = {@Deprecated},
66   otherArrayValue = {}
67 )
68 class AllStructures<
69         U0,
70         U1 extends Number,
71         U2 extends List<String>,
72         U3 extends List<?>,
73         U4 extends List<? extends Number>,
74         U5 extends List<? super Number>,
75         U6 extends Number & Runnable & Cloneable>
76     implements Comparator<Integer> {
77 
78   @Deprecated
79   @InvisibleAnnotation(otherArrayValue = {2})
80   public int f;
81 
82   private U0 f0;
83   private U1 f1;
84   private U2 f2;
85   private U3 f3;
86   private U4 f4;
87   private U5 f5;
88   private U6 f6;
89 
90   @Deprecated
91   @InvisibleAnnotation(otherArrayValue = {3})
m()92   public int m() {
93     return f;
94   }
95 
n( int p0, @Deprecated @InvisibleAnnotation(otherArrayValue = {4}) float p1, @Deprecated float p2, long p3, @InvisibleAnnotation(otherArrayValue = {5}) double p4)96   public int n(
97       int p0,
98       @Deprecated @InvisibleAnnotation(otherArrayValue = {4}) float p1,
99       @Deprecated float p2,
100       long p3,
101       @InvisibleAnnotation(otherArrayValue = {5}) double p4) {
102     return f;
103   }
104 
o()105   public U0 o() {
106     return f0;
107   }
108 
109   <
110           U0,
111           U1 extends Number,
112           U2 extends List<String>,
113           U3 extends List<?>,
114           U4 extends List<? extends Number>,
115           U5 extends List<? super Number>,
116           U6 extends Number & Runnable & Cloneable,
117           U7 extends Exception,
118           U8 extends IOException>
genericMethod( List<U0> p0, List<U1[]> p1, List<U2[][]> p2, List<U3> p3, List<U4> p4, List<U5> p5, List<U6> p6, AllStructures<U0, U1, U2, U3, U4, U5, U6>.InnerClass p7, AllStructures<U0, U1, U2, U3, U4, U5, U6>.GenericInnerClass<U1> p8)119       void genericMethod(
120           List<U0> p0,
121           List<U1[]> p1,
122           List<U2[][]> p2,
123           List<U3> p3,
124           List<U4> p4,
125           List<U5> p5,
126           List<U6> p6,
127           AllStructures<U0, U1, U2, U3, U4, U5, U6>.InnerClass p7,
128           AllStructures<U0, U1, U2, U3, U4, U5, U6>.GenericInnerClass<U1> p8)
129           throws U7, U8 {}
130 
varArgsAutoBoxingAndForLoop(int... args)131   int varArgsAutoBoxingAndForLoop(int... args) {
132     int total = 0;
133     for (int arg : args) {
134       total += arg;
135     }
136     return total;
137   }
138 
localClassConstructor(final String name)139   void localClassConstructor(final String name) {
140     class LocalClass {
141       LocalClass(@Deprecated int value) {
142         System.out.println(name + value);
143       }
144     }
145     new LocalClass(42);
146   }
147 
148   // Generates a bridge method.
compare(Integer a, Integer b)149   public int compare(Integer a, Integer b) {
150     return a < b ? -1 : 1;
151   }
152 
153   @Retention(RetentionPolicy.CLASS)
154   @interface InvisibleAnnotation {
byteValue()155     byte byteValue() default 1;
156 
charValue()157     char charValue() default '1';
158 
booleanValue()159     boolean booleanValue() default true;
160 
intValue()161     int intValue() default 1;
162 
shortValue()163     short shortValue() default 1;
164 
longValue()165     long longValue() default 1L;
166 
floatValue()167     float floatValue() default 1f;
168 
doubleValue()169     double doubleValue() default 1d;
170 
stringValue()171     String stringValue() default "1";
172 
classValue()173     Class classValue() default Object.class;
174 
enumValue()175     EnumClass enumValue() default EnumClass.VALUE1;
176 
annotationValue()177     Deprecated annotationValue() default @Deprecated;
178 
byteArrayValue()179     byte[] byteArrayValue() default {1};
180 
charArrayValue()181     char[] charArrayValue() default {'1'};
182 
booleanArrayValue()183     boolean[] booleanArrayValue() default {true};
184 
intArrayValue()185     int[] intArrayValue() default {1};
186 
shortArrayValue()187     short[] shortArrayValue() default {1};
188 
longArrayValue()189     long[] longArrayValue() default {1L};
190 
floatArrayValue()191     float[] floatArrayValue() default {1f};
192 
doubleArrayValue()193     double[] doubleArrayValue() default {1d};
194 
stringArrayValue()195     String[] stringArrayValue() default {"1"};
196 
classArrayValue()197     Class[] classArrayValue() default {Object.class, int.class, int[].class};
198 
enumArrayValue()199     EnumClass[] enumArrayValue() default {EnumClass.VALUE1};
200 
annotationArrayValue()201     Deprecated[] annotationArrayValue() default {@Deprecated};
202 
otherArrayValue()203     int[] otherArrayValue();
204   }
205 
206   enum EnumClass {
207     VALUE0(0),
208     VALUE1(1),
209     VALUE2(2);
210 
211     private int value;
212 
EnumClass(int value)213     private EnumClass(int value) {
214       this.value = value;
215     }
216 
getValue()217     public int getValue() {
218       return value;
219     }
220   }
221 
222   class InnerClass {}
223 
224   class GenericInnerClass<T> {}
225 }
226