dimanche 25 octobre 2020

What are Differents between this kind of reflection?

String s =  "something";
Class<?> c1 = s.getclass();
Class<?> c2 = Class.forname("java.lang.String");
Class<?> c3 = java.lang.String.class;

what is different between c1, c2, c3?

If I load a class with different class-loader , there will be different class of that class in runtime.

Classloader cl1 = new URLClassloader(...) ;
Classloader cl2 = new URLClassloader(...) ;

Class<?> x1 = Class.forname("java.lang.String", cl1);
Class<?> x2 = Class.forname("java.lang.String", cl2);

x1 and x2 are not the same why?





Aucun commentaire:

Enregistrer un commentaire