Get the appropriate default value per JLS 4.5.4
( Class type )
| 921 | Get the appropriate default value per JLS 4.5.4 |
| 922 | */ |
| 923 | public static Primitive getDefaultValue( Class type ) |
| 924 | { |
| 925 | if ( type == null || !type.isPrimitive() ) |
| 926 | return Primitive.NULL; |
| 927 | if ( type == Boolean.TYPE ) |
| 928 | return Primitive.FALSE; |
| 929 | |
| 930 | // non boolean primitive, get appropriate flavor of zero |
| 931 | try { |
| 932 | return new Primitive((int)0).castToType( type, Types.CAST ); |
| 933 | } catch ( UtilEvalError e ) { |
| 934 | throw new InterpreterError( "bad cast" ); |
| 935 | } |
| 936 | } |
| 937 | |
| 938 | /** |
| 939 | Get the corresponding java.lang wrapper class for the primitive TYPE |
no test coverage detected