diff --git a/src/de/inetsoftware/jwebassembly/module/nativecode/ReplacementForClass.java b/src/de/inetsoftware/jwebassembly/module/nativecode/ReplacementForClass.java index 7a40a57..2f6291e 100644 --- a/src/de/inetsoftware/jwebassembly/module/nativecode/ReplacementForClass.java +++ b/src/de/inetsoftware/jwebassembly/module/nativecode/ReplacementForClass.java @@ -191,6 +191,17 @@ class ReplacementForClass { 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() * @@ -470,4 +481,17 @@ class ReplacementForClass { */ @WasmTextCode( "unreachable" ) // TODO native Map 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; + } }