MCPcopy Create free account
hub / github.com/beanshell/beanshell / getDefaultValue

Method getDefaultValue

src/bsh/Primitive.java:923–936  ·  view source on GitHub ↗

Get the appropriate default value per JLS 4.5.4

( Class type )

Source from the content-addressed store, hash-verified

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

Callers 1

setValueMethod · 0.95

Calls 2

castToTypeMethod · 0.80
isPrimitiveMethod · 0.45

Tested by

no test coverage detected