mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 07:27:52 +01:00
add forName(String,ClassLoader) and cast(Object)
This commit is contained in:
parent
9c7b69b2a7
commit
0dfb7c4a34
@ -191,6 +191,17 @@ class ReplacementForClass<T> {
|
|||||||
throw new ClassNotFoundException( className ); // TODO
|
throw new ClassNotFoundException( className ); // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replacement of the Java method forName(String)
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
* the fully qualified name of the desired class.
|
||||||
|
* @return the {@code Class} object for the class with the specified name.
|
||||||
|
*/
|
||||||
|
public static Class<?> forName(String name, boolean initialize, ClassLoader loader) throws ClassNotFoundException {
|
||||||
|
return forName( name );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replacement of the Java method newInstance()
|
* Replacement of the Java method newInstance()
|
||||||
*
|
*
|
||||||
@ -470,4 +481,17 @@ class ReplacementForClass<T> {
|
|||||||
*/
|
*/
|
||||||
@WasmTextCode( "unreachable" ) // TODO
|
@WasmTextCode( "unreachable" ) // TODO
|
||||||
native Map<String, T> enumConstantDirectory();
|
native Map<String, T> enumConstantDirectory();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replacement of the Java method cast(Object)
|
||||||
|
*
|
||||||
|
* @param obj the object to be cast
|
||||||
|
* @return the object after casting, or null if obj is null
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public T cast(Object obj) {
|
||||||
|
if (obj != null && !isInstance(obj))
|
||||||
|
throw new ClassCastException("Cannot cast " + obj.getClass().getName() + " to " + getName());
|
||||||
|
return (T) obj;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user