main()
method
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 | Deprecated_attribute
.
25 | */
26 | public class DeprecatedAttribute extends AttributeInfo {
27 | /**
28 | * The name of this attribute "Deprecated"
.
29 | */
30 | public static final String tag = "Deprecated";
31 |
32 | DeprecatedAttribute(ConstPool cp, int n, DataInputStream in)
33 | throws IOException
34 | {
35 | super(cp, n, in);
36 | }
37 |
38 | /**
39 | * Constructs a Deprecated attribute.
40 | *
41 | * @param cp a constant pool table.
42 | */
43 | public DeprecatedAttribute(ConstPool cp) {
44 | super(cp, tag, new byte[0]);
45 | }
46 |
47 | /**
48 | * Makes a copy.
49 | *
50 | * @param newCp the constant pool table used by the new copy.
51 | * @param classnames should be null.
52 | */
53 | public AttributeInfo copy(ConstPool newCp, Map classnames) {
54 | return new DeprecatedAttribute(newCp);
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/src/javassist/bytecode/DuplicateMemberException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Javassist, a Java-bytecode translator toolkit.
3 | * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
4 | *
5 | * The contents of this file are subject to the Mozilla Public License Version
6 | * 1.1 (the "License"); you may not use this file except in compliance with
7 | * the License. Alternatively, the contents of this file may be used under
8 | * the terms of the GNU Lesser General Public License Version 2.1 or later,
9 | * or the Apache License Version 2.0.
10 | *
11 | * Software distributed under the License is distributed on an "AS IS" basis,
12 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 | * for the specific language governing rights and limitations under the
14 | * License.
15 | */
16 |
17 | package javassist.bytecode;
18 |
19 | import javassist.CannotCompileException;
20 |
21 | /**
22 | * An exception thrown when adding a duplicate member is requested.
23 | *
24 | * @see ClassFile#addMethod(MethodInfo)
25 | * @see ClassFile#addField(FieldInfo)
26 | */
27 | public class DuplicateMemberException extends CannotCompileException {
28 | public DuplicateMemberException(String msg) {
29 | super(msg);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/javassist/bytecode/LocalVariableTypeAttribute.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Javassist, a Java-bytecode translator toolkit.
3 | * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
4 | *
5 | * The contents of this file are subject to the Mozilla Public License Version
6 | * 1.1 (the "License"); you may not use this file except in compliance with
7 | * the License. Alternatively, the contents of this file may be used under
8 | * the terms of the GNU Lesser General Public License Version 2.1 or later,
9 | * or the Apache License Version 2.0.
10 | *
11 | * Software distributed under the License is distributed on an "AS IS" basis,
12 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 | * for the specific language governing rights and limitations under the
14 | * License.
15 | */
16 |
17 | package javassist.bytecode;
18 |
19 | import java.io.DataInputStream;
20 | import java.io.IOException;
21 | import java.util.Map;
22 |
23 | /**
24 | * LocalVariableTypeTable_attribute
.
25 | *
26 | * @since 3.11
27 | */
28 | public class LocalVariableTypeAttribute extends LocalVariableAttribute {
29 | /**
30 | * The name of the attribute "LocalVariableTypeTable"
.
31 | */
32 | public static final String tag = LocalVariableAttribute.typeTag;
33 |
34 | /**
35 | * Constructs an empty LocalVariableTypeTable.
36 | */
37 | public LocalVariableTypeAttribute(ConstPool cp) {
38 | super(cp, tag, new byte[2]);
39 | ByteArray.write16bit(0, info, 0);
40 | }
41 |
42 | LocalVariableTypeAttribute(ConstPool cp, int n, DataInputStream in)
43 | throws IOException
44 | {
45 | super(cp, n, in);
46 | }
47 |
48 | private LocalVariableTypeAttribute(ConstPool cp, byte[] dest) {
49 | super(cp, tag, dest);
50 | }
51 |
52 | String renameEntry(String desc, String oldname, String newname) {
53 | return SignatureAttribute.renameClass(desc, oldname, newname);
54 | }
55 |
56 | String renameEntry(String desc, Map classnames) {
57 | return SignatureAttribute.renameClass(desc, classnames);
58 | }
59 |
60 | LocalVariableAttribute makeThisAttr(ConstPool cp, byte[] dest) {
61 | return new LocalVariableTypeAttribute(cp, dest);
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/javassist/bytecode/LongVector.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Javassist, a Java-bytecode translator toolkit.
3 | * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
4 | *
5 | * The contents of this file are subject to the Mozilla Public License Version
6 | * 1.1 (the "License"); you may not use this file except in compliance with
7 | * the License. Alternatively, the contents of this file may be used under
8 | * the terms of the GNU Lesser General Public License Version 2.1 or later,
9 | * or the Apache License Version 2.0.
10 | *
11 | * Software distributed under the License is distributed on an "AS IS" basis,
12 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 | * for the specific language governing rights and limitations under the
14 | * License.
15 | */
16 |
17 | package javassist.bytecode;
18 |
19 | final class LongVector {
20 | static final int ASIZE = 128;
21 | static final int ABITS = 7; // ASIZE = 2^ABITS
22 | static final int VSIZE = 8;
23 | private ConstInfo[][] objects;
24 | private int elements;
25 |
26 | public LongVector() {
27 | objects = new ConstInfo[VSIZE][];
28 | elements = 0;
29 | }
30 |
31 | public LongVector(int initialSize) {
32 | int vsize = ((initialSize >> ABITS) & ~(VSIZE - 1)) + VSIZE;
33 | objects = new ConstInfo[vsize][];
34 | elements = 0;
35 | }
36 |
37 | public int size() { return elements; }
38 |
39 | public int capacity() { return objects.length * ASIZE; }
40 |
41 | public ConstInfo elementAt(int i) {
42 | if (i < 0 || elements <= i)
43 | return null;
44 |
45 | return objects[i >> ABITS][i & (ASIZE - 1)];
46 | }
47 |
48 | public void addElement(ConstInfo value) {
49 | int nth = elements >> ABITS;
50 | int offset = elements & (ASIZE - 1);
51 | int len = objects.length;
52 | if (nth >= len) {
53 | ConstInfo[][] newObj = new ConstInfo[len + VSIZE][];
54 | System.arraycopy(objects, 0, newObj, 0, len);
55 | objects = newObj;
56 | }
57 |
58 | if (objects[nth] == null)
59 | objects[nth] = new ConstInfo[ASIZE];
60 |
61 | objects[nth][offset] = value;
62 | elements++;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/src/javassist/bytecode/SourceFileAttribute.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Javassist, a Java-bytecode translator toolkit.
3 | * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
4 | *
5 | * The contents of this file are subject to the Mozilla Public License Version
6 | * 1.1 (the "License"); you may not use this file except in compliance with
7 | * the License. Alternatively, the contents of this file may be used under
8 | * the terms of the GNU Lesser General Public License Version 2.1 or later,
9 | * or the Apache License Version 2.0.
10 | *
11 | * Software distributed under the License is distributed on an "AS IS" basis,
12 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 | * for the specific language governing rights and limitations under the
14 | * License.
15 | */
16 |
17 | package javassist.bytecode;
18 |
19 | import java.io.DataInputStream;
20 | import java.io.IOException;
21 | import java.util.Map;
22 |
23 | /**
24 | * SourceFile_attribute
.
25 | */
26 | public class SourceFileAttribute extends AttributeInfo {
27 | /**
28 | * The name of this attribute "SourceFile"
.
29 | */
30 | public static final String tag = "SourceFile";
31 |
32 | SourceFileAttribute(ConstPool cp, int n, DataInputStream in)
33 | throws IOException
34 | {
35 | super(cp, n, in);
36 | }
37 |
38 | /**
39 | * Constructs a SourceFile attribute.
40 | *
41 | * @param cp a constant pool table.
42 | * @param filename the name of the source file.
43 | */
44 | public SourceFileAttribute(ConstPool cp, String filename) {
45 | super(cp, tag);
46 | int index = cp.addUtf8Info(filename);
47 | byte[] bvalue = new byte[2];
48 | bvalue[0] = (byte)(index >>> 8);
49 | bvalue[1] = (byte)index;
50 | set(bvalue);
51 | }
52 |
53 | /**
54 | * Returns the file name indicated by sourcefile_index
.
55 | */
56 | public String getFileName() {
57 | return getConstPool().getUtf8Info(ByteArray.readU16bit(get(), 0));
58 | }
59 |
60 | /**
61 | * Makes a copy. Class names are replaced according to the
62 | * given Map
object.
63 | *
64 | * @param newCp the constant pool table used by the new copy.
65 | * @param classnames pairs of replaced and substituted
66 | * class names.
67 | */
68 | public AttributeInfo copy(ConstPool newCp, Map classnames) {
69 | return new SourceFileAttribute(newCp, getFileName());
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/javassist/bytecode/SyntheticAttribute.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Javassist, a Java-bytecode translator toolkit.
3 | * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
4 | *
5 | * The contents of this file are subject to the Mozilla Public License Version
6 | * 1.1 (the "License"); you may not use this file except in compliance with
7 | * the License. Alternatively, the contents of this file may be used under
8 | * the terms of the GNU Lesser General Public License Version 2.1 or later,
9 | * or the Apache License Version 2.0.
10 | *
11 | * Software distributed under the License is distributed on an "AS IS" basis,
12 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 | * for the specific language governing rights and limitations under the
14 | * License.
15 | */
16 |
17 | package javassist.bytecode;
18 |
19 | import java.io.DataInputStream;
20 | import java.io.IOException;
21 | import java.util.Map;
22 |
23 | /**
24 | * Synthetic_attribute
.
25 | */
26 | public class SyntheticAttribute extends AttributeInfo {
27 | /**
28 | * The name of this attribute "Synthetic"
.
29 | */
30 | public static final String tag = "Synthetic";
31 |
32 | SyntheticAttribute(ConstPool cp, int n, DataInputStream in)
33 | throws IOException
34 | {
35 | super(cp, n, in);
36 | }
37 |
38 | /**
39 | * Constructs a Synthetic attribute.
40 | *
41 | * @param cp a constant pool table.
42 | */
43 | public SyntheticAttribute(ConstPool cp) {
44 | super(cp, tag, new byte[0]);
45 | }
46 |
47 | /**
48 | * Makes a copy.
49 | *
50 | * @param newCp the constant pool table used by the new copy.
51 | * @param classnames should be null.
52 | */
53 | public AttributeInfo copy(ConstPool newCp, Map classnames) {
54 | return new SyntheticAttribute(newCp);
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/src/javassist/bytecode/analysis/IntQueue.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Javassist, a Java-bytecode translator toolkit.
3 | * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
4 | *
5 | * The contents of this file are subject to the Mozilla Public License Version
6 | * 1.1 (the "License"); you may not use this file except in compliance with
7 | * the License. Alternatively, the contents of this file may be used under
8 | * the terms of the GNU Lesser General Public License Version 2.1 or later,
9 | * or the Apache License Version 2.0.
10 | *
11 | * Software distributed under the License is distributed on an "AS IS" basis,
12 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 | * for the specific language governing rights and limitations under the
14 | * License.
15 | */
16 | package javassist.bytecode.analysis;
17 |
18 | import java.util.NoSuchElementException;
19 |
20 | class IntQueue {
21 | private static class Entry {
22 | private IntQueue.Entry next;
23 | private int value;
24 | private Entry(int value) {
25 | this.value = value;
26 | }
27 | }
28 | private IntQueue.Entry head;
29 |
30 | private IntQueue.Entry tail;
31 |
32 | void add(int value) {
33 | IntQueue.Entry entry = new Entry(value);
34 | if (tail != null)
35 | tail.next = entry;
36 | tail = entry;
37 |
38 | if (head == null)
39 | head = entry;
40 | }
41 |
42 | boolean isEmpty() {
43 | return head == null;
44 | }
45 |
46 | int take() {
47 | if (head == null)
48 | throw new NoSuchElementException();
49 |
50 | int value = head.value;
51 | head = head.next;
52 | if (head == null)
53 | tail = null;
54 |
55 | return value;
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/javassist/bytecode/analysis/Subroutine.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Javassist, a Java-bytecode translator toolkit.
3 | * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
4 | *
5 | * The contents of this file are subject to the Mozilla Public License Version
6 | * 1.1 (the "License"); you may not use this file except in compliance with
7 | * the License. Alternatively, the contents of this file may be used under
8 | * the terms of the GNU Lesser General Public License Version 2.1 or later,
9 | * or the Apache License Version 2.0.
10 | *
11 | * Software distributed under the License is distributed on an "AS IS" basis,
12 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 | * for the specific language governing rights and limitations under the
14 | * License.
15 | */
16 | package javassist.bytecode.analysis;
17 |
18 | import java.util.ArrayList;
19 | import java.util.Collection;
20 | import java.util.HashSet;
21 | import java.util.List;
22 | import java.util.Set;
23 |
24 | /**
25 | * Represents a nested method subroutine (marked by JSR and RET).
26 | *
27 | * @author Jason T. Greene
28 | */
29 | public class Subroutine {
30 | //private Set callers = new HashSet();
31 | private List callers = new ArrayList();
32 | private Set access = new HashSet();
33 | private int start;
34 |
35 | public Subroutine(int start, int caller) {
36 | this.start = start;
37 | callers.add(new Integer(caller));
38 | }
39 |
40 | public void addCaller(int caller) {
41 | callers.add(new Integer(caller));
42 | }
43 |
44 | public int start() {
45 | return start;
46 | }
47 |
48 | public void access(int index) {
49 | access.add(new Integer(index));
50 | }
51 |
52 | public boolean isAccessed(int index) {
53 | return access.contains(new Integer(index));
54 | }
55 |
56 | public Collection accessed() {
57 | return access;
58 | }
59 |
60 | public Collection callers() {
61 | return callers;
62 | }
63 |
64 | public String toString() {
65 | return "start = " + start + " callers = " + callers.toString();
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/javassist/bytecode/analysis/Util.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Javassist, a Java-bytecode translator toolkit.
3 | * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
4 | *
5 | * The contents of this file are subject to the Mozilla Public License Version
6 | * 1.1 (the "License"); you may not use this file except in compliance with
7 | * the License. Alternatively, the contents of this file may be used under
8 | * the terms of the GNU Lesser General Public License Version 2.1 or later,
9 | * or the Apache License Version 2.0.
10 | *
11 | * Software distributed under the License is distributed on an "AS IS" basis,
12 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 | * for the specific language governing rights and limitations under the
14 | * License.
15 | */
16 | package javassist.bytecode.analysis;
17 |
18 | import javassist.bytecode.CodeIterator;
19 | import javassist.bytecode.Opcode;
20 |
21 | /**
22 | * A set of common utility methods.
23 | *
24 | * @author Jason T. Greene
25 | */
26 | public class Util implements Opcode {
27 | public static int getJumpTarget(int pos, CodeIterator iter) {
28 | int opcode = iter.byteAt(pos);
29 | pos += (opcode == JSR_W || opcode == GOTO_W) ? iter.s32bitAt(pos + 1) : iter.s16bitAt(pos + 1);
30 | return pos;
31 | }
32 |
33 | public static boolean isJumpInstruction(int opcode) {
34 | return (opcode >= IFEQ && opcode <= JSR) || opcode == IFNULL || opcode == IFNONNULL || opcode == JSR_W || opcode == GOTO_W;
35 | }
36 |
37 | public static boolean isGoto(int opcode) {
38 | return opcode == GOTO || opcode == GOTO_W;
39 | }
40 |
41 | public static boolean isJsr(int opcode) {
42 | return opcode == JSR || opcode == JSR_W;
43 | }
44 |
45 | public static boolean isReturn(int opcode) {
46 | return (opcode >= IRETURN && opcode <= RETURN);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/javassist/bytecode/analysis/package.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Bytecode Analysis API.
4 |
5 | This package provides an API for performing data-flow analysis on a method's bytecode.
6 | This allows the user to determine the type state of the stack and local variable table
7 | at the start of every instruction. In addition this API can be used to validate
8 | bytecode, find dead bytecode, and identify unnecessary checkcasts.
9 | Look at ControlFlow
class first for details.
10 |
11 |
The users of this package must know the specifications of 12 | class file and Java bytecode. For more details, read this book: 13 | 14 |
This package provides low-level API for editing annotations attributes. 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/javassist/bytecode/package.html: -------------------------------------------------------------------------------- 1 | 2 |
3 | Bytecode-level API. 4 | 5 |This package provides low-level API for editing a raw class file. 6 | It allows the users to read and modify a constant pool entry, a single 7 | bytecode instruction, and so on. 8 | 9 |
The users of this package must know the specifications of 10 | class file and Java bytecode. For more details, read this book: 11 | 12 |
getLeft()
25 | * and getRight()
returns null.
26 | */
27 | public abstract class ASTree implements Serializable {
28 | public ASTree getLeft() { return null; }
29 |
30 | public ASTree getRight() { return null; }
31 |
32 | public void setLeft(ASTree _left) {}
33 |
34 | public void setRight(ASTree _right) {}
35 |
36 | /**
37 | * Is a method for the visitor pattern. It calls
38 | * atXXX()
on the given visitor, where
39 | * XXX
is the class name of the node object.
40 | */
41 | public abstract void accept(Visitor v) throws CompileError;
42 |
43 | public String toString() {
44 | StringBuffer sbuf = new StringBuffer();
45 | sbuf.append('<');
46 | sbuf.append(getTag());
47 | sbuf.append('>');
48 | return sbuf.toString();
49 | }
50 |
51 | /**
52 | * Returns the type of this node. This method is used by
53 | * toString()
.
54 | */
55 | protected String getTag() {
56 | String name = getClass().getName();
57 | return name.substring(name.lastIndexOf('.') + 1);
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/javassist/compiler/ast/ArrayInit.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Javassist, a Java-bytecode translator toolkit.
3 | * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
4 | *
5 | * The contents of this file are subject to the Mozilla Public License Version
6 | * 1.1 (the "License"); you may not use this file except in compliance with
7 | * the License. Alternatively, the contents of this file may be used under
8 | * the terms of the GNU Lesser General Public License Version 2.1 or later,
9 | * or the Apache License Version 2.0.
10 | *
11 | * Software distributed under the License is distributed on an "AS IS" basis,
12 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 | * for the specific language governing rights and limitations under the
14 | * License.
15 | */
16 |
17 | package javassist.compiler.ast;
18 |
19 | import javassist.compiler.CompileError;
20 |
21 | /**
22 | * Array initializer such as { 1, 2, 3 }
.
23 | */
24 | public class ArrayInit extends ASTList {
25 | public ArrayInit(ASTree firstElement) {
26 | super(firstElement);
27 | }
28 |
29 | public void accept(Visitor v) throws CompileError { v.atArrayInit(this); }
30 |
31 | public String getTag() { return "array"; }
32 | }
33 |
--------------------------------------------------------------------------------
/src/javassist/compiler/ast/AssignExpr.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Javassist, a Java-bytecode translator toolkit.
3 | * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
4 | *
5 | * The contents of this file are subject to the Mozilla Public License Version
6 | * 1.1 (the "License"); you may not use this file except in compliance with
7 | * the License. Alternatively, the contents of this file may be used under
8 | * the terms of the GNU Lesser General Public License Version 2.1 or later,
9 | * or the Apache License Version 2.0.
10 | *
11 | * Software distributed under the License is distributed on an "AS IS" basis,
12 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 | * for the specific language governing rights and limitations under the
14 | * License.
15 | */
16 |
17 | package javassist.compiler.ast;
18 |
19 | import javassist.compiler.CompileError;
20 |
21 | /**
22 | * Assignment expression.
23 | */
24 | public class AssignExpr extends Expr {
25 | /* operator must be either of:
26 | * =, %=, &=, *=, +=, -=, /=, ^=, |=, <<=, >>=, >>>=
27 | */
28 |
29 | private AssignExpr(int op, ASTree _head, ASTList _tail) {
30 | super(op, _head, _tail);
31 | }
32 |
33 | public static AssignExpr makeAssign(int op, ASTree oprand1,
34 | ASTree oprand2) {
35 | return new AssignExpr(op, oprand1, new ASTList(oprand2));
36 | }
37 |
38 | public void accept(Visitor v) throws CompileError {
39 | v.atAssignExpr(this);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/javassist/compiler/ast/BinExpr.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Javassist, a Java-bytecode translator toolkit.
3 | * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
4 | *
5 | * The contents of this file are subject to the Mozilla Public License Version
6 | * 1.1 (the "License"); you may not use this file except in compliance with
7 | * the License. Alternatively, the contents of this file may be used under
8 | * the terms of the GNU Lesser General Public License Version 2.1 or later,
9 | * or the Apache License Version 2.0.
10 | *
11 | * Software distributed under the License is distributed on an "AS IS" basis,
12 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 | * for the specific language governing rights and limitations under the
14 | * License.
15 | */
16 |
17 | package javassist.compiler.ast;
18 |
19 | import javassist.compiler.CompileError;
20 |
21 | /**
22 | * Binary expression.
23 | *
24 | * If the operator is +, the right node might be null.
25 | * See TypeChecker.atBinExpr().
26 | */
27 | public class BinExpr extends Expr {
28 | /* operator must be either of:
29 | * ||, &&, |, ^, &, ==, !=, <=, >=, <, >,
30 | * <<, >>, >>>, +, -, *, /, %
31 | */
32 |
33 | private BinExpr(int op, ASTree _head, ASTList _tail) {
34 | super(op, _head, _tail);
35 | }
36 |
37 | public static BinExpr makeBin(int op, ASTree oprand1, ASTree oprand2) {
38 | return new BinExpr(op, oprand1, new ASTList(oprand2));
39 | }
40 |
41 | public void accept(Visitor v) throws CompileError { v.atBinExpr(this); }
42 | }
43 |
--------------------------------------------------------------------------------
/src/javassist/compiler/ast/CallExpr.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Javassist, a Java-bytecode translator toolkit.
3 | * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
4 | *
5 | * The contents of this file are subject to the Mozilla Public License Version
6 | * 1.1 (the "License"); you may not use this file except in compliance with
7 | * the License. Alternatively, the contents of this file may be used under
8 | * the terms of the GNU Lesser General Public License Version 2.1 or later,
9 | * or the Apache License Version 2.0.
10 | *
11 | * Software distributed under the License is distributed on an "AS IS" basis,
12 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 | * for the specific language governing rights and limitations under the
14 | * License.
15 | */
16 |
17 | package javassist.compiler.ast;
18 |
19 | import javassist.compiler.CompileError;
20 | import javassist.compiler.TokenId;
21 | import javassist.compiler.MemberResolver;
22 |
23 | /**
24 | * Method call expression.
25 | */
26 | public class CallExpr extends Expr {
27 | private MemberResolver.Method method; // cached result of lookupMethod()
28 |
29 | private CallExpr(ASTree _head, ASTList _tail) {
30 | super(TokenId.CALL, _head, _tail);
31 | method = null;
32 | }
33 |
34 | public void setMethod(MemberResolver.Method m) {
35 | method = m;
36 | }
37 |
38 | public MemberResolver.Method getMethod() {
39 | return method;
40 | }
41 |
42 | public static CallExpr makeCall(ASTree target, ASTree args) {
43 | return new CallExpr(target, new ASTList(args));
44 | }
45 |
46 | public void accept(Visitor v) throws CompileError { v.atCallExpr(this); }
47 | }
48 |
--------------------------------------------------------------------------------
/src/javassist/compiler/ast/CastExpr.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Javassist, a Java-bytecode translator toolkit.
3 | * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
4 | *
5 | * The contents of this file are subject to the Mozilla Public License Version
6 | * 1.1 (the "License"); you may not use this file except in compliance with
7 | * the License. Alternatively, the contents of this file may be used under
8 | * the terms of the GNU Lesser General Public License Version 2.1 or later,
9 | * or the Apache License Version 2.0.
10 | *
11 | * Software distributed under the License is distributed on an "AS IS" basis,
12 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 | * for the specific language governing rights and limitations under the
14 | * License.
15 | */
16 |
17 | package javassist.compiler.ast;
18 |
19 | import javassist.compiler.TokenId;
20 | import javassist.compiler.CompileError;
21 |
22 | /**
23 | * Cast expression.
24 | */
25 | public class CastExpr extends ASTList implements TokenId {
26 | protected int castType;
27 | protected int arrayDim;
28 |
29 | public CastExpr(ASTList className, int dim, ASTree expr) {
30 | super(className, new ASTList(expr));
31 | castType = CLASS;
32 | arrayDim = dim;
33 | }
34 |
35 | public CastExpr(int type, int dim, ASTree expr) {
36 | super(null, new ASTList(expr));
37 | castType = type;
38 | arrayDim = dim;
39 | }
40 |
41 | /* Returns CLASS, BOOLEAN, INT, or ...
42 | */
43 | public int getType() { return castType; }
44 |
45 | public int getArrayDim() { return arrayDim; }
46 |
47 | public ASTList getClassName() { return (ASTList)getLeft(); }
48 |
49 | public ASTree getOprand() { return getRight().getLeft(); }
50 |
51 | public void setOprand(ASTree t) { getRight().setLeft(t); }
52 |
53 | public String getTag() { return "cast:" + castType + ":" + arrayDim; }
54 |
55 | public void accept(Visitor v) throws CompileError { v.atCastExpr(this); }
56 | }
57 |
--------------------------------------------------------------------------------
/src/javassist/compiler/ast/CondExpr.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Javassist, a Java-bytecode translator toolkit.
3 | * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
4 | *
5 | * The contents of this file are subject to the Mozilla Public License Version
6 | * 1.1 (the "License"); you may not use this file except in compliance with
7 | * the License. Alternatively, the contents of this file may be used under
8 | * the terms of the GNU Lesser General Public License Version 2.1 or later,
9 | * or the Apache License Version 2.0.
10 | *
11 | * Software distributed under the License is distributed on an "AS IS" basis,
12 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 | * for the specific language governing rights and limitations under the
14 | * License.
15 | */
16 |
17 | package javassist.compiler.ast;
18 |
19 | import javassist.compiler.CompileError;
20 |
21 | /**
22 | * Conditional expression.
23 | */
24 | public class CondExpr extends ASTList {
25 | public CondExpr(ASTree cond, ASTree thenp, ASTree elsep) {
26 | super(cond, new ASTList(thenp, new ASTList(elsep)));
27 | }
28 |
29 | public ASTree condExpr() { return head(); }
30 |
31 | public void setCond(ASTree t) { setHead(t); }
32 |
33 | public ASTree thenExpr() { return tail().head(); }
34 |
35 | public void setThen(ASTree t) { tail().setHead(t); }
36 |
37 | public ASTree elseExpr() { return tail().tail().head(); }
38 |
39 | public void setElse(ASTree t) { tail().tail().setHead(t); }
40 |
41 | public String getTag() { return "?:"; }
42 |
43 | public void accept(Visitor v) throws CompileError { v.atCondExpr(this); }
44 | }
45 |
--------------------------------------------------------------------------------
/src/javassist/compiler/ast/FieldDecl.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Javassist, a Java-bytecode translator toolkit.
3 | * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
4 | *
5 | * The contents of this file are subject to the Mozilla Public License Version
6 | * 1.1 (the "License"); you may not use this file except in compliance with
7 | * the License. Alternatively, the contents of this file may be used under
8 | * the terms of the GNU Lesser General Public License Version 2.1 or later,
9 | * or the Apache License Version 2.0.
10 | *
11 | * Software distributed under the License is distributed on an "AS IS" basis,
12 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 | * for the specific language governing rights and limitations under the
14 | * License.
15 | */
16 |
17 | package javassist.compiler.ast;
18 |
19 | import javassist.compiler.CompileError;
20 |
21 | public class FieldDecl extends ASTList {
22 | public FieldDecl(ASTree _head, ASTList _tail) {
23 | super(_head, _tail);
24 | }
25 |
26 | public ASTList getModifiers() { return (ASTList)getLeft(); }
27 |
28 | public Declarator getDeclarator() { return (Declarator)tail().head(); }
29 |
30 | public ASTree getInit() { return (ASTree)sublist(2).head(); }
31 |
32 | public void accept(Visitor v) throws CompileError {
33 | v.atFieldDecl(this);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/javassist/compiler/ast/InstanceOfExpr.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Javassist, a Java-bytecode translator toolkit.
3 | * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
4 | *
5 | * The contents of this file are subject to the Mozilla Public License Version
6 | * 1.1 (the "License"); you may not use this file except in compliance with
7 | * the License. Alternatively, the contents of this file may be used under
8 | * the terms of the GNU Lesser General Public License Version 2.1 or later,
9 | * or the Apache License Version 2.0.
10 | *
11 | * Software distributed under the License is distributed on an "AS IS" basis,
12 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 | * for the specific language governing rights and limitations under the
14 | * License.
15 | */
16 |
17 | package javassist.compiler.ast;
18 |
19 | import javassist.compiler.CompileError;
20 |
21 | /**
22 | * Instanceof expression.
23 | */
24 | public class InstanceOfExpr extends CastExpr {
25 | public InstanceOfExpr(ASTList className, int dim, ASTree expr) {
26 | super(className, dim, expr);
27 | }
28 |
29 | public InstanceOfExpr(int type, int dim, ASTree expr) {
30 | super(type, dim, expr);
31 | }
32 |
33 | public String getTag() {
34 | return "instanceof:" + castType + ":" + arrayDim;
35 | }
36 |
37 | public void accept(Visitor v) throws CompileError {
38 | v.atInstanceOfExpr(this);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/javassist/compiler/ast/Keyword.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Javassist, a Java-bytecode translator toolkit.
3 | * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
4 | *
5 | * The contents of this file are subject to the Mozilla Public License Version
6 | * 1.1 (the "License"); you may not use this file except in compliance with
7 | * the License. Alternatively, the contents of this file may be used under
8 | * the terms of the GNU Lesser General Public License Version 2.1 or later,
9 | * or the Apache License Version 2.0.
10 | *
11 | * Software distributed under the License is distributed on an "AS IS" basis,
12 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 | * for the specific language governing rights and limitations under the
14 | * License.
15 | */
16 |
17 | package javassist.compiler.ast;
18 |
19 | import javassist.compiler.CompileError;
20 |
21 | /**
22 | * Keyword.
23 | */
24 | public class Keyword extends ASTree {
25 | protected int tokenId;
26 |
27 | public Keyword(int token) {
28 | tokenId = token;
29 | }
30 |
31 | public int get() { return tokenId; }
32 |
33 | public String toString() { return "id:" + tokenId; }
34 |
35 | public void accept(Visitor v) throws CompileError { v.atKeyword(this); }
36 | }
37 |
--------------------------------------------------------------------------------
/src/javassist/compiler/ast/Member.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Javassist, a Java-bytecode translator toolkit.
3 | * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
4 | *
5 | * The contents of this file are subject to the Mozilla Public License Version
6 | * 1.1 (the "License"); you may not use this file except in compliance with
7 | * the License. Alternatively, the contents of this file may be used under
8 | * the terms of the GNU Lesser General Public License Version 2.1 or later,
9 | * or the Apache License Version 2.0.
10 | *
11 | * Software distributed under the License is distributed on an "AS IS" basis,
12 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 | * for the specific language governing rights and limitations under the
14 | * License.
15 | */
16 |
17 | package javassist.compiler.ast;
18 |
19 | import javassist.compiler.CompileError;
20 | import javassist.CtField;
21 |
22 | /**
23 | * Member name.
24 | */
25 | public class Member extends Symbol {
26 | // cache maintained by fieldAccess() in TypeChecker.
27 | // this is used to obtain the value of a static final field.
28 | private CtField field;
29 |
30 | public Member(String name) {
31 | super(name);
32 | field = null;
33 | }
34 |
35 | public void setField(CtField f) { field = f; }
36 |
37 | public CtField getField() { return field; }
38 |
39 | public void accept(Visitor v) throws CompileError { v.atMember(this); }
40 | }
41 |
--------------------------------------------------------------------------------
/src/javassist/compiler/ast/MethodDecl.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Javassist, a Java-bytecode translator toolkit.
3 | * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
4 | *
5 | * The contents of this file are subject to the Mozilla Public License Version
6 | * 1.1 (the "License"); you may not use this file except in compliance with
7 | * the License. Alternatively, the contents of this file may be used under
8 | * the terms of the GNU Lesser General Public License Version 2.1 or later,
9 | * or the Apache License Version 2.0.
10 | *
11 | * Software distributed under the License is distributed on an "AS IS" basis,
12 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 | * for the specific language governing rights and limitations under the
14 | * License.
15 | */
16 |
17 | package javassist.compiler.ast;
18 |
19 | import javassist.compiler.CompileError;
20 |
21 | public class MethodDecl extends ASTList {
22 | public static final String initName = " This package contains the classes for modifying a method body.
5 | See Javassist (Java programming assistant) makes bytecode
6 | engineering simple. It is a class library for editing
7 | bytecode in Java; it enables Java programs to define a new class at
8 | runtime and to modify a given class file when the JVM loads it.
9 |
10 | The most significant class of this package is To know the version number of this package, type the following command:
14 |
15 | It prints the version number on the console.
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/src/javassist/runtime/Cflow.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Javassist, a Java-bytecode translator toolkit.
3 | * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
4 | *
5 | * The contents of this file are subject to the Mozilla Public License Version
6 | * 1.1 (the "License"); you may not use this file except in compliance with
7 | * the License. Alternatively, the contents of this file may be used under
8 | * the terms of the GNU Lesser General Public License Version 2.1 or later,
9 | * or the Apache License Version 2.0.
10 | *
11 | * Software distributed under the License is distributed on an "AS IS" basis,
12 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 | * for the specific language governing rights and limitations under the
14 | * License.
15 | */
16 |
17 | package javassist.runtime;
18 |
19 | /**
20 | * A support class for implementing This package includes support classes that may be required by
6 | classes modified with Javassist. Note that most of the modified
7 | classes do not require these support classes. See the documentation
8 | of every support class to know which kind of modification needs
9 | a support class.
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/javassist/scopedpool/ScopedClassPoolFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Javassist, a Java-bytecode translator toolkit.
3 | * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
4 | *
5 | * The contents of this file are subject to the Mozilla Public License Version
6 | * 1.1 (the "License"); you may not use this file except in compliance with
7 | * the License. Alternatively, the contents of this file may be used under
8 | * the terms of the GNU Lesser General Public License Version 2.1 or later,
9 | * or the Apache License Version 2.0.
10 | *
11 | * Software distributed under the License is distributed on an "AS IS" basis,
12 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 | * for the specific language governing rights and limitations under the
14 | * License.
15 | */
16 |
17 | package javassist.scopedpool;
18 |
19 | import javassist.ClassPool;
20 |
21 | /**
22 | * A factory interface.
23 | *
24 | * @author Kabir Khan
25 | * @version $Revision: 1.4 $
26 | */
27 | public interface ScopedClassPoolFactory {
28 | /**
29 | * Makes an instance.
30 | */
31 | ScopedClassPool create(ClassLoader cl, ClassPool src,
32 | ScopedClassPoolRepository repository);
33 |
34 | /**
35 | * Makes an instance.
36 | */
37 | ScopedClassPool create(ClassPool src,
38 | ScopedClassPoolRepository repository);
39 | }
40 |
--------------------------------------------------------------------------------
/src/javassist/scopedpool/ScopedClassPoolFactoryImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Javassist, a Java-bytecode translator toolkit.
3 | * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
4 | *
5 | * The contents of this file are subject to the Mozilla Public License Version
6 | * 1.1 (the "License"); you may not use this file except in compliance with
7 | * the License. Alternatively, the contents of this file may be used under
8 | * the terms of the GNU Lesser General Public License Version 2.1 or later,
9 | * or the Apache License Version 2.0.
10 | *
11 | * Software distributed under the License is distributed on an "AS IS" basis,
12 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 | * for the specific language governing rights and limitations under the
14 | * License.
15 | */
16 |
17 | package javassist.scopedpool;
18 |
19 | import javassist.ClassPool;
20 |
21 | /**
22 | * An implementation of factory.
23 | *
24 | * @author Kabir Khan
25 | * @version $Revision: 1.5 $
26 | */
27 | public class ScopedClassPoolFactoryImpl implements ScopedClassPoolFactory {
28 | /**
29 | * Makes an instance.
30 | */
31 | public ScopedClassPool create(ClassLoader cl, ClassPool src,
32 | ScopedClassPoolRepository repository) {
33 | return new ScopedClassPool(cl, src, repository, false);
34 | }
35 |
36 | /**
37 | * Makes an instance.
38 | */
39 | public ScopedClassPool create(ClassPool src,
40 | ScopedClassPoolRepository repository) {
41 | return new ScopedClassPool(null, src, repository, true);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/javassist/scopedpool/package.html:
--------------------------------------------------------------------------------
1 |
2 | A custom class pool for several JBoss products.
4 | It is not part of Javassist.
5 | For example,
29 | * prints the contents of the constant pool and the list of methods
32 | * and fields.
33 | */
34 | public class Dump {
35 | private Dump() {}
36 |
37 | /**
38 | * Main method.
39 | *
40 | * @param args For example,
27 | * (also recently known as interceptors or AOP?)
6 |
7 | This package enables a metaobject to trap method calls and field
8 | accesses on a regular Java object. It provides a class
9 | An instance of the reflective class is associated with
17 | a runtime metaobject and a runtime class metaobject, which control
18 | the behavior of that instance.
19 | The runtime
20 | metaobject is created for every (base-level) instance but the
21 | runtime class metaobject is created for every (base-level) class.
22 | This package is provided as a sample implementation of the
27 | reflection mechanism with Javassist. All the programs in this package
28 | uses only the regular Javassist API; they never call any hidden
29 | methods.
30 |
31 | The most significant class in this package is This package enables applets to access remote objects
6 | running on the web server with regular Java syntax.
7 | It is provided as a sample implementation with Javassist.
8 | All the programs in this package uses only the regular
9 | Javassist API; they never call any hidden methods.
10 |
11 | The most significant class of this package is
12 | This package provides a simple web server for sample packages.
6 |
7 |
8 |
--------------------------------------------------------------------------------
/src/javassist/util/package.html:
--------------------------------------------------------------------------------
1 |
2 | this()
and super()
28 | * within a constructor body.
29 | *
30 | * @see NewExpr
31 | */
32 | public class ConstructorCall extends MethodCall {
33 | /**
34 | * Undocumented constructor. Do not use; internal-use only.
35 | */
36 | protected ConstructorCall(int pos, CodeIterator i, CtClass decl, MethodInfo m) {
37 | super(pos, i, decl, m);
38 | }
39 |
40 | /**
41 | * Returns "super"
or ""this"
.
42 | */
43 | public String getMethodName() {
44 | return isSuper() ? "super" : "this";
45 | }
46 |
47 | /**
48 | * Always throws a NotFoundException
.
49 | *
50 | * @see #getConstructor()
51 | */
52 | public CtMethod getMethod() throws NotFoundException {
53 | throw new NotFoundException("this is a constructor call. Call getConstructor().");
54 | }
55 |
56 | /**
57 | * Returns the called constructor.
58 | */
59 | public CtConstructor getConstructor() throws NotFoundException {
60 | return getCtClass().getConstructor(getSignature());
61 | }
62 |
63 | /**
64 | * Returns true if the called constructor is not this()
65 | * but super()
(a constructor declared in the super class).
66 | */
67 | public boolean isSuper() {
68 | return super.isSuper();
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/src/javassist/expr/package.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ExprEditor
(expression editor) for more details.
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/javassist/package.html:
--------------------------------------------------------------------------------
1 |
2 | CtClass
.
11 | See the description of this class first.
12 |
13 |
16 | java -jar javassist.jar
17 |
18 |
19 | $cflow
.
21 | * This support class is required at runtime
22 | * only if $cflow
is used.
23 | *
24 | * @see javassist.CtBehavior#useCflow(String)
25 | */
26 | public class Cflow extends ThreadLocal {
27 | private static class Depth {
28 | private int depth;
29 | Depth() { depth = 0; }
30 | int get() { return depth; }
31 | void inc() { ++depth; }
32 | void dec() { --depth; }
33 | }
34 |
35 | protected synchronized Object initialValue() {
36 | return new Depth();
37 | }
38 |
39 | /**
40 | * Increments the counter.
41 | */
42 | public void enter() { ((Depth)get()).inc(); }
43 |
44 | /**
45 | * Decrements the counter.
46 | */
47 | public void exit() { ((Depth)get()).dec(); }
48 |
49 | /**
50 | * Returns the value of the counter.
51 | */
52 | public int value() { return ((Depth)get()).get(); }
53 | }
54 |
--------------------------------------------------------------------------------
/src/javassist/runtime/DotClass.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Javassist, a Java-bytecode translator toolkit.
3 | * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
4 | *
5 | * The contents of this file are subject to the Mozilla Public License Version
6 | * 1.1 (the "License"); you may not use this file except in compliance with
7 | * the License. Alternatively, the contents of this file may be used under
8 | * the terms of the GNU Lesser General Public License Version 2.1 or later,
9 | * or the Apache License Version 2.0.
10 | *
11 | * Software distributed under the License is distributed on an "AS IS" basis,
12 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 | * for the specific language governing rights and limitations under the
14 | * License.
15 | */
16 |
17 | package javassist.runtime;
18 |
19 | /**
20 | * A support class for implementing .class
notation.
21 | * This is required at runtime
22 | * only if .class
notation is used in source code given
23 | * to the Javassist compiler.
24 | */
25 | public class DotClass {
26 | public static NoClassDefFoundError fail(ClassNotFoundException e) {
27 | return new NoClassDefFoundError(e.getMessage());
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/javassist/runtime/Inner.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Javassist, a Java-bytecode translator toolkit.
3 | * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
4 | *
5 | * The contents of this file are subject to the Mozilla Public License Version
6 | * 1.1 (the "License"); you may not use this file except in compliance with
7 | * the License. Alternatively, the contents of this file may be used under
8 | * the terms of the GNU Lesser General Public License Version 2.1 or later,
9 | * or the Apache License Version 2.0.
10 | *
11 | * Software distributed under the License is distributed on an "AS IS" basis,
12 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 | * for the specific language governing rights and limitations under the
14 | * License.
15 | */
16 |
17 | package javassist.runtime;
18 |
19 | /**
20 | * A support class for compiling a method declared in an inner class.
21 | * This support class is required at runtime
22 | * only if the method calls a private constructor in the enclosing class.
23 | */
24 | public class Inner {
25 | }
26 |
--------------------------------------------------------------------------------
/src/javassist/runtime/package.html:
--------------------------------------------------------------------------------
1 |
2 | % java javassist.tools.Dump foo.class
30 | *
31 | * args[0]
is the class file name.
41 | */
42 | public static void main(String[] args) throws Exception {
43 | if (args.length != 1) {
44 | System.err.println("Usage: java Dump % java javassist.tools.framedump foo.class
28 | */
29 | public class framedump {
30 | private framedump() {}
31 |
32 | /**
33 | * Main method.
34 | *
35 | * @param args args[0]
is the class file name.
36 | */
37 | public static void main(String[] args) throws Exception {
38 | if (args.length != 1) {
39 | System.err.println("Usage: java javassist.tools.framedump ClassMetaobject.newInstance()
fails.
21 | */
22 | public class CannotCreateException extends Exception {
23 | public CannotCreateException(String s) {
24 | super(s);
25 | }
26 |
27 | public CannotCreateException(Exception e) {
28 | super("by " + e.toString());
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/javassist/tools/reflect/CannotInvokeException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Javassist, a Java-bytecode translator toolkit.
3 | * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
4 | *
5 | * The contents of this file are subject to the Mozilla Public License Version
6 | * 1.1 (the "License"); you may not use this file except in compliance with
7 | * the License. Alternatively, the contents of this file may be used under
8 | * the terms of the GNU Lesser General Public License Version 2.1 or later,
9 | * or the Apache License Version 2.0.
10 | *
11 | * Software distributed under the License is distributed on an "AS IS" basis,
12 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 | * for the specific language governing rights and limitations under the
14 | * License.
15 | */
16 |
17 | package javassist.tools.reflect;
18 |
19 | import java.lang.reflect.InvocationTargetException;
20 | import java.lang.IllegalAccessException;
21 |
22 | /**
23 | * Thrown when method invocation using the reflection API has thrown
24 | * an exception.
25 | *
26 | * @see javassist.tools.reflect.Metaobject#trapMethodcall(int, Object[])
27 | * @see javassist.tools.reflect.ClassMetaobject#trapMethodcall(int, Object[])
28 | * @see javassist.tools.reflect.ClassMetaobject#invoke(Object, int, Object[])
29 | */
30 | public class CannotInvokeException extends RuntimeException {
31 |
32 | private Throwable err = null;
33 |
34 | /**
35 | * Returns the cause of this exception. It may return null.
36 | */
37 | public Throwable getReason() { return err; }
38 |
39 | /**
40 | * Constructs a CannotInvokeException with an error message.
41 | */
42 | public CannotInvokeException(String reason) {
43 | super(reason);
44 | }
45 |
46 | /**
47 | * Constructs a CannotInvokeException with an InvocationTargetException.
48 | */
49 | public CannotInvokeException(InvocationTargetException e) {
50 | super("by " + e.getTargetException().toString());
51 | err = e.getTargetException();
52 | }
53 |
54 | /**
55 | * Constructs a CannotInvokeException with an IllegalAccessException.
56 | */
57 | public CannotInvokeException(IllegalAccessException e) {
58 | super("by " + e.toString());
59 | err = e;
60 | }
61 |
62 | /**
63 | * Constructs a CannotInvokeException with an ClassNotFoundException.
64 | */
65 | public CannotInvokeException(ClassNotFoundException e) {
66 | super("by " + e.toString());
67 | err = e;
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/src/javassist/tools/reflect/CannotReflectException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Javassist, a Java-bytecode translator toolkit.
3 | * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
4 | *
5 | * The contents of this file are subject to the Mozilla Public License Version
6 | * 1.1 (the "License"); you may not use this file except in compliance with
7 | * the License. Alternatively, the contents of this file may be used under
8 | * the terms of the GNU Lesser General Public License Version 2.1 or later,
9 | * or the Apache License Version 2.0.
10 | *
11 | * Software distributed under the License is distributed on an "AS IS" basis,
12 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 | * for the specific language governing rights and limitations under the
14 | * License.
15 | */
16 |
17 | package javassist.tools.reflect;
18 |
19 | import javassist.CannotCompileException;
20 |
21 | /**
22 | * Thrown by makeReflective()
in Reflection
23 | * when there is an attempt to reflect
24 | * a class that is either an interface or a subclass of
25 | * either ClassMetaobject or Metaobject.
26 | *
27 | * @author Brett Randall
28 | * @see javassist.tools.reflect.Reflection#makeReflective(CtClass,CtClass,CtClass)
29 | * @see javassist.CannotCompileException
30 | */
31 | public class CannotReflectException extends CannotCompileException {
32 | public CannotReflectException(String msg) {
33 | super(msg);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/javassist/tools/reflect/Metalevel.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Javassist, a Java-bytecode translator toolkit.
3 | * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
4 | *
5 | * The contents of this file are subject to the Mozilla Public License Version
6 | * 1.1 (the "License"); you may not use this file except in compliance with
7 | * the License. Alternatively, the contents of this file may be used under
8 | * the terms of the GNU Lesser General Public License Version 2.1 or later,
9 | * or the Apache License Version 2.0.
10 | *
11 | * Software distributed under the License is distributed on an "AS IS" basis,
12 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 | * for the specific language governing rights and limitations under the
14 | * License.
15 | */
16 |
17 | package javassist.tools.reflect;
18 |
19 | /**
20 | * An interface to access a metaobject and a class metaobject.
21 | * This interface is implicitly implemented by the reflective
22 | * class.
23 | */
24 | public interface Metalevel {
25 | /**
26 | * Obtains the class metaobject associated with this object.
27 | */
28 | ClassMetaobject _getClass();
29 |
30 | /**
31 | * Obtains the metaobject associated with this object.
32 | */
33 | Metaobject _getMetaobject();
34 |
35 | /**
36 | * Changes the metaobject associated with this object.
37 | */
38 | void _setMetaobject(Metaobject m);
39 | }
40 |
--------------------------------------------------------------------------------
/src/javassist/tools/reflect/Sample.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Javassist, a Java-bytecode translator toolkit.
3 | * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
4 | *
5 | * The contents of this file are subject to the Mozilla Public License Version
6 | * 1.1 (the "License"); you may not use this file except in compliance with
7 | * the License. Alternatively, the contents of this file may be used under
8 | * the terms of the GNU Lesser General Public License Version 2.1 or later,
9 | * or the Apache License Version 2.0.
10 | *
11 | * Software distributed under the License is distributed on an "AS IS" basis,
12 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 | * for the specific language governing rights and limitations under the
14 | * License.
15 | */
16 |
17 | package javassist.tools.reflect;
18 |
19 | /**
20 | * A template used for defining a reflective class.
21 | */
22 | public class Sample {
23 | private Metaobject _metaobject;
24 | private static ClassMetaobject _classobject;
25 |
26 | public Object trap(Object[] args, int identifier) throws Throwable {
27 | Metaobject mobj;
28 | mobj = _metaobject;
29 | if (mobj == null)
30 | return ClassMetaobject.invoke(this, identifier, args);
31 | else
32 | return mobj.trapMethodcall(identifier, args);
33 | }
34 |
35 | public static Object trapStatic(Object[] args, int identifier)
36 | throws Throwable
37 | {
38 | return _classobject.trapMethodcall(identifier, args);
39 | }
40 |
41 | public static Object trapRead(Object[] args, String name) {
42 | if (args[0] == null)
43 | return _classobject.trapFieldRead(name);
44 | else
45 | return ((Metalevel)args[0])._getMetaobject().trapFieldRead(name);
46 | }
47 |
48 | public static Object trapWrite(Object[] args, String name) {
49 | Metalevel base = (Metalevel)args[0];
50 | if (base == null)
51 | _classobject.trapFieldWrite(name, args[1]);
52 | else
53 | base._getMetaobject().trapFieldWrite(name, args[1]);
54 |
55 | return null;
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/javassist/tools/reflect/package.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Runtime Behavioral Reflection.
4 |
5 | Reflection
, which is a main module for implementing
10 | runtime behavioral reflection.
11 | It also provides
12 | a class Loader
and Compiler
13 | as utilities for dynamically or statically
14 | translating a regular class into a reflective class.
15 |
16 | Metaobject
is the root class of the runtime
23 | metaobject and ClassMetaobject
is the root class
24 | of the runtime class metaobject.
25 |
26 | Reflection
.
32 | See the description of this class first.
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/src/javassist/tools/rmi/ObjectNotFoundException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Javassist, a Java-bytecode translator toolkit.
3 | * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
4 | *
5 | * The contents of this file are subject to the Mozilla Public License Version
6 | * 1.1 (the "License"); you may not use this file except in compliance with
7 | * the License. Alternatively, the contents of this file may be used under
8 | * the terms of the GNU Lesser General Public License Version 2.1 or later,
9 | * or the Apache License Version 2.0.
10 | *
11 | * Software distributed under the License is distributed on an "AS IS" basis,
12 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 | * for the specific language governing rights and limitations under the
14 | * License.
15 | */
16 |
17 | package javassist.tools.rmi;
18 |
19 | public class ObjectNotFoundException extends Exception {
20 | public ObjectNotFoundException(String name) {
21 | super(name + " is not exported");
22 | }
23 |
24 | public ObjectNotFoundException(String name, Exception e) {
25 | super(name + " because of " + e.toString());
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/javassist/tools/rmi/Proxy.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Javassist, a Java-bytecode translator toolkit.
3 | * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
4 | *
5 | * The contents of this file are subject to the Mozilla Public License Version
6 | * 1.1 (the "License"); you may not use this file except in compliance with
7 | * the License. Alternatively, the contents of this file may be used under
8 | * the terms of the GNU Lesser General Public License Version 2.1 or later,
9 | * or the Apache License Version 2.0.
10 | *
11 | * Software distributed under the License is distributed on an "AS IS" basis,
12 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 | * for the specific language governing rights and limitations under the
14 | * License.
15 | */
16 |
17 | package javassist.tools.rmi;
18 |
19 | /**
20 | * An interface implemented by proxy classes.
21 | *
22 | * @see javassist.tools.rmi.StubGenerator
23 | */
24 | public interface Proxy {
25 | int _getObjectId();
26 | }
27 |
--------------------------------------------------------------------------------
/src/javassist/tools/rmi/RemoteException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Javassist, a Java-bytecode translator toolkit.
3 | * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
4 | *
5 | * The contents of this file are subject to the Mozilla Public License Version
6 | * 1.1 (the "License"); you may not use this file except in compliance with
7 | * the License. Alternatively, the contents of this file may be used under
8 | * the terms of the GNU Lesser General Public License Version 2.1 or later,
9 | * or the Apache License Version 2.0.
10 | *
11 | * Software distributed under the License is distributed on an "AS IS" basis,
12 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 | * for the specific language governing rights and limitations under the
14 | * License.
15 | */
16 |
17 | package javassist.tools.rmi;
18 |
19 | /**
20 | * RemoteException
represents any exception thrown
21 | * during remote method invocation.
22 | */
23 | public class RemoteException extends RuntimeException {
24 | public RemoteException(String msg) {
25 | super(msg);
26 | }
27 |
28 | public RemoteException(Exception e) {
29 | super("by " + e.toString());
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/javassist/tools/rmi/RemoteRef.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Javassist, a Java-bytecode translator toolkit.
3 | * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
4 | *
5 | * The contents of this file are subject to the Mozilla Public License Version
6 | * 1.1 (the "License"); you may not use this file except in compliance with
7 | * the License. Alternatively, the contents of this file may be used under
8 | * the terms of the GNU Lesser General Public License Version 2.1 or later,
9 | * or the Apache License Version 2.0.
10 | *
11 | * Software distributed under the License is distributed on an "AS IS" basis,
12 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 | * for the specific language governing rights and limitations under the
14 | * License.
15 | */
16 |
17 | package javassist.tools.rmi;
18 |
19 | /**
20 | * Remote reference. This class is internally used for sending a remote
21 | * reference through a network stream.
22 | */
23 | public class RemoteRef implements java.io.Serializable {
24 | public int oid;
25 | public String classname;
26 |
27 | public RemoteRef(int i) {
28 | oid = i;
29 | classname = null;
30 | }
31 |
32 | public RemoteRef(int i, String name) {
33 | oid = i;
34 | classname = name;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/javassist/tools/rmi/Sample.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Javassist, a Java-bytecode translator toolkit.
3 | * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
4 | *
5 | * The contents of this file are subject to the Mozilla Public License Version
6 | * 1.1 (the "License"); you may not use this file except in compliance with
7 | * the License. Alternatively, the contents of this file may be used under
8 | * the terms of the GNU Lesser General Public License Version 2.1 or later,
9 | * or the Apache License Version 2.0.
10 | *
11 | * Software distributed under the License is distributed on an "AS IS" basis,
12 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 | * for the specific language governing rights and limitations under the
14 | * License.
15 | */
16 |
17 | package javassist.tools.rmi;
18 |
19 | /**
20 | * A template used for defining a proxy class.
21 | * The class file of this class is read by the StubGenerator
22 | * class.
23 | */
24 | public class Sample {
25 | private ObjectImporter importer;
26 | private int objectId;
27 |
28 | public Object forward(Object[] args, int identifier) {
29 | return importer.call(objectId, identifier, args);
30 | }
31 |
32 | public static Object forwardStatic(Object[] args, int identifier)
33 | throws RemoteException
34 | {
35 | throw new RemoteException("cannot call a static method.");
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/javassist/tools/rmi/package.html:
--------------------------------------------------------------------------------
1 |
2 | ObjectImporter
.
13 | See the description of this class first.
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/javassist/tools/web/BadHttpRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Javassist, a Java-bytecode translator toolkit.
3 | * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
4 | *
5 | * The contents of this file are subject to the Mozilla Public License Version
6 | * 1.1 (the "License"); you may not use this file except in compliance with
7 | * the License. Alternatively, the contents of this file may be used under
8 | * the terms of the GNU Lesser General Public License Version 2.1 or later,
9 | * or the Apache License Version 2.0.
10 | *
11 | * Software distributed under the License is distributed on an "AS IS" basis,
12 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 | * for the specific language governing rights and limitations under the
14 | * License.
15 | */
16 |
17 | package javassist.tools.web;
18 |
19 | /**
20 | * Thrown when receiving an invalid HTTP request.
21 | */
22 | public class BadHttpRequest extends Exception {
23 | private Exception e;
24 |
25 | public BadHttpRequest() { e = null; }
26 |
27 | public BadHttpRequest(Exception _e) { e = _e; }
28 |
29 | public String toString() {
30 | if (e == null)
31 | return super.toString();
32 | else
33 | return e.toString();
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/javassist/tools/web/package.html:
--------------------------------------------------------------------------------
1 |
2 | getHandler()
method. If the super class
23 | * has getHandler
, then Proxy
interface is
24 | * available.
25 | *
26 | * @see ProxyFactory
27 | * @see Proxy
28 | */
29 | public interface ProxyObject extends Proxy {
30 | /**
31 | * Sets a handler. It can be used for changing handlers
32 | * during runtime.
33 | */
34 | void setHandler(MethodHandler mi);
35 |
36 | /**
37 | * Get the handler.
38 | * This can be used to access the underlying MethodHandler
39 | * or to serialize it properly.
40 | *
41 | * @see ProxyFactory#getHandler(Proxy)
42 | */
43 | MethodHandler getHandler();
44 | }
45 |
--------------------------------------------------------------------------------
/src/javassist/util/proxy/package.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dynamic proxy (similar to Enhancer
of cglib).
4 | See ProxyFactory
for more details.
5 |
6 |
7 |
--------------------------------------------------------------------------------