Package list findbugs / upstream/latest src / patches / bcel.diff
upstream/latest

Tree @upstream/latest (Download .tar.gz)

bcel.diff @upstream/latestraw · history · blame

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
Property changes on: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2
___________________________________________________________________
Name: svn:ignore
   - bin
velocity.log
*~
   + bin
velocity.log
*~
bcel.jar


Index: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/build.xml
===================================================================
--- /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/build.xml	(revision 0)
+++ /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/build.xml	(revision 0)
@@ -0,0 +1,39 @@
+<project name="bcel" default="jar">
+
+	<property name="src.dir" value="src/java"/>
+	<property name="classes.dir" value="eclipse"/>
+	<property name="jar.dir" value="."/>
+
+	<target name="jar" depends="clean,classes">
+		<!-- Main engine and command line jar file. -->
+		<jar destfile="${jar.dir}/bcel.jar" >
+			<!-- Compiled classes, properties files. -->
+			<fileset dir="${classes.dir}">
+				<include name="**/*.class"/>
+			</fileset>
+		</jar>
+   </target>
+	
+	<!-- Compile Java source files, and copy other files (properties,
+		images, html, XSL stylesheets) that need to be part of the codebase. -->
+	<target name="classes">
+		<mkdir dir="${classes.dir}"/>
+		<!-- Compile Java source files. -->
+		<javac srcdir="${src.dir}"
+						destdir="${classes.dir}"
+						source="1.5"
+						target="jsr14"
+						deprecation="on"
+						debug="on">
+				</javac>
+	</target>
+	<!-- Delete generated files. -->
+	<target name="clean">
+		<delete file="${classes.dir}"/>
+		<mkdir dir="${classes.dir}"/>
+	</target>
+
+	
+</project>
+
+<!-- vim:set ts=4: -->
Index: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/AbstractLocalVariableTable.java
===================================================================
--- /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/AbstractLocalVariableTable.java	(revision 0)
+++ /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/AbstractLocalVariableTable.java	(revision 0)
@@ -0,0 +1,187 @@
+/*
+ * Copyright  2000-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License"); 
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License. 
+ *
+ */
+package org.apache.bcel.classfile;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import org.apache.bcel.Constants;
+
+/**
+ * This class represents colection of local variables in a
+ * method. This attribute is contained in the <em>Code</em> attribute.
+ *
+ * @version $Id: bcel.diff,v 1.2 2007/08/14 03:33:02 wpugh Exp $
+ * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
+ * @see     Code
+ * @see LocalVariable
+ */
+abstract public class AbstractLocalVariableTable extends Attribute {
+
+    private int local_variable_table_length; // Table of local
+    private LocalVariable[] local_variable_table; // variables
+
+
+    /**
+     * Initialize from another object. Note that both objects use the same
+     * references (shallow copy). Use copy() for a physical copy.
+     */
+    public AbstractLocalVariableTable(AbstractLocalVariableTable c) {
+        this(c.getNameIndex(), c.getLength(), c.getLocalVariableTable(), c.getConstantPool());
+    }
+
+
+    /**
+     * @param name_index Index in constant pool to `LocalVariableTable'
+     * @param length Content length in bytes
+     * @param local_variable_table Table of local variables
+     * @param constant_pool Array of constants
+     */
+    public AbstractLocalVariableTable(int name_index, int length, LocalVariable[] local_variable_table,
+            ConstantPool constant_pool) {
+        super(Constants.ATTR_LOCAL_VARIABLE_TABLE, name_index, length, constant_pool);
+        setLocalVariableTable(local_variable_table);
+    }
+
+
+    /**
+     * Construct object from file stream.
+     * @param name_index Index in constant pool
+     * @param length Content length in bytes
+     * @param file Input stream
+     * @param constant_pool Array of constants
+     * @throws IOException
+     */
+    AbstractLocalVariableTable(int name_index, int length, DataInputStream file, ConstantPool constant_pool)
+            throws IOException {
+        this(name_index, length, (LocalVariable[]) null, constant_pool);
+        local_variable_table_length = (file.readUnsignedShort());
+        local_variable_table = new LocalVariable[local_variable_table_length];
+        for (int i = 0; i < local_variable_table_length; i++) {
+            local_variable_table[i] = new LocalVariable(file, constant_pool);
+        }
+    }
+
+
+
+
+    /**
+     * Dump local variable table attribute to file stream in binary format.
+     *
+     * @param file Output file stream
+     * @throws IOException
+     */
+    public final void dump( DataOutputStream file ) throws IOException {
+        super.dump(file);
+        file.writeShort(local_variable_table_length);
+        for (int i = 0; i < local_variable_table_length; i++) {
+            local_variable_table[i].dump(file);
+        }
+    }
+
+
+    /**
+     * @return Array of local variables of method.
+     */
+    public final LocalVariable[] getLocalVariableTable() {
+        return local_variable_table;
+    }
+
+
+    /** 
+     * @return first matching variable using index
+     * 
+     * @param index the variable slot
+     * 
+     * @return the first LocalVariable that matches the slot or null if not found
+     * 
+     * @deprecated since 5.2 because multiple variables can share the
+     *             same slot, use getLocalVariable(int index, int pc) instead.
+     */
+    public final LocalVariable getLocalVariable( int index ) {
+        for (int i = 0; i < local_variable_table_length; i++) {
+            if (local_variable_table[i].getIndex() == index) {
+                return local_variable_table[i];
+            }
+        }
+        return null;
+    }
+
+
+    /** 
+     * @return matching variable using index when variable is used at supplied pc
+     * 
+     * @param index the variable slot
+     * @param pc the current pc that this variable is alive
+     * 
+     * @return the LocalVariable that matches or null if not found
+     */
+    public final LocalVariable getLocalVariable( int index, int pc ) {
+        for (int i = 0; i < local_variable_table_length; i++) {
+            if (local_variable_table[i].getIndex() == index) {
+                int start_pc = local_variable_table[i].getStartPC();
+                int end_pc = start_pc + local_variable_table[i].getLength();
+                if ((pc >= start_pc) && (pc < end_pc)) {
+                    return local_variable_table[i];
+                }
+            }
+        }
+        return null;
+    }
+
+
+    public final void setLocalVariableTable( LocalVariable[] local_variable_table ) {
+        this.local_variable_table = local_variable_table;
+        local_variable_table_length = (local_variable_table == null)
+                ? 0
+                : local_variable_table.length;
+    }
+
+
+    /**
+     * @return String representation.
+     */
+    public final String toString() {
+        StringBuffer buf = new StringBuffer("");
+        for (int i = 0; i < local_variable_table_length; i++) {
+            buf.append(local_variable_table[i].toString());
+            if (i < local_variable_table_length - 1) {
+                buf.append('\n');
+            }
+        }
+        return buf.toString();
+    }
+
+
+    /**
+     * @return deep copy of this attribute
+     */
+    public Attribute copy( ConstantPool _constant_pool ) {
+        AbstractLocalVariableTable c = (AbstractLocalVariableTable) clone();
+        c.local_variable_table = new LocalVariable[local_variable_table_length];
+        for (int i = 0; i < local_variable_table_length; i++) {
+            c.local_variable_table[i] = local_variable_table[i].copy();
+        }
+        c.constant_pool = _constant_pool;
+        return c;
+    }
+
+
+    public final int getTableLength() {
+        return local_variable_table_length;
+    }
+}
Index: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/Attribute.java
===================================================================
--- /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/Attribute.java	(revision 510968)
+++ /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/Attribute.java	(working copy)
@@ -159,7 +159,9 @@
                 return new LineNumberTable(name_index, length, file, constant_pool);
             case Constants.ATTR_LOCAL_VARIABLE_TABLE:
                 return new LocalVariableTable(name_index, length, file, constant_pool);
-            case Constants.ATTR_INNER_CLASSES:
+            case Constants.ATTR_LOCAL_VARIABLE_TYPE_TABLE:
+                return new LocalVariableTypeTable(name_index, length, file, constant_pool);
+           case Constants.ATTR_INNER_CLASSES:
                 return new InnerClasses(name_index, length, file, constant_pool);
             case Constants.ATTR_SYNTHETIC:
                 return new Synthetic(name_index, length, file, constant_pool);
Index: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/Constant.java
===================================================================
--- /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/Constant.java	(revision 510968)
+++ /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/Constant.java	(working copy)
@@ -141,7 +141,7 @@
             case Constants.CONSTANT_NameAndType:
                 return new ConstantNameAndType(file);
             case Constants.CONSTANT_Utf8:
-                return new ConstantUtf8(file);
+                return ConstantUtf8.getInstance(file);
             default:
                 throw new ClassFormatException("Invalid byte tag in constant pool: " + b);
         }
Index: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/ConstantUtf8.java
===================================================================
--- /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/ConstantUtf8.java	(revision 510968)
+++ /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/ConstantUtf8.java	(working copy)
@@ -19,7 +19,12 @@
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
 import org.apache.bcel.Constants;
+import org.apache.bcel.generic.ObjectType;
 
 /** 
  * This class is derived from the abstract 
@@ -32,9 +37,60 @@
  */
 public final class ConstantUtf8 extends Constant {
 
-    private String bytes;
+     private final String bytes;
+    
+    private static final int MAX_CACHE_ENTRIES = 20000;
+    private static final int INITIAL_CACHE_CAPACITY = (int)(MAX_CACHE_ENTRIES/0.75);
+    private static HashMap<String, ConstantUtf8> cache;
+    private static int considered = 0;
+    private static int hits = 0;
+    private static int skipped = 0;
+    private static int created = 0;
+    final static boolean BCEL_STATISTICS = Boolean.getBoolean("bcel.statistics");
+    final static boolean BCEL_DONT_CACHE = Boolean.getBoolean("bcel.dontCache");
+    
+    static {
+        if (BCEL_STATISTICS)
+        Runtime.getRuntime().addShutdownHook(new Thread() {
+            public void run() {
+                System.err.println("Cache hit " + hits + "/" + considered +", " 
+                        + skipped + " skipped");
+                System.err.println("Total of " + created + " ConstantUtf8 objects created");
+            }
+        });
+    }
+    public  static synchronized ConstantUtf8 getCachedInstance(String s) {
+        if (BCEL_DONT_CACHE || s.length() > 200) {
+            skipped++;
+            return  new ConstantUtf8(s);
+        }
+        considered++;
+        if (cache == null)  {
+                      cache = new LinkedHashMap<String, ConstantUtf8>(INITIAL_CACHE_CAPACITY, 0.75f, true) {
+            
+            protected boolean removeEldestEntry(Map.Entry eldest) {
+               return size() > MAX_CACHE_ENTRIES;
+            }
+            
+        };
+        }
+        ConstantUtf8 result = cache.get(s);
+        if (result != null) {
+            hits++;
+            return result;
+        }
+        result = new ConstantUtf8(s);
+        cache.put(s, result);
+        return result;
+    }
 
+    public static ConstantUtf8 getInstance(String s) {
+        return getCachedInstance(s);
+    }
 
+    public static ConstantUtf8 getInstance (DataInputStream file)  throws IOException {
+        return getInstance(file.readUTF());
+    }
     /**
      * Initialize from another object.
      */
@@ -52,6 +108,7 @@
     ConstantUtf8(DataInputStream file) throws IOException {
         super(Constants.CONSTANT_Utf8);
         bytes = file.readUTF();
+        created++;
     }
 
 
@@ -64,6 +121,7 @@
             throw new IllegalArgumentException("bytes must not be null!");
         }
         this.bytes = bytes;
+        created++;
     }
 
 
@@ -101,9 +159,10 @@
 
     /**
      * @param bytes the raw bytes of this Utf-8
+     * @deprecated
      */
     public final void setBytes( String bytes ) {
-        this.bytes = bytes;
+        throw new UnsupportedOperationException();
     }
 
 
Index: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/DescendingVisitor.java
===================================================================
--- /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/DescendingVisitor.java	(revision 510968)
+++ /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/DescendingVisitor.java	(working copy)
@@ -185,6 +185,9 @@
         }
         stack.pop();
     }
+    public void visitLocalVariableTypeTable( LocalVariableTypeTable table ) {
+        
+    }
 
 
     public void visitStackMap( StackMap table ) {
Index: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/EmptyVisitor.java
===================================================================
--- /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/EmptyVisitor.java	(revision 510968)
+++ /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/EmptyVisitor.java	(working copy)
@@ -158,4 +158,10 @@
 
     public void visitStackMapEntry( StackMapEntry obj ) {
     }
+
+
+    public void visitLocalVariableTypeTable(LocalVariableTypeTable obj) {
+        // TODO Auto-generated method stub
+        
+    }
 }
Index: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/LineNumber.java
===================================================================
--- /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/LineNumber.java	(revision 510968)
+++ /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/LineNumber.java	(working copy)
@@ -32,8 +32,8 @@
  */
 public final class LineNumber implements Cloneable, Node, Serializable {
 
-    private int start_pc; // Program Counter (PC) corresponds to line
-    private int line_number; // number in source file
+    private short start_pc; // Program Counter (PC) corresponds to line
+    private short line_number; // number in source file
 
 
     /**
@@ -59,8 +59,8 @@
      * @param line_number line number in source file
      */
     public LineNumber(int start_pc, int line_number) {
-        this.start_pc = start_pc;
-        this.line_number = line_number;
+        this.start_pc = (short) start_pc;
+        this.line_number = (short)line_number;
     }
 
 
@@ -92,7 +92,7 @@
      * @return Corresponding source line
      */
     public final int getLineNumber() {
-        return line_number;
+        return 0xffff & line_number;
     }
 
 
@@ -100,7 +100,7 @@
      * @return PC in code
      */
     public final int getStartPC() {
-        return start_pc;
+        return  0xffff & start_pc;
     }
 
 
@@ -108,7 +108,7 @@
      * @param line_number the source line number
      */
     public final void setLineNumber( int line_number ) {
-        this.line_number = line_number;
+        this.line_number = (short) line_number;
     }
 
 
@@ -116,7 +116,7 @@
      * @param start_pc the pc for this line number
      */
     public final void setStartPC( int start_pc ) {
-        this.start_pc = start_pc;
+        this.start_pc = (short) start_pc;
     }
 
 
Index: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/LocalVariableTable.java
===================================================================
--- /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/LocalVariableTable.java	(revision 510968)
+++ /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/LocalVariableTable.java	(working copy)
@@ -30,11 +30,7 @@
  * @see     Code
  * @see LocalVariable
  */
-public class LocalVariableTable extends Attribute {
-
-    private int local_variable_table_length; // Table of local
-    private LocalVariable[] local_variable_table; // variables
-
+public class LocalVariableTable extends AbstractLocalVariableTable {
 
     /**
      * Initialize from another object. Note that both objects use the same
@@ -53,8 +49,7 @@
      */
     public LocalVariableTable(int name_index, int length, LocalVariable[] local_variable_table,
             ConstantPool constant_pool) {
-        super(Constants.ATTR_LOCAL_VARIABLE_TABLE, name_index, length, constant_pool);
-        setLocalVariableTable(local_variable_table);
+        super(name_index,length, local_variable_table, constant_pool);
     }
 
 
@@ -68,12 +63,7 @@
      */
     LocalVariableTable(int name_index, int length, DataInputStream file, ConstantPool constant_pool)
             throws IOException {
-        this(name_index, length, (LocalVariable[]) null, constant_pool);
-        local_variable_table_length = (file.readUnsignedShort());
-        local_variable_table = new LocalVariable[local_variable_table_length];
-        for (int i = 0; i < local_variable_table_length; i++) {
-            local_variable_table[i] = new LocalVariable(file, constant_pool);
-        }
+       super(name_index,length, file, constant_pool);
     }
 
 
@@ -87,111 +77,4 @@
     public void accept( Visitor v ) {
         v.visitLocalVariableTable(this);
     }
-
-
-    /**
-     * Dump local variable table attribute to file stream in binary format.
-     *
-     * @param file Output file stream
-     * @throws IOException
-     */
-    public final void dump( DataOutputStream file ) throws IOException {
-        super.dump(file);
-        file.writeShort(local_variable_table_length);
-        for (int i = 0; i < local_variable_table_length; i++) {
-            local_variable_table[i].dump(file);
-        }
-    }
-
-
-    /**
-     * @return Array of local variables of method.
-     */
-    public final LocalVariable[] getLocalVariableTable() {
-        return local_variable_table;
-    }
-
-
-    /** 
-     * @return first matching variable using index
-     * 
-     * @param index the variable slot
-     * 
-     * @return the first LocalVariable that matches the slot or null if not found
-     * 
-     * @deprecated since 5.2 because multiple variables can share the
-     *             same slot, use getLocalVariable(int index, int pc) instead.
-     */
-    public final LocalVariable getLocalVariable( int index ) {
-        for (int i = 0; i < local_variable_table_length; i++) {
-            if (local_variable_table[i].getIndex() == index) {
-                return local_variable_table[i];
-            }
-        }
-        return null;
-    }
-
-
-    /** 
-     * @return matching variable using index when variable is used at supplied pc
-     * 
-     * @param index the variable slot
-     * @param pc the current pc that this variable is alive
-     * 
-     * @return the LocalVariable that matches or null if not found
-     */
-    public final LocalVariable getLocalVariable( int index, int pc ) {
-        for (int i = 0; i < local_variable_table_length; i++) {
-            if (local_variable_table[i].getIndex() == index) {
-                int start_pc = local_variable_table[i].getStartPC();
-                int end_pc = start_pc + local_variable_table[i].getLength();
-                if ((pc >= start_pc) && (pc < end_pc)) {
-                    return local_variable_table[i];
-                }
-            }
-        }
-        return null;
-    }
-
-
-    public final void setLocalVariableTable( LocalVariable[] local_variable_table ) {
-        this.local_variable_table = local_variable_table;
-        local_variable_table_length = (local_variable_table == null)
-                ? 0
-                : local_variable_table.length;
-    }
-
-
-    /**
-     * @return String representation.
-     */
-    public final String toString() {
-        StringBuffer buf = new StringBuffer("");
-        for (int i = 0; i < local_variable_table_length; i++) {
-            buf.append(local_variable_table[i].toString());
-            if (i < local_variable_table_length - 1) {
-                buf.append('\n');
-            }
-        }
-        return buf.toString();
-    }
-
-
-    /**
-     * @return deep copy of this attribute
-     */
-    public Attribute copy( ConstantPool _constant_pool ) {
-        LocalVariableTable c = (LocalVariableTable) clone();
-        c.local_variable_table = new LocalVariable[local_variable_table_length];
-        for (int i = 0; i < local_variable_table_length; i++) {
-            c.local_variable_table[i] = local_variable_table[i].copy();
-        }
-        c.constant_pool = _constant_pool;
-        return c;
-    }
-
-
-    public final int getTableLength() {
-        return local_variable_table_length;
-    }
 }
Index: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/LocalVariableTypeTable.java
===================================================================
--- /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/LocalVariableTypeTable.java	(revision 0)
+++ /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/LocalVariableTypeTable.java	(revision 0)
@@ -0,0 +1,22 @@
+package org.apache.bcel.classfile;
+
+import java.io.DataInputStream;
+import java.io.IOException;
+
+public class LocalVariableTypeTable extends AbstractLocalVariableTable {
+
+    public LocalVariableTypeTable(int name_index, int length, DataInputStream file, ConstantPool constant_pool) throws IOException {
+        super(name_index, length, file, constant_pool);
+    }
+    
+    /**
+     * Called by objects that are traversing the nodes of the tree implicitely
+     * defined by the contents of a Java class. I.e., the hierarchy of methods,
+     * fields, attributes, etc. spawns a tree of objects.
+     *
+     * @param v Visitor object
+     */
+    public void accept( Visitor v ) {
+        v.visitLocalVariableTypeTable(this);
+    }
+}
Index: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/Visitor.java
===================================================================
--- /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/Visitor.java	(revision 510968)
+++ /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/classfile/Visitor.java	(working copy)
@@ -103,6 +103,7 @@
 
 
     public void visitLocalVariableTable( LocalVariableTable obj );
+    public void visitLocalVariableTypeTable( LocalVariableTypeTable obj );
 
 
     public void visitMethod( Method obj );
Index: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/Constants.java
===================================================================
--- /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/Constants.java	(revision 510968)
+++ /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/Constants.java	(working copy)
@@ -729,13 +729,16 @@
   public static final byte ATTR_PMG                           			= 9;
   public static final byte ATTR_SIGNATURE                     			= 10;
   public static final byte ATTR_STACK_MAP                     			= 11;
-  public static final byte ATTR_RUNTIMEVISIBLE_ANNOTATIONS    			= 12;
-  public static final byte ATTR_RUNTIMEINVISIBLE_ANNOTATIONS  			= 13;
-  public static final byte ATTR_RUNTIMEVISIBLE_PARAMETER_ANNOTATIONS 	= 14;
-  public static final byte ATTR_RUNTIMEINVISIBLE_PARAMETER_ANNOTATIONS 	= 15;
-  public static final byte ATTR_ANNOTATION_DEFAULT                      = 16;
+  public static final byte ATTR_LOCAL_VARIABLE_TYPE_TABLE                    = 12;
+  public static final byte ATTR_RUNTIMEVISIBLE_ANNOTATIONS    			= 13;
+  public static final byte ATTR_RUNTIMEINVISIBLE_ANNOTATIONS  			= 14;
+  public static final byte ATTR_RUNTIMEVISIBLE_PARAMETER_ANNOTATIONS 	= 15;
+  public static final byte ATTR_RUNTIMEINVISIBLE_PARAMETER_ANNOTATIONS 	= 16;
+  public static final byte ATTR_ANNOTATION_DEFAULT                      = 17;
+ 
+  
 
-  public static final short KNOWN_ATTRIBUTES = 12;//should be 17
+  public static final short KNOWN_ATTRIBUTES = 13;//should be 17
 
   public static final String[] ATTRIBUTE_NAMES = {
     "SourceFile", "ConstantValue", "Code", "Exceptions",
@@ -741,7 +744,7 @@
     "SourceFile", "ConstantValue", "Code", "Exceptions",
     "LineNumberTable", "LocalVariableTable",
     "InnerClasses", "Synthetic", "Deprecated",
-    "PMGClass", "Signature", "StackMap", 
+    "PMGClass", "Signature", "StackMap", "LocalVariableTypeTable", 
     "RuntimeVisibleAnnotations", "RuntimeInvisibleAnnotations",
     "RuntimeVisibleParameterAnnotations", "RuntimeInvisibleParameterAnnotations",
     "AnnotationDefault"
Index: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/ArrayType.java
===================================================================
--- /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/ArrayType.java	(revision 510968)
+++ /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/ArrayType.java	(working copy)
@@ -46,7 +46,7 @@
      * @param class_name complete name of class (java.lang.String, e.g.)
      */
     public ArrayType(String class_name, int dimensions) {
-        this(new ObjectType(class_name), dimensions);
+        this(ObjectType.getInstance(class_name), dimensions);
     }
 
 
Index: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/FieldGen.java
===================================================================
--- /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/FieldGen.java	(revision 510968)
+++ /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/FieldGen.java	(working copy)
@@ -107,7 +107,7 @@
      * by the JVM automatically.
      */
     public void setInitValue( String str ) {
-        checkType(new ObjectType("java.lang.String"));
+        checkType(  ObjectType.getInstance("java.lang.String"));
         if (str != null) {
             value = str;
         }
Index: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/FieldOrMethod.java
===================================================================
--- /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/FieldOrMethod.java	(revision 510968)
+++ /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/FieldOrMethod.java	(working copy)
@@ -94,7 +94,7 @@
      *    getReferenceType() instead.
      */
     public ObjectType getClassType( ConstantPoolGen cpg ) {
-        return new ObjectType(getClassName(cpg));
+        return ObjectType.getInstance(getClassName(cpg));
     }
 
 
@@ -115,7 +115,7 @@
             return (ArrayType) Type.getType(className);
         } else {
             className = className.replace('/', '.');
-            return new ObjectType(className);
+            return ObjectType.getInstance(className);
         }
     }
 
Index: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/InstructionFactory.java
===================================================================
--- /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/InstructionFactory.java	(revision 510968)
+++ /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/InstructionFactory.java	(working copy)
@@ -616,7 +616,7 @@
 
 
     public NEW createNew( String s ) {
-        return createNew(new ObjectType(s));
+        return createNew(ObjectType.getInstance(s));
     }
 
 
Index: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/MethodGen.java
===================================================================
--- /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/MethodGen.java	(revision 510968)
+++ /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/MethodGen.java	(working copy)
@@ -122,7 +122,7 @@
             /* Add local variables, namely the implicit `this' and the arguments
              */
             if (!isStatic() && (class_name != null)) { // Instance method -> `this' is local var 0
-                addLocalVariable("this", new ObjectType(class_name), start, end);
+                addLocalVariable("this",  ObjectType.getInstance(class_name), start, end);
             }
         }
         if (arg_types != null) {
@@ -183,7 +183,7 @@
                         if (type > 0) {
                             String cen = m.getConstantPool().getConstantString(type,
                                     Constants.CONSTANT_Class);
-                            c_type = new ObjectType(cen);
+                            c_type =  ObjectType.getInstance(cen);
                         }
                         int end_pc = ce.getEndPC();
                         int length = m.getCode().getCode().length;
Index: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/ObjectType.java
===================================================================
--- /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/ObjectType.java	(revision 510968)
+++ /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/ObjectType.java	(working copy)
@@ -16,6 +16,10 @@
  */
 package org.apache.bcel.generic;
 
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
 import org.apache.bcel.Constants;
 import org.apache.bcel.Repository;
 import org.apache.bcel.classfile.JavaClass;
@@ -20,6 +24,7 @@
 import org.apache.bcel.Repository;
 import org.apache.bcel.classfile.JavaClass;
 
+
 /** 
  * Denotes reference such as java.lang.String.
  *
@@ -28,8 +33,27 @@
  */
 public class ObjectType extends ReferenceType {
 
-    private String class_name; // Class name of type
+    private static final int MAX_CACHE_ENTRIES = 200;
+    private static final int INITIAL_CACHE_CAPACITY = (int)(MAX_CACHE_ENTRIES/0.75);
+    private static HashMap<String, ObjectType> cache;
+    public synchronized static ObjectType getInstance(String class_name) {
+        if (cache == null) 
+            cache = new LinkedHashMap<String, ObjectType>(INITIAL_CACHE_CAPACITY, 0.75f, true) {
+            
+
+            protected boolean removeEldestEntry(Map.Entry eldest) {
+               return size() > MAX_CACHE_ENTRIES;
+            }
+        
+        };
+        ObjectType result = cache.get(class_name);
+        if (result != null) return result;
+        result = new ObjectType(class_name);
+        cache.put(class_name, result);
+        return result;
+    }
 
+    final private String class_name; // Class name of type
 
     /**
      * @param class_name fully qualified class name, e.g. java.lang.String
Index: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/ReferenceType.java
===================================================================
--- /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/ReferenceType.java	(revision 510968)
+++ /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/ReferenceType.java	(working copy)
@@ -162,7 +162,7 @@
             // 'java.io.Serializable'"
             if ((T instanceof ObjectType) && (((ObjectType) T).referencesInterfaceExact())) {
                 for (int ii = 0; ii < Constants.INTERFACES_IMPLEMENTED_BY_ARRAYS.length; ii++) {
-                    if (T.equals(new ObjectType(Constants.INTERFACES_IMPLEMENTED_BY_ARRAYS[ii]))) {
+                    if (T.equals(ObjectType.getInstance(Constants.INTERFACES_IMPLEMENTED_BY_ARRAYS[ii]))) {
                         return true;
                     }
                 }
@@ -248,7 +248,7 @@
         for (int i = 0; i < t_sups.length; i++) {
             for (int j = 0; j < this_sups.length; j++) {
                 if (this_sups[j].equals(t_sups[i])) {
-                    return new ObjectType(this_sups[j].getClassName());
+                    return ObjectType.getInstance(this_sups[j].getClassName());
                 }
             }
         }
@@ -320,7 +320,7 @@
         for (int i = 0; i < t_sups.length; i++) {
             for (int j = 0; j < this_sups.length; j++) {
                 if (this_sups[j].equals(t_sups[i])) {
-                    return new ObjectType(this_sups[j].getClassName());
+                    return ObjectType.getInstance(this_sups[j].getClassName());
                 }
             }
         }
Index: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/Type.java
===================================================================
--- /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/Type.java	(revision 510968)
+++ /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/generic/Type.java	(working copy)
@@ -31,7 +31,7 @@
  */
 public abstract class Type implements java.io.Serializable {
 
-    protected byte type;
+    final protected byte type;
     protected String signature; // signature for the type
     /** Predefined constants
      */
@@ -44,11 +44,11 @@
     public static final BasicType DOUBLE = new BasicType(Constants.T_DOUBLE);
     public static final BasicType FLOAT = new BasicType(Constants.T_FLOAT);
     public static final BasicType CHAR = new BasicType(Constants.T_CHAR);
-    public static final ObjectType OBJECT = new ObjectType("java.lang.Object");
-    public static final ObjectType CLASS = new ObjectType("java.lang.Class");
-    public static final ObjectType STRING = new ObjectType("java.lang.String");
-    public static final ObjectType STRINGBUFFER = new ObjectType("java.lang.StringBuffer");
-    public static final ObjectType THROWABLE = new ObjectType("java.lang.Throwable");
+    public static final ObjectType OBJECT = ObjectType.getInstance("java.lang.Object");
+    public static final ObjectType CLASS = ObjectType.getInstance("java.lang.Class");
+    public static final ObjectType STRING = ObjectType.getInstance("java.lang.String");
+    public static final ObjectType STRINGBUFFER = ObjectType.getInstance("java.lang.StringBuffer");
+    public static final ObjectType THROWABLE = ObjectType.getInstance("java.lang.Throwable");
     public static final Type[] NO_ARGS = new Type[0];
     public static final ReferenceType NULL = new ReferenceType() {
     };
@@ -190,7 +190,7 @@
             }
             //corrected concurrent private static field acess
             wrap(consumed_chars, index + 1); // "Lblabla;" `L' and `;' are removed
-            return new ObjectType(signature.substring(1, index).replace('/', '.'));
+            return ObjectType.getInstance(signature.substring(1, index).replace('/', '.'));
         }
     }
 
@@ -278,7 +278,7 @@
                 throw new IllegalStateException("Ooops, what primitive type is " + cl);
             }
         } else { // "Real" class
-            return new ObjectType(cl.getName());
+            return ObjectType.getInstance(cl.getName());
         }
     }
 
Index: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java
===================================================================
--- /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java	(revision 510968)
+++ /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/verifier/structurals/InstConstraintVisitor.java	(working copy)
@@ -52,7 +52,7 @@
  */
 public class InstConstraintVisitor extends EmptyVisitor implements org.apache.bcel.generic.Visitor{
 
-	private static ObjectType GENERIC_ARRAY = new ObjectType("org.apache.bcel.verifier.structurals.GenericArray");
+	private static ObjectType GENERIC_ARRAY = ObjectType.getInstance("org.apache.bcel.verifier.structurals.GenericArray");
 
 	/**
 	 * The constructor. Constructs a new instance of this class.
@@ -1207,7 +1207,7 @@
 
 		if (f.isProtected()){
 			ObjectType classtype = o.getClassType(cpg);
-			ObjectType curr = new ObjectType(mg.getClassName());
+			ObjectType curr = ObjectType.getInstance(mg.getClassName());
 
 			if (	classtype.equals(curr) ||
 						curr.subclassOf(classtype)	){
@@ -2531,7 +2531,7 @@
 		
 		if (f.isProtected()){
 			ObjectType classtype = o.getClassType(cpg);
-			ObjectType curr = new ObjectType(mg.getClassName());
+			ObjectType curr = ObjectType.getInstance(mg.getClassName());
 
 			if (	classtype.equals(curr) ||
 						curr.subclassOf(classtype)	){
Index: /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/verifier/structurals/Pass3bVerifier.java
===================================================================
--- /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/verifier/structurals/Pass3bVerifier.java	(revision 510968)
+++ /Users/pugh/Documents/eclipse/workspace/jakarta-bcel-5.2/src/java/org/apache/bcel/verifier/structurals/Pass3bVerifier.java	(working copy)
@@ -301,7 +301,7 @@
 				Frame f = new Frame(mg.getMaxLocals(),mg.getMaxStack());
 				if ( !mg.isStatic() ){
 					if (mg.getName().equals(Constants.CONSTRUCTOR_NAME)){
-						Frame._this = new UninitializedObjectType(new ObjectType(jc.getClassName()));
+						Frame._this = new UninitializedObjectType(ObjectType.getInstance(jc.getClassName()));
 						f.getLocals().set(0, Frame._this);
 					}
 					else{
@@ -306,7 +306,7 @@
 					}
 					else{
 						Frame._this = null;
-						f.getLocals().set(0, new ObjectType(jc.getClassName()));
+						f.getLocals().set(0, ObjectType.getInstance(jc.getClassName()));
 					}
 				}
 				Type[] argtypes = mg.getArgumentTypes();