List of usage examples for org.objectweb.asm Opcodes ACC_PUBLIC
int ACC_PUBLIC
To view the source code for org.objectweb.asm Opcodes ACC_PUBLIC.
Click Source Link
From source file:de.zib.sfs.instrument.FileChannelImplAdapter.java
License:BSD License
private boolean isReadMethod(int access, String name, String desc, String signature, String[] exceptions) { return access == Opcodes.ACC_PUBLIC && "read".equals(name) && (Type.getMethodDescriptor(Type.INT_TYPE, Type.getType(ByteBuffer.class)).equals(desc) || Type.getMethodDescriptor(Type.LONG_TYPE, Type.getType(ByteBuffer[].class), Type.INT_TYPE, Type.INT_TYPE).equals(desc) || Type.getMethodDescriptor(Type.INT_TYPE, Type.getType(ByteBuffer.class), Type.LONG_TYPE) .equals(desc)) && null == signature && exceptions != null && exceptions.length == 1 && Type.getInternalName(IOException.class).equals(exceptions[0]) && !skipReads(); }
From source file:de.zib.sfs.instrument.FileChannelImplAdapter.java
License:BSD License
private boolean isWriteMethod(int access, String name, String desc, String signature, String[] exceptions) { return access == Opcodes.ACC_PUBLIC && "write".equals(name) && (Type.getMethodDescriptor(Type.INT_TYPE, Type.getType(ByteBuffer.class)).equals(desc) || Type.getMethodDescriptor(Type.LONG_TYPE, Type.getType(ByteBuffer[].class), Type.INT_TYPE, Type.INT_TYPE).equals(desc) || Type.getMethodDescriptor(Type.INT_TYPE, Type.getType(ByteBuffer.class), Type.LONG_TYPE) .equals(desc)) && null == signature && exceptions != null && exceptions.length == 1 && Type.getInternalName(IOException.class).equals(exceptions[0]) && !skipWrites(); }
From source file:de.zib.sfs.instrument.FileChannelImplAdapter.java
License:BSD License
private boolean isTransferToMethod(int access, String name, String desc, String signature, String[] exceptions) {/*from ww w . j a va 2s .co m*/ return access == Opcodes.ACC_PUBLIC && "transferTo".equals(name) && Type.getMethodDescriptor(Type.LONG_TYPE, Type.LONG_TYPE, Type.LONG_TYPE, Type.getType(WritableByteChannel.class)).equals(desc) && null == signature && exceptions != null && exceptions.length == 1 && Type.getInternalName(IOException.class).equals(exceptions[0]) && !skipReads(); }
From source file:de.zib.sfs.instrument.FileChannelImplAdapter.java
License:BSD License
private boolean isTransferFromMethod(int access, String name, String desc, String signature, String[] exceptions) {/*w ww. java2 s. co m*/ return access == Opcodes.ACC_PUBLIC && "transferFrom".equals(name) && Type.getMethodDescriptor(Type.LONG_TYPE, Type.getType(ReadableByteChannel.class), Type.LONG_TYPE, Type.LONG_TYPE).equals(desc) && null == signature && exceptions != null && exceptions.length == 1 && Type.getInternalName(IOException.class).equals(exceptions[0]) && !skipWrites(); }
From source file:de.zib.sfs.instrument.FileChannelImplAdapter.java
License:BSD License
private static boolean isMapMethod(int access, String name, String desc, String signature, String[] exceptions) {//from ww w. ja v a 2s . co m return access == Opcodes.ACC_PUBLIC && "map".equals(name) && Type.getMethodDescriptor(Type.getType(MappedByteBuffer.class), Type.getType(MapMode.class), Type.LONG_TYPE, Type.LONG_TYPE).equals(desc) && null == signature && exceptions != null && exceptions.length == 1 && Type.getInternalName(IOException.class).equals(exceptions[0]); }
From source file:de.zib.sfs.instrument.FileInputStreamAdapter.java
License:BSD License
@Override protected void appendWrappedMethods(ClassVisitor visitor) { wrapMethod(Opcodes.ACC_PRIVATE, "open", Type.VOID_TYPE, new Type[] { Type.getType(String.class) }, null, new String[] { Type.getInternalName(FileNotFoundException.class) }, "openCallback", Type.getType(String.class), new ParameterResultPasser(1)); // for all read methods pass the read result to the callback ReturnResultPasser resultPasser = new ReturnResultPasser(); if (!skipReads()) { wrapMethod(Opcodes.ACC_PUBLIC, "read", Type.INT_TYPE, null, null, new String[] { Type.getInternalName(IOException.class) }, "readCallback", Type.INT_TYPE, resultPasser);//w w w . j av a 2 s . c o m wrapMethod(Opcodes.ACC_PUBLIC, "read", Type.INT_TYPE, new Type[] { Type.getType(byte[].class) }, null, new String[] { Type.getInternalName(IOException.class) }, "readBytesCallback", Type.INT_TYPE, resultPasser); wrapMethod(Opcodes.ACC_PUBLIC, "read", Type.INT_TYPE, new Type[] { Type.getType(byte[].class), Type.INT_TYPE, Type.INT_TYPE }, null, new String[] { Type.getInternalName(IOException.class) }, "readBytesCallback", Type.INT_TYPE, resultPasser); } }
From source file:de.zib.sfs.instrument.FileInputStreamAdapter.java
License:BSD License
private boolean isReadMethod(int access, String name, String desc, String signature, String[] exceptions) { return access == Opcodes.ACC_PUBLIC && "read".equals(name) && (Type.getMethodDescriptor(Type.INT_TYPE).equals(desc) || Type.getMethodDescriptor(Type.INT_TYPE, Type.getType(byte[].class)).equals(desc) || Type.getMethodDescriptor(Type.INT_TYPE, Type.getType(byte[].class), Type.INT_TYPE, Type.INT_TYPE).equals(desc)) && null == signature && exceptions != null && exceptions.length == 1 && Type.getInternalName(IOException.class).equals(exceptions[0]) && !skipReads(); }
From source file:de.zib.sfs.instrument.FileOutputStreamAdapter.java
License:BSD License
@Override protected void appendWrappedMethods(ClassVisitor visitor) { ResultPasser resultDiscarder = new DiscardResultPasser(); wrapMethod(Opcodes.ACC_PRIVATE, "open", Type.VOID_TYPE, new Type[] { Type.getType(String.class), Type.BOOLEAN_TYPE }, null, new String[] { Type.getInternalName(FileNotFoundException.class) }, "openCallback", Type.getType(String.class), new ParameterResultPasser(1)); if (!skipWrites()) { // 1 byte write, no result needed wrapMethod(Opcodes.ACC_PUBLIC, "write", Type.VOID_TYPE, new Type[] { Type.INT_TYPE }, null, new String[] { Type.getInternalName(IOException.class) }, "writeCallback", null, resultDiscarder);/*from ww w . ja v a 2s. c o m*/ // have the byte array put on top of the stack, then pass its length // to the callback wrapMethod(Opcodes.ACC_PUBLIC, "write", Type.VOID_TYPE, new Type[] { Type.getType(byte[].class) }, null, new String[] { Type.getInternalName(IOException.class) }, "writeBytesCallback", Type.INT_TYPE, new ParameterResultPasser(1) { @Override public void passResult(MethodVisitor mv) { mv.visitInsn(Opcodes.ARRAYLENGTH); } }); // have the len parameter put on top of the stack wrapMethod(Opcodes.ACC_PUBLIC, "write", Type.VOID_TYPE, new Type[] { Type.getType(byte[].class), Type.INT_TYPE, Type.INT_TYPE }, null, new String[] { Type.getInternalName(IOException.class) }, "writeBytesCallback", Type.INT_TYPE, new ParameterResultPasser(3)); } }
From source file:de.zib.sfs.instrument.FileOutputStreamAdapter.java
License:BSD License
private boolean isWriteMethod(int access, String name, String desc, String signature, String[] exceptions) { return access == Opcodes.ACC_PUBLIC && "write".equals(name) && (Type.getMethodDescriptor(Type.VOID_TYPE, Type.INT_TYPE).equals(desc) || Type.getMethodDescriptor(Type.VOID_TYPE, Type.getType(byte[].class)).equals(desc) || Type.getMethodDescriptor(Type.VOID_TYPE, Type.getType(byte[].class), Type.INT_TYPE, Type.INT_TYPE).equals(desc)) && null == signature && exceptions != null && exceptions.length == 1 && Type.getInternalName(IOException.class).equals(exceptions[0]) && !skipWrites(); }
From source file:de.zib.sfs.instrument.MappedByteBufferAdapter.java
License:BSD License
@Override protected void appendWrappedMethods(ClassVisitor visitor) { // public void setFromFileChannel(boolean fromFileChannel) { MethodVisitor setFromFileChannelMV = visitor.visitMethod(Opcodes.ACC_PUBLIC, "setFromFileChannel", Type.getMethodDescriptor(Type.VOID_TYPE, Type.BOOLEAN_TYPE), null, null); setFromFileChannelMV.visitCode();/*ww w . ja v a 2s.c o m*/ // this.fromFileChannel = fromFileChannel; setFromFileChannelMV.visitVarInsn(Opcodes.ALOAD, 0); setFromFileChannelMV.visitVarInsn(Opcodes.ILOAD, 1); setFromFileChannelMV.visitFieldInsn(Opcodes.PUTFIELD, Type.getInternalName(MappedByteBuffer.class), "fromFileChannel", Type.getDescriptor(Boolean.TYPE)); // } setFromFileChannelMV.visitInsn(Opcodes.RETURN); setFromFileChannelMV.visitMaxs(0, 0); setFromFileChannelMV.visitEnd(); // public boolean isFromFileChannel() { MethodVisitor isFromFileChannelMV = visitor.visitMethod(Opcodes.ACC_PUBLIC, "isFromFileChannel", Type.getMethodDescriptor(Type.BOOLEAN_TYPE), null, null); isFromFileChannelMV.visitCode(); // return fromFileChannel; // } isFromFileChannelMV.visitVarInsn(Opcodes.ALOAD, 0); isFromFileChannelMV.visitFieldInsn(Opcodes.GETFIELD, Type.getInternalName(MappedByteBuffer.class), "fromFileChannel", Type.getDescriptor(Boolean.TYPE)); isFromFileChannelMV.visitInsn(Opcodes.IRETURN); isFromFileChannelMV.visitMaxs(0, 0); isFromFileChannelMV.visitEnd(); // public void setFileDescriptor(FileDescriptor fileDescriptor) { MethodVisitor settFileDescriptorMV = visitor.visitMethod(Opcodes.ACC_PUBLIC, "setFileDescriptor", Type.getMethodDescriptor(Type.VOID_TYPE, Type.getType(FileDescriptor.class)), null, null); settFileDescriptorMV.visitCode(); // this.fileDescriptor = fileDescriptor; settFileDescriptorMV.visitVarInsn(Opcodes.ALOAD, 0); settFileDescriptorMV.visitVarInsn(Opcodes.ALOAD, 1); settFileDescriptorMV.visitFieldInsn(Opcodes.PUTFIELD, Type.getInternalName(MappedByteBuffer.class), "fileDescriptor", Type.getDescriptor(FileDescriptor.class)); // } settFileDescriptorMV.visitInsn(Opcodes.RETURN); settFileDescriptorMV.visitMaxs(0, 0); settFileDescriptorMV.visitEnd(); // public FileDescriptor getFileDescriptor() { MethodVisitor getFileDescriptorMV = visitor.visitMethod(Opcodes.ACC_PUBLIC, "getFileDescriptor", Type.getMethodDescriptor(Type.getType(FileDescriptor.class)), null, null); getFileDescriptorMV.visitCode(); // return getFileDescriptorImpl(); // } getFileDescriptorMV.visitVarInsn(Opcodes.ALOAD, 0); getFileDescriptorMV.visitMethodInsn(Opcodes.INVOKESPECIAL, this.instrumentedTypeInternalName, "getFileDescriptorImpl", Type.getMethodDescriptor(Type.getType(FileDescriptor.class)), false); getFileDescriptorMV.visitInsn(Opcodes.ARETURN); getFileDescriptorMV.visitMaxs(0, 0); getFileDescriptorMV.visitEnd(); // protected FileDescriptor getFileDescriptorImpl() { MethodVisitor getFileDescriptorImplMV = visitor.visitMethod(Opcodes.ACC_PROTECTED, "getFileDescriptorImpl", Type.getMethodDescriptor(Type.getType(FileDescriptor.class)), null, null); getFileDescriptorImplMV.visitCode(); // return fileDescriptor; // } getFileDescriptorImplMV.visitVarInsn(Opcodes.ALOAD, 0); getFileDescriptorImplMV.visitFieldInsn(Opcodes.GETFIELD, Type.getInternalName(MappedByteBuffer.class), "fileDescriptor", Type.getDescriptor(FileDescriptor.class)); getFileDescriptorImplMV.visitInsn(Opcodes.ARETURN); getFileDescriptorImplMV.visitMaxs(0, 0); getFileDescriptorImplMV.visitEnd(); visitor.visitEnd(); }