/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;
abstract class Foo {
protected int x;
protected Foo(int x) {
this.x = x;
}
public abstract void bar();
}
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
{
Foo foo = new Foo(123) { // <<== This works because of "compiler magic"
public void bar() {
System.
out.
println("hi " + x
); }
};
foo.bar();
Class<?> clazz = foo.getClass();
for (Constructor<?> c : clazz.getDeclaredConstructors()){
System.
out.
println("protected? "+Modifier.
isProtected(c.
getModifiers())); // System.out.println("default? "+Modifier.isProtected(c.getModifiers()));
}
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CmltcG9ydCBqYXZhLmxhbmcucmVmbGVjdC5Db25zdHJ1Y3RvcjsKaW1wb3J0IGphdmEubGFuZy5yZWZsZWN0Lk1vZGlmaWVyOwoKCmFic3RyYWN0IGNsYXNzIEZvbyB7Cglwcm90ZWN0ZWQgaW50IHg7CgoJcHJvdGVjdGVkIEZvbyhpbnQgeCkgewoJCXRoaXMueCA9IHg7Cgl9CgoJcHVibGljIGFic3RyYWN0IHZvaWQgYmFyKCk7Cn0KLyogTmFtZSBvZiB0aGUgY2xhc3MgaGFzIHRvIGJlICJNYWluIiBvbmx5IGlmIHRoZSBjbGFzcyBpcyBwdWJsaWMuICovCmNsYXNzIElkZW9uZQp7CglwdWJsaWMgc3RhdGljIHZvaWQgbWFpbiAoU3RyaW5nW10gYXJncykgdGhyb3dzIGphdmEubGFuZy5FeGNlcHRpb24KCXsKCQlGb28gZm9vID0gbmV3IEZvbygxMjMpIHsgLy8gPDw9PSBUaGlzIHdvcmtzIGJlY2F1c2Ugb2YgImNvbXBpbGVyIG1hZ2ljIgoJCQlwdWJsaWMgdm9p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