class Main { void foo() throws ReflectiveOperationException { bar().getField(""); } Class bar() throws ClassNotFoundException { return (Class) Class.forName("Test"); } } class Test { public int num; public void method(){} }