}
@Test
public void protectedFieldAccessors() throws Exception {
TypeRegistry tr = getTypeRegistry("prot.SubOne");
ReloadableType rtype = tr.addType("prot.SubOne", loadBytesForClass("prot.SubOne"));
Object instance = rtype.getClazz().newInstance();
runOnInstance(rtype.getClazz(), instance, "setPublicField", 3);
assertEquals(3, runOnInstance(rtype.getClazz(), instance, "getPublicField").returnValue);
runOnInstance(rtype.getClazz(), instance, "setProtectedField", 3);
assertEquals(3, runOnInstance(rtype.getClazz(), instance, "getProtectedField").returnValue);
runOnInstance(rtype.getClazz(), instance, "setProtectedShortField", (short) 33);
assertEquals((short) 33, runOnInstance(rtype.getClazz(), instance, "getProtectedShortField").returnValue);
runOnInstance(rtype.getClazz(), instance, "setProtectedByteField", (byte) 133);
assertEquals((byte) 133, runOnInstance(rtype.getClazz(), instance, "getProtectedByteField").returnValue);
runOnInstance(rtype.getClazz(), instance, "setProtectedCharField", (char) 12);
assertEquals((char) 12, runOnInstance(rtype.getClazz(), instance, "getProtectedCharField").returnValue);
runOnInstance(rtype.getClazz(), instance, "setProtectedBooleanField", true);
assertEquals(true, runOnInstance(rtype.getClazz(), instance, "isProtectedBooleanField").returnValue);
runOnInstance(rtype.getClazz(), instance, "setProtectedDoubleField", 3.1d);
assertEquals(3.1d, runOnInstance(rtype.getClazz(), instance, "getProtectedDoubleField").returnValue);
runOnInstance(rtype.getClazz(), instance, "setProtectedFloatField", 8f);
assertEquals(8f, runOnInstance(rtype.getClazz(), instance, "getProtectedFloatField").returnValue);
runOnInstance(rtype.getClazz(), instance, "setProtectedLongField", 888L);
assertEquals(888L, runOnInstance(rtype.getClazz(), instance, "getProtectedLongField").returnValue);
runOnInstance(rtype.getClazz(), instance, "setProtectedArrayOfInts", new int[] { 1, 2, 3 });
assertEquals("[1,2,3]", toString(runOnInstance(rtype.getClazz(), instance, "getProtectedArrayOfInts").returnValue));
runOnInstance(rtype.getClazz(), instance, "setProtectedArrayOfStrings", (Object) new String[] { "a", "b", "c" });
assertEquals("[a,b,c]", toString(runOnInstance(rtype.getClazz(), instance, "getProtectedArrayOfStrings").returnValue));
runOnInstance(rtype.getClazz(), instance, "setProtectedArrayOfArrayOfLongs", (Object) new long[][] { new long[] { 3L },
new long[] { 4L, 45L }, new long[] { 7L } });
assertEquals("[[3],[4,45],[7]]",
toString(runOnInstance(rtype.getClazz(), instance, "getProtectedArrayOfArrayOfLongs").returnValue));
runOnInstance(rtype.getClazz(), instance, "setProtectedStaticField", 3);
assertEquals(3, runOnInstance(rtype.getClazz(), instance, "getProtectedStaticField").returnValue);
rtype.loadNewVersion(rtype.bytesInitial);
runOnInstance(rtype.getClazz(), instance, "setPublicField", 4);
assertEquals(4, runOnInstance(rtype.getClazz(), instance, "getPublicField").returnValue);
runOnInstance(rtype.getClazz(), instance, "setProtectedField", 3);
assertEquals(3, runOnInstance(rtype.getClazz(), instance, "getProtectedField").returnValue);
runOnInstance(rtype.getClazz(), instance, "setProtectedShortField", (short) 33);
assertEquals((short) 33, runOnInstance(rtype.getClazz(), instance, "getProtectedShortField").returnValue);
runOnInstance(rtype.getClazz(), instance, "setProtectedByteField", (byte) 133);
assertEquals((byte) 133, runOnInstance(rtype.getClazz(), instance, "getProtectedByteField").returnValue);
runOnInstance(rtype.getClazz(), instance, "setProtectedCharField", (char) 12);
assertEquals((char) 12, runOnInstance(rtype.getClazz(), instance, "getProtectedCharField").returnValue);
runOnInstance(rtype.getClazz(), instance, "setProtectedBooleanField", true);
assertEquals(true, runOnInstance(rtype.getClazz(), instance, "isProtectedBooleanField").returnValue);
runOnInstance(rtype.getClazz(), instance, "setProtectedDoubleField", 3.1d);
assertEquals(3.1d, runOnInstance(rtype.getClazz(), instance, "getProtectedDoubleField").returnValue);
runOnInstance(rtype.getClazz(), instance, "setProtectedFloatField", 8f);
assertEquals(8f, runOnInstance(rtype.getClazz(), instance, "getProtectedFloatField").returnValue);
runOnInstance(rtype.getClazz(), instance, "setProtectedLongField", 888L);
assertEquals(888L, runOnInstance(rtype.getClazz(), instance, "getProtectedLongField").returnValue);
runOnInstance(rtype.getClazz(), instance, "setProtectedArrayOfInts", new int[] { 1, 2, 3 });
assertEquals("[1,2,3]", toString(runOnInstance(rtype.getClazz(), instance, "getProtectedArrayOfInts").returnValue));
runOnInstance(rtype.getClazz(), instance, "setProtectedArrayOfStrings", (Object) new String[] { "a", "b", "c" });
assertEquals("[a,b,c]", toString(runOnInstance(rtype.getClazz(), instance, "getProtectedArrayOfStrings").returnValue));
runOnInstance(rtype.getClazz(), instance, "setProtectedArrayOfArrayOfLongs", (Object) new long[][] { new long[] { 3L },
new long[] { 4L, 45L }, new long[] { 7L } });
assertEquals("[[3],[4,45],[7]]",
toString(runOnInstance(rtype.getClazz(), instance, "getProtectedArrayOfArrayOfLongs").returnValue));
runOnInstance(rtype.getClazz(), instance, "setProtectedStaticField", 3);
assertEquals(3, runOnInstance(rtype.getClazz(), instance, "getProtectedStaticField").returnValue);
}