//package com.nowjava;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
/*
from 时 代 J a v a 公 众 号 - nowjava.com
*/
import java.lang.reflect.Modifier;
public class Main {
public static void main(String[] argv) throws Exception {
Class clazz = String.class;
System.out.println(isPrivate(clazz));
}
/**
* Checks if constructor of class i private and adds line coverage
*/
public static boolean isPrivate(Class<?> clazz)
throws NoSuchMethodException, SecurityException,
InstantiationException, IllegalAccessException,
IllegalArgumentException, InvocationTargetException {
Constructor<?> constructor = clazz
.getDeclaredConstructor((Class<?>[]) null);
// the modifiers int can tell us metadata about the constructor/** 时 代 J a v a 公 众 号 - N o w J a v a . c o m 提供 **/
int constructorModifiers = constructor.getModifiers();
// constructor is private so we first have to make it accessible
/**代码未完, 请加载全部代码(NowJava.com).**/
本文系作者在时代Java发表,未经许可,不得转载。如有侵权,请联系nowjava@qq.com删除。