< prev index next >

test/hotspot/jtreg/runtime/Nestmates/privateMethods/TestMethodHandles.java

Print this page

        

*** 47,86 **** public TestMethodHandles() {} // Methods that will access private methods of nestmates void access_priv(TestMethodHandles o) throws Throwable { ! MethodHandle mh = ! lookup().findSpecial(o.getClass(), "priv_invoke", M_T, this.getClass()); mh.invoke(o); mh.invokeExact(o); checkBadInvoke(mh, new StaticNested()); // wrong nestmate checkBadInvoke(mh, mh); // completely wrong type } void access_priv(InnerNested o) throws Throwable { ! MethodHandle mh = ! lookup().findSpecial(o.getClass(), "priv_invoke", M_T, this.getClass()); mh.invoke(o); mh.invokeExact(o); checkBadInvoke(mh, this); // wrong nestmate checkBadInvoke(mh, mh); // completely wrong type } void access_priv(StaticNested o) throws Throwable { ! MethodHandle mh = ! lookup().findSpecial(o.getClass(), "priv_invoke", M_T, this.getClass()); mh.invoke(o); mh.invokeExact(o); checkBadInvoke(mh, this); // wrong nestmate checkBadInvoke(mh, mh); // completely wrong type } void access_priv(StaticIface o) throws Throwable { ! MethodHandle mh = ! lookup().findSpecial(StaticIface.class, "priv_invoke", M_T, this.getClass()); mh.invoke(o); mh.invokeExact(o); checkBadInvoke(mh, this); // wrong nestmate checkBadInvoke(mh, mh); // completely wrong type } // The various nestmates static interface StaticIface { --- 47,103 ---- public TestMethodHandles() {} // Methods that will access private methods of nestmates void access_priv(TestMethodHandles o) throws Throwable { ! MethodHandle mh = lookup().findVirtual(o.getClass(), "priv_invoke", M_T); ! mh.invoke(o); ! mh.invokeExact(o); ! checkBadInvoke(mh, new StaticNested()); // wrong nestmate ! checkBadInvoke(mh, mh); // completely wrong type ! // findSpecial also works when this and o are the same class ! mh = lookup().findSpecial(o.getClass(), "priv_invoke", M_T, this.getClass()); mh.invoke(o); mh.invokeExact(o); checkBadInvoke(mh, new StaticNested()); // wrong nestmate checkBadInvoke(mh, mh); // completely wrong type } void access_priv(InnerNested o) throws Throwable { ! MethodHandle mh = lookup().findVirtual(o.getClass(), "priv_invoke", M_T); mh.invoke(o); mh.invokeExact(o); checkBadInvoke(mh, this); // wrong nestmate checkBadInvoke(mh, mh); // completely wrong type + try { + mh = lookup().findSpecial(o.getClass(), "priv_invoke", M_T, this.getClass()); + throw new Error("findSpecial() succeeded unexpectedly"); + } + catch (IllegalAccessException expected) {} } void access_priv(StaticNested o) throws Throwable { ! MethodHandle mh = lookup().findVirtual(o.getClass(), "priv_invoke", M_T); mh.invoke(o); mh.invokeExact(o); checkBadInvoke(mh, this); // wrong nestmate checkBadInvoke(mh, mh); // completely wrong type + try { + mh = lookup().findSpecial(o.getClass(), "priv_invoke", M_T, this.getClass()); + throw new Error("findSpecial() succeeded unexpectedly"); + } + catch (IllegalAccessException expected) {} } void access_priv(StaticIface o) throws Throwable { ! MethodHandle mh = lookup().findVirtual(StaticIface.class, "priv_invoke", M_T); mh.invoke(o); mh.invokeExact(o); checkBadInvoke(mh, this); // wrong nestmate checkBadInvoke(mh, mh); // completely wrong type + try { + mh = lookup().findSpecial(StaticIface.class, "priv_invoke", M_T, this.getClass()); + throw new Error("findSpecial() succeeded unexpectedly"); + } + catch (IllegalAccessException expected) {} } // The various nestmates static interface StaticIface {
*** 91,125 **** // Methods that will access private methods of nestmates default void access_priv(TestMethodHandles o) throws Throwable { MethodHandle mh = ! lookup().findSpecial(o.getClass(), "priv_invoke", M_T, StaticIface.class); mh.invoke(o); mh.invokeExact(o); checkBadInvoke(mh, this); // wrong nestmate checkBadInvoke(mh, mh); // completely wrong type } default void access_priv(InnerNested o) throws Throwable { ! MethodHandle mh = ! lookup().findSpecial(o.getClass(), "priv_invoke", M_T, StaticIface.class); mh.invoke(o); mh.invokeExact(o); checkBadInvoke(mh, this); // wrong nestmate checkBadInvoke(mh, mh); // completely wrong type } default void access_priv(StaticNested o) throws Throwable { ! MethodHandle mh = ! lookup().findSpecial(o.getClass(), "priv_invoke", M_T, StaticIface.class); mh.invoke(o); mh.invokeExact(o); checkBadInvoke(mh, this); // wrong nestmate checkBadInvoke(mh, mh); // completely wrong type } default void access_priv(StaticIface o) throws Throwable { ! MethodHandle mh = ! lookup().findSpecial(StaticIface.class, "priv_invoke", M_T, StaticIface.class); mh.invoke(o); mh.invokeExact(o); checkBadInvoke(mh, new StaticNested()); // wrong nestmate checkBadInvoke(mh, mh); // completely wrong type } --- 108,160 ---- // Methods that will access private methods of nestmates default void access_priv(TestMethodHandles o) throws Throwable { MethodHandle mh = ! lookup().findVirtual(o.getClass(), "priv_invoke", M_T); mh.invoke(o); mh.invokeExact(o); checkBadInvoke(mh, this); // wrong nestmate checkBadInvoke(mh, mh); // completely wrong type + try { + mh = lookup().findSpecial(o.getClass(), "priv_invoke", M_T, this.getClass()); + throw new Error("findSpecial() succeeded unexpectedly"); + } + catch (IllegalAccessException expected) {} } default void access_priv(InnerNested o) throws Throwable { ! MethodHandle mh = lookup().findVirtual(o.getClass(), "priv_invoke", M_T); mh.invoke(o); mh.invokeExact(o); checkBadInvoke(mh, this); // wrong nestmate checkBadInvoke(mh, mh); // completely wrong type + try { + mh = lookup().findSpecial(o.getClass(), "priv_invoke", M_T, this.getClass()); + throw new Error("findSpecial() succeeded unexpectedly"); + } + catch (IllegalAccessException expected) {} } default void access_priv(StaticNested o) throws Throwable { ! MethodHandle mh = lookup().findVirtual(o.getClass(), "priv_invoke", M_T); mh.invoke(o); mh.invokeExact(o); checkBadInvoke(mh, this); // wrong nestmate checkBadInvoke(mh, mh); // completely wrong type + try { + mh = lookup().findSpecial(o.getClass(), "priv_invoke", M_T, this.getClass()); + throw new Error("findSpecial() succeeded unexpectedly"); + } + catch (IllegalAccessException expected) {} } default void access_priv(StaticIface o) throws Throwable { ! MethodHandle mh = lookup().findVirtual(StaticIface.class, "priv_invoke", M_T); ! mh.invoke(o); ! mh.invokeExact(o); ! checkBadInvoke(mh, new StaticNested()); // wrong nestmate ! checkBadInvoke(mh, mh); // completely wrong type ! // findSpecial also works when this and o are the same interface ! mh = lookup().findSpecial(StaticIface.class, "priv_invoke", M_T, StaticIface.class); mh.invoke(o); mh.invokeExact(o); checkBadInvoke(mh, new StaticNested()); // wrong nestmate checkBadInvoke(mh, mh); // completely wrong type }
*** 135,174 **** public StaticNested() {} // Methods that will access private methods of nestmates void access_priv(TestMethodHandles o) throws Throwable { ! MethodHandle mh = ! lookup().findSpecial(o.getClass(), "priv_invoke", M_T, this.getClass()); mh.invoke(o); mh.invokeExact(o); checkBadInvoke(mh, this); // wrong nestmate checkBadInvoke(mh, mh); // completely wrong type } void access_priv(InnerNested o) throws Throwable { ! MethodHandle mh = ! lookup().findSpecial(o.getClass(), "priv_invoke", M_T, this.getClass()); mh.invoke(o); mh.invokeExact(o); checkBadInvoke(mh, this); // wrong nestmate checkBadInvoke(mh, mh); // completely wrong type } void access_priv(StaticNested o) throws Throwable { ! MethodHandle mh = ! lookup().findSpecial(o.getClass(), "priv_invoke", M_T, this.getClass()); mh.invoke(o); mh.invokeExact(o); checkBadInvoke(mh, new TestMethodHandles()); // wrong nestmate checkBadInvoke(mh, mh); // completely wrong type } void access_priv(StaticIface o) throws Throwable { ! MethodHandle mh = ! lookup().findSpecial(StaticIface.class, "priv_invoke", M_T, this.getClass()); mh.invoke(o); mh.invokeExact(o); checkBadInvoke(mh, this); // wrong nestmate checkBadInvoke(mh, mh); // completely wrong type } } class InnerNested { --- 170,226 ---- public StaticNested() {} // Methods that will access private methods of nestmates void access_priv(TestMethodHandles o) throws Throwable { ! MethodHandle mh = lookup().findVirtual(o.getClass(), "priv_invoke", M_T); mh.invoke(o); mh.invokeExact(o); checkBadInvoke(mh, this); // wrong nestmate checkBadInvoke(mh, mh); // completely wrong type + try { + mh = lookup().findSpecial(o.getClass(), "priv_invoke", M_T, this.getClass()); + throw new Error("findSpecial() succeeded unexpectedly"); + } + catch (IllegalAccessException expected) {} } void access_priv(InnerNested o) throws Throwable { ! MethodHandle mh = lookup().findVirtual(o.getClass(), "priv_invoke", M_T); mh.invoke(o); mh.invokeExact(o); checkBadInvoke(mh, this); // wrong nestmate checkBadInvoke(mh, mh); // completely wrong type + try { + mh = lookup().findSpecial(o.getClass(), "priv_invoke", M_T, this.getClass()); + throw new Error("findSpecial() succeeded unexpectedly"); + } + catch (IllegalAccessException expected) {} } void access_priv(StaticNested o) throws Throwable { ! MethodHandle mh = lookup().findVirtual(o.getClass(), "priv_invoke", M_T); ! mh.invoke(o); ! mh.invokeExact(o); ! checkBadInvoke(mh, new TestMethodHandles()); // wrong nestmate ! checkBadInvoke(mh, mh); // completely wrong type ! // findSpecial also works when this and o are the same class ! mh = lookup().findSpecial(o.getClass(), "priv_invoke", M_T, this.getClass()); mh.invoke(o); mh.invokeExact(o); checkBadInvoke(mh, new TestMethodHandles()); // wrong nestmate checkBadInvoke(mh, mh); // completely wrong type } void access_priv(StaticIface o) throws Throwable { ! MethodHandle mh = lookup().findVirtual(StaticIface.class, "priv_invoke", M_T); mh.invoke(o); mh.invokeExact(o); checkBadInvoke(mh, this); // wrong nestmate checkBadInvoke(mh, mh); // completely wrong type + try { + mh = lookup().findSpecial(StaticIface.class, "priv_invoke", M_T, this.getClass()); + throw new Error("findSpecial() succeeded unexpectedly"); + } + catch (IllegalAccessException expected) {} } } class InnerNested {
*** 178,217 **** // public constructor so we aren't relying on private access public InnerNested() {} void access_priv(TestMethodHandles o) throws Throwable { ! MethodHandle mh = ! lookup().findSpecial(o.getClass(), "priv_invoke", M_T, this.getClass()); mh.invoke(o); mh.invokeExact(o); checkBadInvoke(mh, this); // wrong nestmate checkBadInvoke(mh, mh); // completely wrong type } void access_priv(InnerNested o) throws Throwable { ! MethodHandle mh = ! lookup().findSpecial(o.getClass(), "priv_invoke", M_T, this.getClass()); mh.invoke(o); mh.invokeExact(o); checkBadInvoke(mh, new StaticNested()); // wrong nestmate checkBadInvoke(mh, mh); // completely wrong type } void access_priv(StaticNested o) throws Throwable { ! MethodHandle mh = ! lookup().findSpecial(o.getClass(), "priv_invoke", M_T, this.getClass()); mh.invoke(o); mh.invokeExact(o); checkBadInvoke(mh, this); // wrong nestmate checkBadInvoke(mh, mh); // completely wrong type } void access_priv(StaticIface o) throws Throwable { ! MethodHandle mh = ! lookup().findSpecial(StaticIface.class, "priv_invoke", M_T, this.getClass()); mh.invoke(o); mh.invokeExact(o); checkBadInvoke(mh, this); // wrong nestmate checkBadInvoke(mh, mh); // completely wrong type } } static void checkBadInvoke(MethodHandle mh, Object o) throws Throwable { try { --- 230,286 ---- // public constructor so we aren't relying on private access public InnerNested() {} void access_priv(TestMethodHandles o) throws Throwable { ! MethodHandle mh = lookup().findVirtual(o.getClass(), "priv_invoke", M_T); mh.invoke(o); mh.invokeExact(o); checkBadInvoke(mh, this); // wrong nestmate checkBadInvoke(mh, mh); // completely wrong type + try { + mh = lookup().findSpecial(o.getClass(), "priv_invoke", M_T, this.getClass()); + throw new Error("findSpecial() succeeded unexpectedly"); + } + catch (IllegalAccessException expected) {} } void access_priv(InnerNested o) throws Throwable { ! MethodHandle mh = lookup().findVirtual(o.getClass(), "priv_invoke", M_T); ! mh.invoke(o); ! mh.invokeExact(o); ! checkBadInvoke(mh, new StaticNested()); // wrong nestmate ! checkBadInvoke(mh, mh); // completely wrong type ! // findSpecial also works when this and o are the same class ! mh = lookup().findSpecial(o.getClass(), "priv_invoke", M_T, this.getClass()); mh.invoke(o); mh.invokeExact(o); checkBadInvoke(mh, new StaticNested()); // wrong nestmate checkBadInvoke(mh, mh); // completely wrong type } void access_priv(StaticNested o) throws Throwable { ! MethodHandle mh = lookup().findVirtual(o.getClass(), "priv_invoke", M_T); mh.invoke(o); mh.invokeExact(o); checkBadInvoke(mh, this); // wrong nestmate checkBadInvoke(mh, mh); // completely wrong type + try { + mh = lookup().findSpecial(o.getClass(), "priv_invoke", M_T, this.getClass()); + throw new Error("findSpecial() succeeded unexpectedly"); + } + catch (IllegalAccessException expected) {} } void access_priv(StaticIface o) throws Throwable { ! MethodHandle mh = lookup().findVirtual(StaticIface.class, "priv_invoke", M_T); mh.invoke(o); mh.invokeExact(o); checkBadInvoke(mh, this); // wrong nestmate checkBadInvoke(mh, mh); // completely wrong type + try { + mh = lookup().findSpecial(StaticIface.class, "priv_invoke", M_T, this.getClass()); + throw new Error("findSpecial() succeeded unexpectedly"); + } + catch (IllegalAccessException expected) {} } } static void checkBadInvoke(MethodHandle mh, Object o) throws Throwable { try {
< prev index next >