protected boolean containsAnnotation(InputStream is, long size) throws IOException { boolean result = false; // check if it contains top level annotations... ReadableByteChannel channel = null; try { channel = Channels.newChannel(is); if (channel!=null) { result = classFile.containsAnnotation(channel, size); } return result; } finally { if (channel != null) { channel.close(); } } } }
protected boolean containsAnnotation(InputStream is, long size) throws IOException { boolean result = false; // check if it contains top level annotations... ReadableByteChannel channel = null; try { channel = Channels.newChannel(is); if (channel!=null) { result = classFile.containsAnnotation(channel, size); } return result; } finally { if (channel != null) { channel.close(); } } } }
/** * Read the input channel and initialize instance data * structure. */public boolean containsAnnotation(ReadableByteChannel in, long size) throws IOException { header.clear(); if (size!=-1 && size>header.capacity()) { // time to expand... header = ByteBuffer.allocate((int) size); } long read = (long) in.read(header); if (size!=-1 && read!=size) { return false; } header.rewind(); return containsAnnotation(header); }
/** * Read the input channel and initialize instance data * structure. */public boolean containsAnnotation(ReadableByteChannel in, long size) throws IOException { header.clear(); if (size!=-1 && size>header.capacity()) { // time to expand... header = ByteBuffer.allocate((int) size); } long read = (long) in.read(header); if (size!=-1 && read!=size) { return false; } header.rewind(); return containsAnnotation(header); }
private boolean containsAnnotation(final ByteBuffer headerBuffer) throws IOException { /** * this is the .class file layout * ClassFile { u4 magic; u2 minor_version; u2 major_version; u2 constant_pool_count; cp_info constant_pool[constant_pool_count-1]; u2 access_flags; u2 this_class; u2 super_class; u2 interfaces_count; u2 interfaces[interfaces_count]; u2 fields_count; field_info fields[fields_count]; u2 methods_count; method_info methods[methods_count]; u2 attributes_count; attribute_info attributes[attributes_count]; } **/ if (headerBuffer.getInt()!=magic) { return false; }
private boolean containsAnnotation(final ByteBuffer headerBuffer) throws IOException { /** * this is the .class file layout * ClassFile { u4 magic; u2 minor_version; u2 major_version; u2 constant_pool_count; cp_info constant_pool[constant_pool_count-1]; u2 access_flags; u2 this_class; u2 super_class; u2 interfaces_count; u2 interfaces[interfaces_count]; u2 fields_count; field_info fields[fields_count]; u2 methods_count; method_info methods[methods_count]; u2 attributes_count; attribute_info attributes[attributes_count]; } **/ if (headerBuffer.getInt()!=magic) { return false; }
baos.write(buffer, 0, bytesRead); if (classFile.containsAnnotation(baos.toByteArray())) { addEntry(je);