...
Wiki Markup |
---|
According to the Java Language Specification \[[JLS 05|AA. Java References#JLS 05]\] section 4.3.2 ""The Class {{Object}}"": ""The method {{getClass}} returns the {{Class}} object that represents the class of the object"". The first ten methods shown below can be used on a {{Class}} object. |
...
Code Block | ||
---|---|---|
| ||
public class ExceptionExample { public static void untrustedCode() { Date now = new Date(); Class<?>Class<?> dateClass = now.getClass(); createInstance(dateClass); } public static void createInstance(Class<?>Class<?> dateClass) { try { // Create another Date object using the Date Class Object o = dateClass.newInstance(); if (o instanceof Date) { Date d = (Date)o; System.out.println(""The time is: "" + d.toString()); } } catch (InstantiationException ie) { System.out.println(ie.toString()); } catch (IllegalAccessException iae) { System.out.println(iae.toString()); } } } |
...
SEC01-J. Provide sensitive mutable classes with unmodifiable wrappers 02. Platform Security (SEC) SEC03-J. Do not use APIs that perform access checks against the immediate caller