本文整理汇总了Java中sun.tools.java.MemberDefinition.getExceptions方法的典型用法代码示例。如果您正苦于以下问题:Java MemberDefinition.getExceptions方法的具体用法?Java MemberDefinition.getExceptions怎么用?Java MemberDefinition.getExceptions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sun.tools.java.MemberDefinition
的用法示例。
在下文中一共展示了MemberDefinition.getExceptions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: computeMethodHash
import sun.tools.java.MemberDefinition; //导入方法依赖的package包/类
/**
* Create a new Method object corresponding to the given
* method definition.
*/
/*
* Temporarily comment out the private modifier until
* the VM allows outer class to access inner class's
* private constructor
*/
/* private */ Method(MemberDefinition memberDef) {
this.memberDef = memberDef;
exceptions = memberDef.getExceptions(env);
methodHash = computeMethodHash();
}
示例2: getMethodExceptions
import sun.tools.java.MemberDefinition; //导入方法依赖的package包/类
protected ValueType[] getMethodExceptions (MemberDefinition member,
boolean quiet,
ContextStack stack) throws Exception {
boolean result = true;
stack.setNewContextCode(ContextStack.METHOD_EXCEPTION);
ClassDeclaration[] except = member.getExceptions(env);
ValueType[] exceptions = new ValueType[except.length];
try {
for (int i = 0; i < except.length; i++) {
ClassDefinition theClass = except[i].getClassDefinition(env);
try {
ValueType type = ValueType.forValue(theClass,stack,false);
if (type != null) {
exceptions[i] = type;
} else {
result = false;
}
} catch (ClassCastException e1) {
failedConstraint(22,quiet,stack,getQualifiedName());
throw new CompilerError("Method: exception " + theClass.getName() + " not a class type!");
} catch (NullPointerException e2) {
failedConstraint(23,quiet,stack,getQualifiedName());
throw new CompilerError("Method: caught null pointer exception");
}
}
} catch (ClassNotFound e) {
classNotFound(quiet,stack,e);
result = false;
}
if (!result) {
throw new Exception();
}
// Remove any duplicates (javac seems to allow them, but rmic will
// generate bad ties)...
int dupCount = 0;
for (int i = 0; i < exceptions.length; i++) {
for (int j = 0; j < exceptions.length; j++) {
if (i != j && exceptions[i] != null && exceptions[i] == exceptions[j]) {
exceptions[j] = null;
dupCount++;
}
}
}
if (dupCount > 0) {
int offset = 0;
ValueType[] temp = new ValueType[exceptions.length - dupCount];
for (int i = 0; i < exceptions.length; i++) {
if (exceptions[i] != null) {
temp[offset++] = exceptions[i];
}
}
exceptions = temp;
}
return exceptions;
}