Search Java Code Snippets


  Help us in improving the repository. Add new snippets through 'Submit Code Snippet ' link.





Java - Code Samples

 Sample 1. Code Sample / Example / Snippet of org.apache.bcel.classfile.Field

        public void visitGETSTATIC(final GETSTATIC o) {

try {

final String field_name = o.getFieldName(cpg);

final JavaClass jc = Repository.lookupClass(getObjectType(o).getClassName());

final Field[] fields = jc.getFields();

Field f = null;

for (final Field field : fields) {

if (field.getName().equals(field_name)) {

f = field;

break;

}

}

if (f == null) {

throw new AssertionViolatedException("Field '" + field_name + "' not found in " + jc.getClassName());

}



if (! (f.isStatic())) {

constraintViolated(o, "Referenced field '"+f+"' is not static which it should be.");

}

} catch (final ClassNotFoundException e) {

throw new AssertionViolatedException("Missing class: " + e, e);

}

}




   Like      Feedback      org.apache.bcel.classfile.Field



Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner