本文整理汇总了Java中com.strobel.assembler.metadata.MethodDefinition类的典型用法代码示例。如果您正苦于以下问题:Java MethodDefinition类的具体用法?Java MethodDefinition怎么用?Java MethodDefinition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MethodDefinition类属于com.strobel.assembler.metadata包,在下文中一共展示了MethodDefinition类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: visitMethodDeclaration
import com.strobel.assembler.metadata.MethodDefinition; //导入依赖的package包/类
@Override
public Void visitMethodDeclaration(MethodDeclaration node, SourceIndex index) {
MethodDefinition def = node.getUserData(Keys.METHOD_DEFINITION);
BehaviorEntry behaviorEntry = ProcyonEntryFactory.getBehaviorEntry(def);
AstNode tokenNode = node.getNameToken();
if (behaviorEntry instanceof ConstructorEntry) {
ConstructorEntry constructorEntry = (ConstructorEntry)behaviorEntry;
if (constructorEntry.isStatic()) {
// for static initializers, check elsewhere for the token node
tokenNode = node.getModifiers().firstOrNullObject();
}
}
index.addDeclaration(tokenNode, behaviorEntry);
return node.acceptVisitor(new SourceIndexBehaviorVisitor(behaviorEntry), index);
}
开发者ID:cccssw,项目名称:enigma-vk,代码行数:17,代码来源:SourceIndexClassVisitor.java
示例2: findMethodInType
import com.strobel.assembler.metadata.MethodDefinition; //导入依赖的package包/类
private MethodDefinition findMethodInType(TypeDefinition typeDef, String uniqueStr) {
String[] linkParts = uniqueStr.split("\\|");
if (linkParts.length != 5)
return null;
String methodName = linkParts[3];
String methodErasedSignature = linkParts[4];
if (methodName.trim().length() <= 0 || methodErasedSignature.trim().length() <= 0)
return null;
List<MethodDefinition> declaredMethods = typeDef.getDeclaredMethods();
if (declaredMethods == null)
return null;
boolean isFound = false;
for (MethodDefinition declaredMethod : declaredMethods) {
isFound = (declaredMethod != null && methodName.equals(declaredMethod.getName()));
isFound = (isFound && methodErasedSignature.equals(declaredMethod.getErasedSignature()));
if (isFound) {
if (declaredMethod.isSynthetic() && !settings.getShowSyntheticMembers()) {
return null;
} else {
return declaredMethod;
}
}
}
return null;
}
开发者ID:KevinPriv,项目名称:Luyten4Forge,代码行数:26,代码来源:DecompilerLinkProvider.java
示例3: visit
import com.strobel.assembler.metadata.MethodDefinition; //导入依赖的package包/类
@AstVisitor(nodes = AstNodes.EXPRESSIONS)
public void visit(Expression expr, MethodContext mc) {
if (expr.getCode() != AstCode.InvokeVirtual)
return;
MethodReference mr = (MethodReference) expr.getOperand();
String name = mr.getName();
if (!Types.isObject(mr.getDeclaringType()) || (!name.equals("wait") && !name.startsWith("notify")))
return;
TypeReference type = ValuesFlow.reduceType(expr.getArguments().get(0));
if (type == null || !type.getInternalName().startsWith("java/util/concurrent/"))
return;
TypeDefinition target = type.resolve();
if (target == null || !target.isPublic())
return;
MethodDefinition replacement = findReplacement(name, target);
if(replacement != null) {
mc.report("IncorrectConcurrentMethod", 0, expr, TARGET.create(target), Roles.REPLACEMENT_METHOD.create(replacement));
}
}
开发者ID:amaembo,项目名称:huntbugs,代码行数:20,代码来源:LockProblems.java
示例4: checkSameAsConstructor
import com.strobel.assembler.metadata.MethodDefinition; //导入依赖的package包/类
@AstVisitor(nodes = AstNodes.ROOT)
public void checkSameAsConstructor(Block root, MethodDefinition md, TypeDefinition td, MethodContext mc) {
if (md.getName().equals(td.getSimpleName()) && md.getReturnType().isVoid() && !md.isDeprecated()) {
int priority = 0;
if (root.getBody().isEmpty()) {
priority += 20;
} else if (root.getBody().size() == 1 && Nodes.isOp(root.getBody().get(0), AstCode.AThrow)) {
priority += 40;
}
if (td.getDeclaredMethods().stream().anyMatch(
m -> m.isConstructor() && m.getErasedSignature().equals(md.getErasedSignature()))) {
priority += 10;
}
mc.report("BadNameOfMethodSameAsConstructor", priority);
}
}
开发者ID:amaembo,项目名称:huntbugs,代码行数:17,代码来源:Naming.java
示例5: checkMethod
import com.strobel.assembler.metadata.MethodDefinition; //导入依赖的package包/类
@AstVisitor(nodes=AstNodes.ROOT)
public void checkMethod(Block root, MethodDefinition md, MethodStats ms, MethodContext mc) {
if(md.getReturnType().isVoid()) {
MethodData stats = ms.getStats(md);
if (stats != null && !stats.mayHaveSideEffect(true) && !stats.testAny(MethodStats.METHOD_MAY_THROW, true)) {
List<Node> body = root.getBody();
if(body.isEmpty())
return;
if(md.isConstructor() && body.size() == 1 && Nodes.isOp(body.get(0), AstCode.InvokeSpecial))
return;
int codeSize = Nodes.estimateCodeSize(root);
int priority = codeSize < 10 ? 20 : codeSize < 20 ? 10 : codeSize < 30 ? 5 : 0;
mc.report("UselessVoidMethod", priority);
}
}
}
开发者ID:amaembo,项目名称:huntbugs,代码行数:17,代码来源:UselessVoidMethod.java
示例6: visit
import com.strobel.assembler.metadata.MethodDefinition; //导入依赖的package包/类
@AstVisitor(nodes = AstNodes.EXPRESSIONS)
public boolean visit(Expression expr, NodeChain nc, MethodContext mc, MethodDefinition md) {
if (selfCall(expr, md) && (!stateChange && checkArgs(expr) || !controlTransfer && checkControlFlow(nc))) {
mc.report("InfiniteRecursion", 0, expr);
}
if (expr.getCode() == AstCode.StoreElement || expr.getCode() == AstCode.PutField
|| expr.getCode() == AstCode.PutStatic) {
stateChange = true;
}
if ((Nodes.isInvoke(expr) || expr.getCode() == AstCode.InitObject) && !Nodes.isSideEffectFree(expr)) {
stateChange = true;
}
if (expr.getCode() == AstCode.Return || expr.getCode() == AstCode.AThrow
|| expr.getCode() == AstCode.LoopContinue || expr.getCode() == AstCode.LoopOrSwitchBreak
|| expr.getCode() == AstCode.Goto) {
controlTransfer = true;
}
if (controlTransfer && stateChange)
return false;
return true;
}
开发者ID:amaembo,项目名称:huntbugs,代码行数:22,代码来源:InfiniteRecursion.java
示例7: selfCall
import com.strobel.assembler.metadata.MethodDefinition; //导入依赖的package包/类
private boolean selfCall(Expression expr, MethodDefinition md) {
if (!(expr.getOperand() instanceof MethodReference))
return false;
MethodReference mr = (MethodReference) expr.getOperand();
if (!mr.isEquivalentTo(md))
return false;
switch (expr.getCode()) {
case InvokeStatic:
return md.isStatic();
case InitObject:
case InvokeSpecial:
return md.isConstructor();
case InvokeVirtual:
case InvokeInterface:
return !md.isStatic() && Exprs.isThis(expr.getArguments().get(0));
default:
return false;
}
}
开发者ID:amaembo,项目名称:huntbugs,代码行数:20,代码来源:InfiniteRecursion.java
示例8: visit
import com.strobel.assembler.metadata.MethodDefinition; //导入依赖的package包/类
@AstVisitor(nodes = AstNodes.EXPRESSIONS)
public void visit(Expression expr, NodeChain nc, MethodContext mc, MethodDefinition md, Mutability m) {
FieldDefinition fd = getField(expr, md);
if (fd == null)
return;
Expression value = Exprs.getChild(expr, expr.getArguments().size() - 1);
ParameterDefinition pd = getParameter(value);
if (pd == null)
return;
if (!Types.isMutable(fd.getFieldType()) && !m.isKnownMutable(fd.getFieldType()))
return;
int priority = 0;
if (md.isProtected() || fd.isProtected())
priority += 10;
if (md.isVarArgs() && pd.getPosition() == md.getParameters().size() - 1)
priority += 10;
if (nc.getParent() == null && nc.getRoot().getBody().size() == 1)
priority += 15;
else if (!fd.isFinal())
priority += 3;
String type = fd.isStatic() ? "ExposeMutableStaticFieldViaParameter" : "ExposeMutableFieldViaParameter";
mc.report(type, priority, expr, Roles.FIELD_TYPE.create(fd.getFieldType()));
}
开发者ID:amaembo,项目名称:huntbugs,代码行数:24,代码来源:ExposeRepresentation.java
示例9: visit
import com.strobel.assembler.metadata.MethodDefinition; //导入依赖的package包/类
@AstVisitor(nodes=AstNodes.EXPRESSIONS)
public void visit(Expression expr, MethodContext mc) {
if(expr.getOperand() instanceof MethodReference) {
MethodReference mr = (MethodReference) expr.getOperand();
if(mr.getErasedSignature().contains("[Ljava/lang/Object;)")) {
Expression lastArg = expr.getArguments().get(expr.getArguments().size()-1);
if(lastArg.getCode() == AstCode.InitArray && lastArg.getArguments().size() == 1) {
TypeReference nested = lastArg.getArguments().get(0).getInferredType();
if(nested != null && nested.isArray() && nested.getElementType().isPrimitive()) {
int priority = 0;
if(!highPriority(mr)) {
priority = 10;
MethodDefinition md = mr.resolve();
if(md == null) {
priority = 20;
} else if(!md.isVarArgs())
return;
}
mc.report("PrimitiveArrayPassedAsVarArg", priority, lastArg, Roles.CALLED_METHOD.create(mr),
Roles.ARRAY_TYPE.create(nested));
}
}
}
}
}
开发者ID:amaembo,项目名称:huntbugs,代码行数:26,代码来源:IncorrectVarArg.java
示例10: extractCalls
import com.strobel.assembler.metadata.MethodDefinition; //导入依赖的package包/类
static void extractCalls(MethodDefinition md, Predicate<MethodReference> action) {
MethodBody body = md.getBody();
if(body == null)
return;
for(Instruction inst : body.getInstructions()) {
for(int i=0; i<inst.getOperandCount(); i++) {
Object operand = inst.getOperand(i);
if(operand instanceof MethodReference) {
if(!action.test((MethodReference)operand))
return;
}
if(operand instanceof DynamicCallSite) {
MethodHandle mh = Nodes.getMethodHandle((DynamicCallSite) operand);
if(mh != null) {
if(!action.test(mh.getMethod()))
return;
}
}
}
}
}
开发者ID:amaembo,项目名称:huntbugs,代码行数:22,代码来源:UncalledPrivateMethod.java
示例11: visit
import com.strobel.assembler.metadata.MethodDefinition; //导入依赖的package包/类
@AstVisitor(nodes = AstNodes.EXPRESSIONS)
public void visit(Expression expr, NodeChain nc, MethodContext mc, MethodDefinition md, TypeDefinition td) {
if (expr.getCode() == AstCode.Return && !expr.getArguments().isEmpty()) {
Expression child = Exprs.getChild(expr, 0);
if (child.getCode() == AstCode.AConstNull) {
MethodDefinition curMethod = nc.getLambdaMethod();
if (curMethod == null)
curMethod = md;
String warningType = curMethod.getReturnType().isArray() ? "ArrayReturnNull" : TYPE_TO_WARNING
.get(curMethod.getReturnType().getInternalName());
if (warningType != null) {
int priority = 0;
if (!td.isPublic() || md.isPrivate() || md.isPackagePrivate())
priority = 20;
else if (md.isProtected() || md != curMethod)
priority = 10;
// Method which simply contains "return null": probably stub or something
if(nc.getParent() == null && nc.isOnlyChild(expr))
priority += 10;
mc.report(warningType, priority, expr.getArguments().get(0), RETURN_TYPE.create(md
.getReturnType()));
}
}
}
}
开发者ID:amaembo,项目名称:huntbugs,代码行数:26,代码来源:ReturnNull.java
示例12: annotate
import com.strobel.assembler.metadata.MethodDefinition; //导入依赖的package包/类
public static List<Expression> annotate(Context ctx, MethodDefinition md, ClassFields cf, CFG cfg) {
ctx.incStat("ValuesFlow");
Collection<Expression> origFrame = Inf.SOURCE.build(cf, cfg);
if(origFrame == null) {
ctx.incStat("Inf.SOURCE.Incomplete/ValuesFlow");
}
if(!Inf.CONST.build(cfg)) {
ctx.incStat("Inf.CONST.Incomplete/ValuesFlow");
}
if(!Inf.ETYPE.build(cfg)) {
ctx.incStat("Inf.ETYPE.Incomplete/ValuesFlow");
}
if(!Inf.NULL.build(cfg)) {
ctx.incStat("Inf.NULL.Incomplete/ValuesFlow");
}
cfg.forBodies((smd, smethod) -> Inf.PURITY.annotate(smethod, new FrameContext(smd, cf)));
cfg.forBodies((smd, smethod) -> Inf.BACKLINK.annotate(smethod));
return origFrame == null ? null : new ArrayList<>(origFrame);
}
开发者ID:amaembo,项目名称:huntbugs,代码行数:20,代码来源:ValuesFlow.java
示例13: CFG
import com.strobel.assembler.metadata.MethodDefinition; //导入依赖的package包/类
private CFG(MethodDefinition md, BasicBlock closure, Block methodBody) {
this.md = md;
this.body = methodBody;
this.closure = closure;
if (methodBody.getBody().isEmpty()) {
entry = exit;
hasUnreachable = false;
dupExpr = Collections.emptyList();
} else {
entry = new BasicBlock();
buildBlock(entry, exit, new OuterJumpContext(), methodBody);
verify();
inlineBooleans();
fixBlocks();
dupExpr = computeDupBlocks(findDuplicates(methodBody));
hasUnreachable = blocks.stream().anyMatch(bb -> !bb.reached);
}
this.forwardTill = computeForwardTill();
}
开发者ID:amaembo,项目名称:huntbugs,代码行数:20,代码来源:CFG.java
示例14: link
import com.strobel.assembler.metadata.MethodDefinition; //导入依赖的package包/类
void link(MethodDefinition src, FieldReference fr, boolean isStatic, boolean write, boolean hadNull) {
if(fieldRecords == null)
return;
int prevStatus = fieldRecords.getOrDefault(fr.getName(), 0);
int curStatus = prevStatus;
if(src.getDeclaringType().isEquivalentTo(fr.getDeclaringType())) {
if(write && (src.isConstructor() && !isStatic || src.isTypeInitializer() && isStatic)) {
curStatus |= WRITE_CONSTRUCTOR;
} else {
curStatus |= write ? WRITE_CLASS : READ_CLASS;
}
} else if(src.getDeclaringType().getPackageName().equals(fr.getDeclaringType().getPackageName())) {
curStatus |= write ? WRITE_PACKAGE : READ_PACKAGE;
} else {
curStatus |= write ? WRITE_OUTSIDE : READ_OUTSIDE;
}
if(write && !hadNull) {
curStatus |= WRITE_NONNULL;
}
if(prevStatus != curStatus) {
fieldRecords.put(fr.getName(), curStatus);
}
}
开发者ID:amaembo,项目名称:huntbugs,代码行数:24,代码来源:FieldStats.java
示例15: getMethodData
import com.strobel.assembler.metadata.MethodDefinition; //导入依赖的package包/类
private MethodData getMethodData(MethodDefinition md) {
MemberInfo mi = new MemberInfo(md);
MethodData mdata = data.get(mi);
if (mdata != null)
return mdata;
if (md.isAbstract()) {
MethodDefinition superMd = Methods.findSuperMethod(md);
if (superMd != null)
mdata = getMethodData(superMd);
}
if (mdata == null) {
mdata = new MethodData();
}
data.put(mi, mdata);
return mdata;
}
开发者ID:amaembo,项目名称:huntbugs,代码行数:17,代码来源:MethodStats.java
示例16: sortMethods
import com.strobel.assembler.metadata.MethodDefinition; //导入依赖的package包/类
private void sortMethods(List<MethodDefinition> declMethods) {
declMethods.sort(Comparator.comparingInt(md ->
md.isTypeInitializer() ? 0 :
md.isConstructor() ? 1 : 2));
int start = -1, end = declMethods.size();
for (int i = 0; i < end; i++) {
if(start == -1) {
if(declMethods.get(i).isConstructor())
start = i;
} else
if(!declMethods.get(i).isConstructor()) {
end = i;
}
}
if(start >= 0) {
sortConstructors(declMethods.subList(start, end));
}
}
开发者ID:amaembo,项目名称:huntbugs,代码行数:19,代码来源:DetectorRegistry.java
示例17: visitMethodDeclaration
import com.strobel.assembler.metadata.MethodDefinition; //导入依赖的package包/类
@Override
public Void visitMethodDeclaration(MethodDeclaration node, SourceIndex index) {
MethodDefinition def = node.getUserData(Keys.METHOD_DEFINITION);
BehaviorEntry behaviorEntry = ProcyonEntryFactory.getBehaviorEntry(def);
AstNode tokenNode = node.getNameToken();
if (behaviorEntry instanceof ConstructorEntry) {
ConstructorEntry constructorEntry = (ConstructorEntry) behaviorEntry;
if (constructorEntry.isStatic()) {
// for static initializers, check elsewhere for the token node
tokenNode = node.getModifiers().firstOrNullObject();
}
}
index.addDeclaration(tokenNode, behaviorEntry);
return node.acceptVisitor(new SourceIndexBehaviorVisitor(behaviorEntry), index);
}
开发者ID:OpenModLoader,项目名称:Enigma,代码行数:17,代码来源:SourceIndexClassVisitor.java
示例18: visitMethodDeclaration
import com.strobel.assembler.metadata.MethodDefinition; //导入依赖的package包/类
@Override
public Void visitMethodDeclaration(MethodDeclaration node, SourceIndex index)
{
MethodDefinition def = node.getUserData(Keys.METHOD_DEFINITION);
BehaviorEntry behaviorEntry = ProcyonEntryFactory.getBehaviorEntry(def);
AstNode tokenNode = node.getNameToken();
if(behaviorEntry instanceof ConstructorEntry)
{
ConstructorEntry constructorEntry = (ConstructorEntry)behaviorEntry;
if(constructorEntry.isStatic())
// for static initializers, check elsewhere for the token node
tokenNode = node.getModifiers().firstOrNullObject();
}
index.addDeclaration(tokenNode, behaviorEntry);
return node.acceptVisitor(
new SourceIndexBehaviorVisitor(behaviorEntry), index);
}
开发者ID:Wurst-Imperium,项目名称:Wurst-Enigma,代码行数:19,代码来源:SourceIndexClassVisitor.java
示例19: visitParameterDeclaration
import com.strobel.assembler.metadata.MethodDefinition; //导入依赖的package包/类
@Override
public Void visitParameterDeclaration(ParameterDeclaration node,
SourceIndex index)
{
ParameterDefinition def = node.getUserData(Keys.PARAMETER_DEFINITION);
if(def.getMethod() instanceof MethodDefinition)
{
MethodDefinition methodDef = (MethodDefinition)def.getMethod();
BehaviorEntry behaviorEntry =
ProcyonEntryFactory.getBehaviorEntry(methodDef);
ArgumentEntry argumentEntry =
new ArgumentEntry(behaviorEntry, def.getPosition(),
node.getName());
index.addDeclaration(node.getNameToken(), argumentEntry);
}
return recurse(node, index);
}
开发者ID:Wurst-Imperium,项目名称:Wurst-Enigma,代码行数:19,代码来源:SourceIndexBehaviorVisitor.java
示例20: getMethodEntry
import com.strobel.assembler.metadata.MethodDefinition; //导入依赖的package包/类
public static MethodEntry getMethodEntry(MethodDefinition def) {
return new MethodEntry(
new ClassEntry(def.getDeclaringType().getInternalName()),
def.getName(),
new Signature(def.getErasedSignature())
);
}
开发者ID:cccssw,项目名称:enigma-vk,代码行数:8,代码来源:ProcyonEntryFactory.java
注:本文中的com.strobel.assembler.metadata.MethodDefinition类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论