Java ?????????????ó???
???????????? ???????[ 2016/11/10 11:38:35 ] ??????????????????? JAVA
????4.??class?????????
????//??????? Class???????newInstance()????????
????Object obj = class1.newInstance();
????//??????? ??????????Constructor???????????Constructor?????newInstance()????????
????Constructor<?> constructor = class1.getDeclaredConstructor(new Class[]{String.class});//????????????????
????obj = constructor.newInstance(new Object[]{"lcj"});
????5.????????ú???
try {
// ?????μ??????newInstance()????
Object obj = class1.newInstance();
//?ж??????????Person??????
boolean isInstanceOf = obj instanceof Person;
//????????????÷????????Method????
Method method = class1.getDeclaredMethod("setAge"?? new Class[]{int.class});
//?????????????????????
method.invoke(obj?? 28);
method = class1.getDeclaredMethod("getAge");
Object result = method.invoke(obj?? new Class[]{});
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
????6.)????????????????????
?????????????????
????//People??
????public class People<T> {}
????//Person????People??
????public class Person<T> extends People<String> implements PersonInterface<Integer> {}
????//PersonInterface???
????public interface PersonInterface<T> {}
???????????????
Person<String> person = new Person<>();
//??????? ???????getClass????
Class<?> class1 = person.getClass();
Type genericSuperclass = class1.getGenericSuperclass();//???class???????????? Type
Type[] interfaceTypes = class1.getGenericInterfaces();//???class????????н???Type????
getComponentType(genericSuperclass);
getComponentType(interfaceTypes[0]);
getComponentType???????
private Class<?> getComponentType(Type type) {
Class<?> componentType = null;
if (type instanceof ParameterizedType) {
//getActualTypeArguments()???????????????????????? Type ????????顣
Type[] actualTypeArguments = ((ParameterizedType) type).getActualTypeArguments();
if (actualTypeArguments != null && actualTypeArguments.length > 0) {
componentType = (Class<?>) actualTypeArguments[0];
}
} else if (type instanceof GenericArrayType) {
// ????????????????????????????????????????????
componentType = (Class<?>) ((GenericArrayType) type).getGenericComponentType();
} else {
componentType = (Class<?>) type;
}
return componentType;
}
????7.)??????????????????
???????????????Method???????????
try {
//????????????÷????????Method????
Method method = class1.getDeclaredMethod("jumpToGoodsDetail"?? new Class[]{String.class?? String.class});
Annotation[] annotations1 = method.getAnnotations();//??????е??????????
Annotation annotation1 = method.getAnnotation(RouterUri.class);//??????????????
TypeVariable[] typeVariables1 = method.getTypeParameters();
Annotation[][] parameterAnnotationsArray = method.getParameterAnnotations();//??????в?????????
Class<?>[] parameterTypes = method.getParameterTypes();//??????в???class????
Type[] genericParameterTypes = method.getGenericParameterTypes();//??????в?????type????
Class<?> returnType = method.getReturnType();//????????????????
int modifiers = method.getModifiers();//???????????????
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
??????????????ó?????
????· ??????? ?????練????
????· ???????????? ????Retrofit
????· ????????????????? ????EventBus 2.x
????· ??????????? ????Gson
?????????????????
???????
????????????????ж????????????????????÷???
???????
????????????????????????????н??????????jvm????????飬?????????java??????????
???????
????Java????????????????????????к????????????????Щ?????????????÷???????????????????£????к??δ?????????????????????
?????????????У?????и??????ζ?????????????????????ζ???????????????壬????????????
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
Java???????????Щ???????????????Java????????????????Java?б???Map????????Java Web???????????????Java??????????????д?????Java????????7???????????????????????(java .net ?????)???Java??????????Python??????Java webdriver??λ????????′????е?????Java??д??????????????????Java???????????????JavaScript????????????Java?????????????????? Java???????10??????????????Java?м????????????????java???????ü???????????м???????????????????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????