本文整理汇总了Java中org.apache.bcel.classfile.Field.getSignature方法的典型用法代码示例。如果您正苦于以下问题:Java Field.getSignature方法的具体用法?Java Field.getSignature怎么用?Java Field.getSignature使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.bcel.classfile.Field
的用法示例。
在下文中一共展示了Field.getSignature方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visit
import org.apache.bcel.classfile.Field; //导入方法依赖的package包/类
@Override
public void visit(Field field) {
if (!field.isStatic())
return;
String signature = field.getSignature();
if (signature.startsWith("Ljava/util/") && !signature.equals("Ljava/util/regex/Pattern;")
&& !signature.equals("Ljava/util/logging/Logger;") && !signature.equals("Ljava/util/BitSet;")
&& !signature.equals("Ljava/util/ResourceBundle;")
&& !signature.equals("Ljava/util/Comparator;")
&& getXField().getAnnotation(ConstantAnnotation) == null) {
boolean flagged = analysisContextContained(getXClass());
bugReporter.reportBug(new BugInstance(this, "TESTING", flagged ? NORMAL_PRIORITY : LOW_PRIORITY).addClass(this).addField(this).addType(signature));
}
}
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:17,代码来源:CheckAnalysisContextContainedAnnotation.java
示例2: run
import org.apache.bcel.classfile.Field; //导入方法依赖的package包/类
@Override
public void run() {
String args[] = EntryPoint.getArgs();
String inputJarFileName = args[0];
String inputMappingsFileName = args[1];
String outputSrgMappingsFileName = args[2];
try (
PrintWriter outputSrgMappingWriter = new PrintWriter(outputSrgMappingsFileName);
JarFile inputJarFile = new JarFile(inputJarFileName);
Reader inputMappingsReader = new InputStreamReader(new FileInputStream(new File(inputMappingsFileName)), StandardCharsets.UTF_8.toString())
) {
Map<String, Map<String, List<String>>> fieldMappings = new Gson().fromJson(inputMappingsReader, FieldFinderHelpers.MAPPINGS_JSON_FORMAT_TYPE_TOKEN);
for (JarEntry jarEntry : new EnumerationIterator<>(inputJarFile.entries())) {
if (jarEntry.isDirectory() || !jarEntry.getName().endsWith(".class")) {
continue;
}
String fullClassName = Utils.stripClassEnding(jarEntry.getName());
Map<String, List<String>> localFieldMappingsByType = fieldMappings.get(fullClassName);
if (localFieldMappingsByType != null) {
JavaClass clazz = new ClassParser(inputJarFile.getInputStream(jarEntry), fullClassName).parse();
for (Field field : clazz.getFields()) {
if (FieldFinderHelpers.shouldIgnoreField(clazz, field)) {
continue;
}
String signature = field.getGenericSignature() != null ? field.getGenericSignature() : field.getSignature();
List<String> names = localFieldMappingsByType.get(signature);
if (names != null && !names.isEmpty()) {
outputSrgMappingWriter.println(MappingUtils.createSRG(fullClassName, field.getName(), names.remove(0)));
}
}
}
}
} catch (Throwable t) {
t.printStackTrace();
}
}
示例3: visit
import org.apache.bcel.classfile.Field; //导入方法依赖的package包/类
@Override
public void visit(JavaClass obj) {
if (Subtypes2.instanceOf(obj, "java.util.Comparator") && !ClassName.isAnonymous(getClassName())
&& !Subtypes2.instanceOf(obj, "java.io.Serializable")) {
int priority = NORMAL_PRIORITY;
if (obj.isInterface() || obj.isAbstract())
return;
double easilySerializable = 1.0;
for (Field f : obj.getFields()) {
try {
if (f.getName().startsWith("this$"))
return;
String signature = f.getSignature();
char firstChar = signature.charAt(0);
if (firstChar == 'L' || firstChar == '[')
easilySerializable *= DeepSubtypeAnalysis.isDeepSerializable(signature);
} catch (ClassNotFoundException e) {
easilySerializable = 0.0;
break;
}
}
if (easilySerializable < 0.9)
priority = LOW_PRIORITY;
bugReporter.reportBug(new BugInstance(this, "SE_COMPARATOR_SHOULD_BE_SERIALIZABLE", priority).addClass(this));
}
}
示例4: visit
import org.apache.bcel.classfile.Field; //导入方法依赖的package包/类
@Override
public void visit(Field obj) {
super.visit(obj);
XField f = XFactory.createXField(this);
data.allMyFields.add(f);
String signature = obj.getSignature();
if (!getFieldName().equals("serialVersionUID")) {
data.myFields.add(f);
if (obj.getName().equals("_jspx_dependants"))
data.containerFields.add(f);
}
if (isSeleniumWebElement(signature))
data.containerFields.add(f);
}
示例5: getSignatureOfOuterClass
import org.apache.bcel.classfile.Field; //导入方法依赖的package包/类
private static @CheckForNull
String getSignatureOfOuterClass(JavaClass obj) {
for (Field f : obj.getFields())
if (f.getName().startsWith("this$"))
return f.getSignature();
return null;
}
示例6: run
import org.apache.bcel.classfile.Field; //导入方法依赖的package包/类
@Override
public void run() {
String args[] = EntryPoint.getArgs();
String inputJarFileName = args[0];
String classPathStart = args[1];
int minFieldNameLength = Integer.parseInt(args[2]);
String outputMappingsFileName = args[3];
try (
PrintWriter outputMappingsWriter = new PrintWriter(outputMappingsFileName, StandardCharsets.UTF_8.toString());
JarFile inputJarFile = new JarFile(inputJarFileName)
) {
Map<String, Map<String, List<String>>> fieldMappings = new HashMap<>();
for (JarEntry jarEntry : new EnumerationIterator<>(inputJarFile.entries())) {
if (jarEntry.isDirectory() || !jarEntry.getName().endsWith(".class") || !jarEntry.getName().startsWith(classPathStart)) {
continue;
}
String fullClassName = Utils.stripClassEnding(jarEntry.getName());
JavaClass clazz = new ClassParser(inputJarFile.getInputStream(jarEntry), fullClassName).parse();
Map<String, List<String>> localFieldMappingsByType = new HashMap<>();
for (Field field : clazz.getFields()) {
if (FieldFinderHelpers.shouldIgnoreField(clazz, field)) {
continue;
}
if (field.getName().length() < minFieldNameLength) {
continue;
}
String signature = field.getGenericSignature() != null ? field.getGenericSignature() : field.getSignature();
localFieldMappingsByType.compute(signature, (ftype, names) -> {
if (names == null) {
names = new ArrayList<>();
}
return names;
})
.add(field.getName());
}
if (!localFieldMappingsByType.isEmpty()) {
fieldMappings.put(fullClassName, localFieldMappingsByType);
}
}
new GsonBuilder()
.setPrettyPrinting()
.create()
.toJson(
fieldMappings,
FieldFinderHelpers.MAPPINGS_JSON_FORMAT_TYPE_TOKEN,
outputMappingsWriter
);
} catch (Throwable t) {
t.printStackTrace();
}
}
示例7: makeFieldName
import org.apache.bcel.classfile.Field; //导入方法依赖的package包/类
protected String makeFieldName(final String className, final Field field) {
return className + '.' + field.getName() + '.' + field.getSignature();
}
示例8: visit
import org.apache.bcel.classfile.Field; //导入方法依赖的package包/类
@Override
public void visit(JavaClass obj) {
classFields.clear();
Field[] fields = obj.getFields();
String fieldName;
for (Field field : fields)
if (!field.isStatic() && !field.isPrivate()) {
fieldName = field.getName();
classFields.put(fieldName, field);
}
// Walk up the super class chain, looking for name collisions
XClass c = getXClass();
while (true) {
ClassDescriptor s = c.getSuperclassDescriptor();
if (s == null || s.getClassName().equals("java/lang/Object"))
break;
try {
c = Global.getAnalysisCache().getClassAnalysis(XClass.class, s);
} catch (CheckedAnalysisException e) {
break;
}
XClass superClass = c;
for (XField fld : c.getXFields()) {
if (!fld.isStatic() && (fld.isPublic() || fld.isProtected())) {
fieldName = fld.getName();
if (fieldName.length() == 1)
continue;
if (fieldName.equals("serialVersionUID"))
continue;
String superClassName = s.getClassName();
if (superClassName.startsWith("java/io")
&& (superClassName.endsWith("InputStream") && fieldName.equals("in") || superClassName
.endsWith("OutputStream") && fieldName.equals("out")))
continue;
if (classFields.containsKey(fieldName)) {
Field maskingField = classFields.get(fieldName);
String mClassName = getDottedClassName();
FieldAnnotation fa = new FieldAnnotation(mClassName, maskingField.getName(), maskingField.getSignature(),
maskingField.isStatic());
int priority = NORMAL_PRIORITY;
if (maskingField.isStatic() || maskingField.isFinal())
priority++;
else if (fld.getSignature().charAt(0) == 'L' && !fld.getSignature().startsWith("Ljava/lang/")
|| fld.getSignature().charAt(0) == '[')
priority--;
if (!fld.getSignature().equals(maskingField.getSignature()))
priority += 2;
else if (fld.getAccessFlags() != maskingField.getAccessFlags())
priority++;
if (fld.isSynthetic() || fld.getName().indexOf('$') >= 0)
priority++;
FieldAnnotation maskedFieldAnnotation = FieldAnnotation.fromFieldDescriptor(fld.getFieldDescriptor());
BugInstance bug = new BugInstance(this, "MF_CLASS_MASKS_FIELD", priority).addClass(this).addField(fa)
.describe("FIELD_MASKING").addField(maskedFieldAnnotation).describe("FIELD_MASKED");
rememberedBugs.add(new RememberedBug(bug, fa, maskedFieldAnnotation));
}
}
}
}
super.visit(obj);
}
示例9: fromBCELField
import org.apache.bcel.classfile.Field; //导入方法依赖的package包/类
/**
* Factory method. Construct from class name and BCEL Field object.
*
* @param className the name of the class which defines the field
* @param field the BCEL Field object
*/
public static FieldAnnotation fromBCELField(String className, Field field) {
return new FieldAnnotation(className, field.getName(), field.getSignature(), field.isStatic());
}
示例10: parseField
import org.apache.bcel.classfile.Field; //导入方法依赖的package包/类
/**
* @param obj
* the field to parse
* @return a descriptor for the field
*/
protected FieldDescriptor parseField(Field obj) {
return new FieldDescriptor(slashedClassName, obj.getName(), obj.getSignature(), obj.isStatic());
}
示例11: fromBCELField
import org.apache.bcel.classfile.Field; //导入方法依赖的package包/类
/**
* Factory method. Construct from class name and BCEL Field object.
*
* @param className
* the name of the class which defines the field
* @param field
* the BCEL Field object
* @return the FieldAnnotation
*/
public static FieldAnnotation fromBCELField(@DottedClassName String className, Field field) {
return new FieldAnnotation(className, field.getName(), field.getSignature(), field.isStatic());
}