---------------------------------:Reflection:---------------------
compiler use reflection api for check declration syntax error and all.........., server,framwork, testing tool,debugging
JVM design from reflection because it use.. o arg constructor availabe or not etc
https://www.youtube.com/watch?v=mGsDVjbvzRU
how many way get the Class class object;
1- Class c=Class.forName("A");
2- A a=new A();
Class c=a.getClass():
3-Class c=A.class;
getField((public)even to super class ) vs getDeclaredField((private)on corresponding class)
in case of class.forNane("").newIntance(); inside newIntance method constructor fetching logic h
public Object newInstance()
throws InstantiationException, IllegalAccessException
{
if(System.getSecurityManager() != null)
{
checkMemberAccess(0, ClassLoader.getCallerClassLoader());
}
return newInstance0();
}private Object newInstance0()
throws InstantiationException, IllegalAccessException
{
Constructor constructor;
if(cachedConstructor == null)
{
if(this == java/lang/Class)
{
throw new IllegalAccessException("Can not call newInstance() on the Class for java.lang.Class");
}
try
{
Class aclass[] = new Class[0];
final Constructor c = getConstructor0(aclass, 1);
AccessController.doPrivileged(new PrivilegedAction() {
final Constructor val$c;
final Class this$0;
public Object run()
{
c.setAccessible(true);
return null;
} {
this$0 = Class.this;
c = constructor;
super();
}
});
cachedConstructor = c;
}
catch(NoSuchMethodException nosuchmethodexception)
{
throw new InstantiationException(getName());
}
}
constructor = cachedConstructor;
int i = constructor.getModifiers();
if(!Reflection.quickCheckMemberAccess(this, i))
{
Class class1 = Reflection.getCallerClass(3);
if(newInstanceCallerCache != class1)
{
Reflection.ensureMemberAccess(class1, this, null, i);
newInstanceCallerCache = class1;
}
}
return constructor.newInstance((Object[])null);
InvocationTargetException invocationtargetexception;
invocationtargetexception;
Unsafe.getUnsafe().throwException(invocationtargetexception.getTargetException());
return null;
}
----------------------------------
one pacakage is java.lang.reflect package is there
Class is used to get metadata of class
compiler use reflection api for check declration syntax error and all.........., server,framwork, testing tool,debugging
JVM design from reflection because it use.. o arg constructor availabe or not etc
https://www.youtube.com/watch?v=mGsDVjbvzRU
how many way get the Class class object;
1- Class c=Class.forName("A");
2- A a=new A();
Class c=a.getClass():
3-Class c=A.class;
getField((public)even to super class ) vs getDeclaredField((private)on corresponding class)
in case of class.forNane("").newIntance(); inside newIntance method constructor fetching logic h
public Object newInstance()
throws InstantiationException, IllegalAccessException
{
if(System.getSecurityManager() != null)
{
checkMemberAccess(0, ClassLoader.getCallerClassLoader());
}
return newInstance0();
}private Object newInstance0()
throws InstantiationException, IllegalAccessException
{
Constructor constructor;
if(cachedConstructor == null)
{
if(this == java/lang/Class)
{
throw new IllegalAccessException("Can not call newInstance() on the Class for java.lang.Class");
}
try
{
Class aclass[] = new Class[0];
final Constructor c = getConstructor0(aclass, 1);
AccessController.doPrivileged(new PrivilegedAction() {
final Constructor val$c;
final Class this$0;
public Object run()
{
c.setAccessible(true);
return null;
} {
this$0 = Class.this;
c = constructor;
super();
}
});
cachedConstructor = c;
}
catch(NoSuchMethodException nosuchmethodexception)
{
throw new InstantiationException(getName());
}
}
constructor = cachedConstructor;
int i = constructor.getModifiers();
if(!Reflection.quickCheckMemberAccess(this, i))
{
Class class1 = Reflection.getCallerClass(3);
if(newInstanceCallerCache != class1)
{
Reflection.ensureMemberAccess(class1, this, null, i);
newInstanceCallerCache = class1;
}
}
return constructor.newInstance((Object[])null);
InvocationTargetException invocationtargetexception;
invocationtargetexception;
Unsafe.getUnsafe().throwException(invocationtargetexception.getTargetException());
return null;
}
----------------------------------
one pacakage is java.lang.reflect package is there
Class is used to get metadata of class
No comments:
Post a Comment