View Javadoc

1   /*
2    $Id: ScriptBytecodeAdapter.java,v 1.5 2005/03/31 10:02:49 jstrachan Exp $
3   
4    Copyright 2003 (C) James Strachan and Bob Mcwhirter. All Rights Reserved.
5   
6    Redistribution and use of this software and associated documentation
7    ("Software"), with or without modification, are permitted provided
8    that the following conditions are met:
9   
10   1. Redistributions of source code must retain copyright
11      statements and notices.  Redistributions must also contain a
12      copy of this document.
13  
14   2. Redistributions in binary form must reproduce the
15      above copyright notice, this list of conditions and the
16      following disclaimer in the documentation and/or other
17      materials provided with the distribution.
18  
19   3. The name "groovy" must not be used to endorse or promote
20      products derived from this Software without prior written
21      permission of The Codehaus.  For written permission,
22      please contact info@codehaus.org.
23  
24   4. Products derived from this Software may not be called "groovy"
25      nor may "groovy" appear in their names without prior written
26      permission of The Codehaus. "groovy" is a registered
27      trademark of The Codehaus.
28  
29   5. Due credit should be given to The Codehaus -
30      http://groovy.codehaus.org/
31  
32   THIS SOFTWARE IS PROVIDED BY THE CODEHAUS AND CONTRIBUTORS
33   ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
34   NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
35   FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
36   THE CODEHAUS OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
37   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
38   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
39   SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
40   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
41   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
42   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
43   OF THE POSSIBILITY OF SUCH DAMAGE.
44  
45   */
46  package org.codehaus.groovy.runtime;
47  
48  import groovy.lang.*;
49  
50  import java.util.Iterator;
51  import java.util.List;
52  import java.util.Map;
53  import java.util.regex.Matcher;
54  import java.util.regex.Pattern;
55  
56  /***
57   * A static helper class to make bytecode generation easier and act as a facade over the Invoker. 
58   *
59   * @author <a href="mailto:james@coredevelopers.net">James Strachan</a>
60   * @version $Revision: 1.5 $
61   */
62  public class ScriptBytecodeAdapter {
63      public static final Object[] EMPTY_ARGS = {
64      };
65  /*
66      private static final Object[] EMPTY_MAIN_ARGS = new Object[]{new String[0]};
67  
68      private static final Invoker singleton = new Invoker();
69  
70      private static final Integer ZERO = new Integer(0);
71      private static final Integer MINUS_ONE = new Integer(-1);
72      private static final Integer ONE = new Integer(1);*/
73  
74      
75      private static Object unwrap(GroovyRuntimeException gre) throws Throwable{
76          Throwable th = gre;
77          if (th.getCause()!=null && th.getCause()!=gre) th=th.getCause();
78          if (th!=gre && (th instanceof GroovyRuntimeException)) unwrap((GroovyRuntimeException) th);
79          throw th;
80      }
81  
82      public static Object invokeMethod(Object object, String methodName, Object arguments)  throws Throwable{
83          try {
84              return InvokerHelper.invokeMethod(object, methodName, arguments);
85          } catch (GroovyRuntimeException gre) {
86              return unwrap(gre);
87          }
88      }
89      
90      public static Object invokeMethodSafe(Object object, String methodName, Object arguments) throws Throwable{
91          if (object != null) return invokeMethod(object, methodName, arguments);
92          return null;
93      }    
94  
95      public static Object invokeStaticMethod(String type, String methodName, Object arguments) throws Throwable{
96          try {
97              return InvokerHelper.invokeStaticMethod(type, methodName, arguments);
98          } catch (GroovyRuntimeException gre) {
99              return unwrap(gre);
100         }
101     }
102 
103     public static Object invokeConstructor(String type, Object arguments) throws Throwable{
104         try {
105             return InvokerHelper.invokeConstructor(type, arguments);
106         } catch (GroovyRuntimeException gre) {
107             return unwrap(gre);
108         }
109     }
110 
111     public static Object invokeConstructorOf(Class type, Object arguments) throws Throwable{
112         try {
113             return InvokerHelper.invokeConstructorOf(type, arguments);
114         } catch (GroovyRuntimeException gre) {
115             return unwrap(gre);
116         }  
117     }
118     
119     public static Object invokeNoArgumentsConstructorOf(Class type) throws Throwable{
120         return invokeConstructorOf(type, EMPTY_ARGS);
121     }
122     
123     public static Object invokeClosure(Object closure, Object arguments) throws Throwable {
124         return invokeMethod(closure, "doCall", arguments);
125     }    
126     
127     public static Object invokeSuperMethod(Object object, String methodName, Object arguments) throws Throwable{
128         try {
129             return InvokerHelper.invokeSuperMethod(object, methodName, arguments);
130         } catch (GroovyRuntimeException gre) {
131             return unwrap(gre);
132         } 
133     }
134     
135     public static Object invokeNoArgumentsMethod(Object object, String methodName) throws Throwable {
136         return invokeMethod(object, methodName, EMPTY_ARGS);
137     }
138     
139     public static Object invokeStaticNoArgumentsMethod(String type, String methodName) throws Throwable {
140         return invokeStaticMethod(type, methodName, EMPTY_ARGS);
141     }
142     
143     public static int asInt(Object value) throws Throwable {
144         try {
145             return InvokerHelper.asInt(value);
146         } catch (GroovyRuntimeException gre) {
147            unwrap(gre);
148            // return never reached
149            return -1;
150         }
151     }
152     
153     /***
154      * Provides a hook for type coercion of the given object to the required type
155      *
156      * @param type   of object to convert the given object to
157      * @param object the object to be converted
158      * @return the original object or a new converted value
159      * @throws Throwable 
160      */
161     public static Object asType(Object object, Class type) throws Throwable {
162         try {
163             return InvokerHelper.asType(object, type);
164         } catch (GroovyRuntimeException gre) {
165             return unwrap(gre);
166         }
167     }
168 
169 
170 
171     // Attributes
172     //-------------------------------------------------------------------------
173     public static Object getAttribute(Object object, String attribute) throws Throwable {
174         try {
175             return InvokerHelper.getAttribute(object, attribute);
176         } catch (GroovyRuntimeException gre) {
177             return unwrap(gre);
178         }
179     }
180 
181     public static Object getAttributeSafe(Object object, String attribute) throws Throwable {
182         if (object != null) return getAttribute(object, attribute);
183         return null;
184     }
185 
186     public static void setAttribute(Object object, String attribute, Object newValue) throws Throwable {
187         try {
188             InvokerHelper.setAttribute(object, attribute, newValue);
189         } catch (GroovyRuntimeException gre) {
190             unwrap(gre);
191         }
192     }
193     /***
194      * This is so we don't have to reorder the stack when we call this method.
195      * At some point a better name might be in order.
196      * @throws Throwable
197      */
198     public static void setAttribute2(Object newValue, Object object, String property) throws Throwable {
199         setAttribute(object, property, newValue);
200     }
201 
202     /***
203      * This is so we don't have to reorder the stack when we call this method.
204      * At some point a better name might be in order.
205      * @throws Throwable
206      */
207     public static void setAttributeSafe2(Object newValue, Object object, String property) throws Throwable {
208         setAttribute2(newValue, object, property);
209     }
210 
211 
212 
213     // Properties
214     //-------------------------------------------------------------------------
215     public static Object getProperty(Object object, String property) throws Throwable {
216         try {
217             return InvokerHelper.getProperty(object, property);
218         } catch (GroovyRuntimeException gre) {
219             return unwrap(gre);
220         }
221     }
222 
223     public static Object getPropertySafe(Object object, String property) throws Throwable {
224         if (object != null) return getProperty(object, property);
225         return null;
226     }
227 
228     public static void setProperty(Object object, String property, Object newValue) throws Throwable {
229         try {
230             InvokerHelper.setProperty(object, property, newValue);
231         } catch (GroovyRuntimeException gre) {
232             unwrap(gre);
233         }
234     }
235     
236     /***
237      * This is so we don't have to reorder the stack when we call this method.
238      * At some point a better name might be in order.
239      * @throws Throwable 
240      */
241     public static void setProperty2(Object newValue, Object object, String property) throws Throwable {
242         setProperty(object, property, newValue);
243     }
244 
245     /***
246      * This is so we don't have to reorder the stack when we call this method.
247      * At some point a better name might be in order.
248      * @throws Throwable 
249      */
250     public static void setPropertySafe2(Object newValue, Object object, String property) throws Throwable {
251         setProperty2(newValue, object, property);
252     }
253 
254 
255     /***
256      * This is so we don't have to reorder the stack when we call this method.
257      * At some point a better name might be in order.
258      * @throws Throwable 
259      */
260     public static void setGroovyObjectProperty(Object newValue, GroovyObject object, String property) throws Throwable {
261         try {
262             object.setProperty(property, newValue);
263         } catch (GroovyRuntimeException gre) {
264             unwrap(gre);
265         }
266     }
267 
268     public static Object getGroovyObjectProperty(GroovyObject object, String property) throws Throwable {
269         try {
270             return object.getProperty(property);
271         } catch (GroovyRuntimeException gre) {
272             return unwrap(gre);
273         }
274     }
275 
276 
277     /***
278      * Returns the method pointer for the given object name
279      */
280     public static Closure getMethodPointer(Object object, String methodName) {
281         return InvokerHelper.getMethodPointer(object, methodName);
282     }
283 
284     // Coercions
285     //-------------------------------------------------------------------------
286     public static Iterator asIterator(Object collection) throws Throwable {
287         try {
288             return InvokerHelper.asIterator(collection);
289         } catch (GroovyRuntimeException gre) {
290             return (Iterator) unwrap(gre);
291         }
292     }    
293     
294     public static boolean asBool(Object object) throws Throwable {
295         try {
296             return InvokerHelper.asBool(object);
297         } catch (GroovyRuntimeException gre) {
298             unwrap(gre);
299             //return never reached
300             return false;
301         }
302     }
303     
304     public static boolean notBoolean(boolean bool) {
305         return !bool;
306     }    
307     
308     public static boolean notObject(Object object) throws Throwable {
309         return !asBool(object);
310     }
311     
312     public static Pattern regexPattern(Object regex) throws Throwable {
313         try {
314             return InvokerHelper.regexPattern(regex);
315         } catch (GroovyRuntimeException gre) {
316             return (Pattern) unwrap(gre);
317         }
318     }
319     
320     public static Object spreadList(Object value) throws Throwable {
321         try {
322             return InvokerHelper.spreadList(value);
323         } catch (GroovyRuntimeException gre) {
324             return unwrap(gre);
325         }
326     }
327 
328     public static Object negate(Object value) throws Throwable {
329         try {
330             return InvokerHelper.negate(value);
331         } catch (GroovyRuntimeException gre) {
332             return unwrap(gre);
333         }
334     }
335     
336     public static Object bitNegate(Object value) throws Throwable {
337         try {
338             return InvokerHelper.bitNegate(value);
339         } catch (GroovyRuntimeException gre) {
340             return unwrap(gre);
341         }
342     }
343     
344     /***
345      * @param a    array of primitives
346      * @param type component type of the array
347      * @return
348      * @throws Throwable 
349      */
350     public static Object[] convertPrimitiveArray(Object a, Class type) throws Throwable {
351         try {
352             return InvokerHelper.convertPrimitiveArray(a,type);
353         } catch (GroovyRuntimeException gre) {
354             return (Object[])unwrap(gre);
355         }
356     }
357     
358     public static Object convertToPrimitiveArray(Object a, Class type) throws Throwable {
359         try {
360             return InvokerHelper.convertToPrimitiveArray(a,type);
361         } catch (GroovyRuntimeException gre) {
362             return unwrap(gre);
363         }
364     }
365 
366     public static boolean compareIdentical(Object left, Object right) {
367         return left == right;
368     }
369     
370     public static boolean compareEqual(Object left, Object right) throws Throwable{
371         try {
372             return InvokerHelper.compareEqual(left, right);
373         } catch (GroovyRuntimeException gre) {
374             unwrap(gre);
375             // return never reached
376             return false;
377         }
378     }
379     
380     public static boolean compareNotEqual(Object left, Object right) throws Throwable{
381         return !compareEqual(left, right);
382     }
383     
384     public static Integer compareTo(Object left, Object right) throws Throwable{
385         try {
386             return InvokerHelper.compareTo(left, right);
387         } catch (GroovyRuntimeException gre) {
388             return (Integer) unwrap(gre);
389         }
390     }    
391 
392     public static Matcher findRegex(Object left, Object right) throws Throwable{
393         try {
394             return InvokerHelper.findRegex(left, right);
395         } catch (GroovyRuntimeException gre) {
396             return (Matcher) unwrap(gre);
397         }
398     }
399     
400     public static boolean matchRegex(Object left, Object right) throws Throwable{
401         try {
402             return InvokerHelper.matchRegex(left, right);
403         } catch (GroovyRuntimeException gre) {
404             unwrap(gre);
405             // return never reached
406             return false;
407         }
408     }
409 
410     public static boolean compareLessThan(Object left, Object right) throws Throwable{
411         return compareTo(left, right).intValue() < 0;
412     }
413     
414     public static boolean compareLessThanEqual(Object left, Object right) throws Throwable{
415         return compareTo(left, right).intValue() <= 0;
416     }
417     
418     public static boolean compareGreaterThan(Object left, Object right) throws Throwable{
419         return compareTo(left, right).intValue() > 0;
420     }
421 
422     public static boolean compareGreaterThanEqual(Object left, Object right) throws Throwable{
423         return compareTo(left, right).intValue() >= 0;
424     }
425     
426     public static boolean isCase(Object switchValue, Object caseExpression) throws Throwable{
427         return asBool(invokeMethod(caseExpression, "isCase", new Object[]{switchValue}));
428     }
429     
430     public static Tuple createTuple(Object[] array) throws Throwable{
431         return new Tuple(array);
432     }
433 
434     public static List createList(Object[] values) throws Throwable{
435         return InvokerHelper.createList(values);
436     }
437 
438     public static Map createMap(Object[] values) throws Throwable{
439         return InvokerHelper.createMap(values);
440     }
441     
442     public static List createRange(Object from, Object to, boolean inclusive) throws Throwable{
443         try {
444             return InvokerHelper.createRange(from,to,inclusive);
445         } catch (GroovyRuntimeException gre) {
446             return (List) unwrap(gre);
447         }
448     }
449     
450     public static void assertFailed(Object expression, Object message) {
451         InvokerHelper.assertFailed(expression,message);
452     }
453     
454     public static Object box(boolean value) {
455         return value ? Boolean.TRUE : Boolean.FALSE;
456     }
457 
458     public static Object box(byte value) {
459         return new Byte(value);
460     }
461 
462     public static Object box(char value) {
463         return new Character(value);
464     }
465 
466     public static Object box(short value) {
467         return new Short(value);
468     }
469 
470     public static Object box(int value) {
471         return integerValue(value);
472     }
473 
474     public static Object box(long value) {
475         return new Long(value);
476     }
477 
478     public static Object box(float value) {
479         return new Float(value);
480     }
481 
482     public static Object box(double value) {
483         return new Double(value);
484     }
485     
486     /***
487      * get the Integer object from an int. Cached version is used for small ints.
488      *
489      * @param v
490      * @return
491      */
492     public static Integer integerValue(int v) {
493         return InvokerHelper.integerValue(v);
494     }    
495 
496     public static byte byteUnbox(Object value) throws Throwable {
497         Number n = (Number) asType(value, Byte.class);
498         return n.byteValue();
499     }
500 
501     public static char charUnbox(Object value) throws Throwable {
502         Character n = (Character) asType(value, Character.class);
503         return n.charValue();
504     }
505 
506     public static short shortUnbox(Object value) throws Throwable {
507         Number n = (Number) asType(value, Short.class);
508         return n.shortValue();
509     }
510 
511     public static int intUnbox(Object value) throws Throwable {
512         Number n = (Number) asType(value, Integer.class);
513         return n.intValue();
514     }
515 
516     public static boolean booleanUnbox(Object value) throws Throwable {
517         Boolean n = (Boolean) asType(value, Boolean.class);
518         return n.booleanValue();
519     }
520 
521     public static long longUnbox(Object value) throws Throwable {
522         Number n = (Number) asType(value, Long.class);
523         return n.longValue();
524     }
525 
526     public static float floatUnbox(Object value) throws Throwable {
527         Number n = (Number) asType(value, Float.class);
528         return n.floatValue();
529     }
530 
531     public static double doubleUnbox(Object value) throws Throwable {
532         Number n = (Number) asType(value, Double.class);
533         return n.doubleValue();
534     }    
535     
536     public static MetaClass getMetaClass(Object object) {
537         return InvokerHelper.getMetaClass(object);
538     }
539 
540     /*
541     public static void removeClass(Class clazz) {
542         getInstance().removeMetaClass(clazz);
543         Introspector.flushFromCaches(clazz);
544     }
545 
546     public static Invoker getInstance() {
547         return singleton;
548     }
549 
550     public static Collection asCollection(Object collection) {
551         return getInstance().asCollection(collection);
552     }
553 
554     public static List asList(Object args) {
555         return getInstance().asList(args);
556     }
557 
558     public static String toString(Object arguments) {
559         return getInstance().toString(arguments);
560     }
561 
562     public static String toTypeString(Object[] arguments) {
563         return getInstance().toTypeString(arguments);
564     }
565 
566     public static String inspect(Object self) {
567         return getInstance().inspect(self);
568     }
569 
570 
571 
572     public static Object runScript(Class scriptClass, String[] args) {
573         Binding context = new Binding(args);
574         Script script = createScript(scriptClass, context);
575         return invokeMethod(script, "run", EMPTY_ARGS);
576     }
577 
578     public static Script createScript(Class scriptClass, Binding context) {
579         try {
580             final GroovyObject object = (GroovyObject) scriptClass.newInstance();
581             Script script = null;
582             if (object instanceof Script) {
583                 script = (Script) object;
584             } else {
585                 // it could just be a class, so lets wrap it in a Script wrapper
586                 // though the bindings will be ignored
587                 script = new Script() {
588                     public Object run() {
589                         object.invokeMethod("main", EMPTY_MAIN_ARGS);
590                         return null;
591                     }
592                 };
593                 setProperties(object, context.getVariables());
594             }
595             script.setBinding(context);
596             return script;
597         } catch (Exception e) {
598             throw new GroovyRuntimeException("Failed to create Script instance for class: " + scriptClass + ". Reason: " + e,
599                     e);
600         }
601     }
602 */
603     
604     /***
605      * Sets the properties on the given object
606      *
607      * @param object
608      * @param map
609      */
610 /*    public static void setProperties(Object object, Map map) {
611         getMetaClass(object).setProperties(object, map);
612     }
613 
614     public static String getVersion() {
615         String version = null;
616         Package p = Package.getPackage("groovy.lang");
617         if (p != null) {
618             version = p.getImplementationVersion();
619         }
620         if (version == null) {
621             version = "";
622         }
623         return version;
624     }*/
625 
626     /***
627      * Allows conversion of arrays into a mutable List
628      *
629      * @return the array as a List
630      */
631     /*protected static List primitiveArrayToList(Object array) {
632         int size = Array.getLength(array);
633         List list = new ArrayList(size);
634         for (int i = 0; i < size; i++) {
635             list.add(Array.get(array, i));
636         }
637         return list;
638     }*/
639 
640     /***
641      * Writes the given object to the given stream
642      */
643 /*    public static void write(Writer out, Object object) throws IOException {
644         if (object instanceof String) {
645             out.write((String) object);
646         } else if (object instanceof Writable) {
647             Writable writable = (Writable) object;
648             writable.writeTo(out);
649         } else if (object instanceof InputStream || object instanceof Reader) {
650             // Copy stream to stream
651             Reader reader;
652             if (object instanceof InputStream) {
653                 reader = new InputStreamReader((InputStream) object);
654             } else {
655                 reader = (Reader) object;
656             }
657             char[] chars = new char[8192];
658             int i;
659             while ((i = reader.read(chars)) != -1) {
660                 out.write(chars, 0, i);
661             }
662             reader.close();
663         } else {
664             out.write(toString(object));
665         }
666     }
667 
668     public static int[] convertToIntArray(Object a) {
669         int[] ans = null;
670 
671         // conservative coding
672         if (a.getClass().getName().equals("[I")) {
673             ans = (int[]) a;
674         } else {
675             Object[] ia = (Object[]) a;
676             ans = new int[ia.length];
677             for (int i = 0; i < ia.length; i++) {
678                 ans[i] = ((Number) ia[i]).intValue();
679             }
680         }
681         return ans;
682     }
683 
684     public static boolean[] convertToBooleanArray(Object a) {
685         boolean[] ans = null;
686 
687         // conservative coding
688         if (a.getClass().getName().equals("[Z")) {
689             ans = (boolean[]) a;
690         } else {
691             Object[] ia = (Object[]) a;
692             ans = new boolean[ia.length];
693             for (int i = 0; i < ia.length; i++) {
694                 ans[i] = ((Boolean) ia[i]).booleanValue();
695             }
696         }
697         return ans;
698     }
699 
700     public static byte[] convertToByteArray(Object a) {
701         byte[] ans = null;
702 
703         // conservative coding
704         if (a.getClass().getName().equals("[B")) {
705             ans = (byte[]) a;
706         } else {
707             Object[] ia = (Object[]) a;
708             ans = new byte[ia.length];
709             for (int i = 0; i < ia.length; i++) {
710                 if (ia[i] != null)
711                     ans[i] = ((Number) ia[i]).byteValue();
712             }
713         }
714         return ans;
715     }
716 
717     public static short[] convertToShortArray(Object a) {
718         short[] ans = null;
719 
720         // conservative coding
721         if (a.getClass().getName().equals("[S")) {
722             ans = (short[]) a;
723         } else {
724             Object[] ia = (Object[]) a;
725             ans = new short[ia.length];
726             for (int i = 0; i < ia.length; i++) {
727                 ans[i] = ((Number) ia[i]).shortValue();
728             }
729         }
730         return ans;
731     }
732 
733     public static char[] convertToCharArray(Object a) {
734         char[] ans = null;
735 
736         // conservative coding
737         if (a.getClass().getName().equals("[C")) {
738             ans = (char[]) a;
739         } else {
740             Object[] ia = (Object[]) a;
741             ans = new char[ia.length];
742             for (int i = 0; i < ia.length; i++) {
743                 ans[i] = ((Character) ia[i]).charValue();
744             }
745         }
746         return ans;
747     }
748 
749     public static long[] convertToLongArray(Object a) {
750         long[] ans = null;
751 
752         // conservative coding
753         if (a.getClass().getName().equals("[J")) {
754             ans = (long[]) a;
755         } else {
756             Object[] ia = (Object[]) a;
757             ans = new long[ia.length];
758             for (int i = 0; i < ia.length; i++) {
759                 ans[i] = ((Number) ia[i]).longValue();
760             }
761         }
762         return ans;
763     }
764 
765     public static float[] convertToFloatArray(Object a) {
766         float[] ans = null;
767 
768         // conservative coding
769         if (a.getClass().getName().equals("[F")) {
770             ans = (float[]) a;
771         } else {
772             Object[] ia = (Object[]) a;
773             ans = new float[ia.length];
774             for (int i = 0; i < ia.length; i++) {
775                 ans[i] = ((Number) ia[i]).floatValue();
776             }
777         }
778         return ans;
779     }
780 
781     public static double[] convertToDoubleArray(Object a) {
782         double[] ans = null;
783 
784         // conservative coding
785         if (a.getClass().getName().equals("[D")) {
786             ans = (double[]) a;
787         } else {
788             Object[] ia = (Object[]) a;
789             ans = new double[ia.length];
790             for (int i = 0; i < ia.length; i++) {
791                 ans[i] = ((Number) ia[i]).doubleValue();
792             }
793         }
794         return ans;
795     }
796 */
797     
798     /*
799 
800     private static Integer[] SMALL_INTEGERS;
801     private static int INT_CACHE_OFFSET = 128, INT_CACHE_LEN = 256;
802 
803     static {
804         SMALL_INTEGERS = new Integer[INT_CACHE_LEN];
805         for (int i = 0; i < SMALL_INTEGERS.length; i++) {
806             SMALL_INTEGERS[i] = new Integer(i - INT_CACHE_OFFSET);
807         }
808     }*/
809 }