101
102 public byte[] bytecodes(String className, String methodName, int location) {
103 return injection;
104 }
105 }
106
107 class IndexedInjector implements TrackerInjector {
108 int counter = 0;
109 int tracker;
110 List<Info> infoList = new ArrayList<>();
111
112 public int stackSize(int currentSize) {
113 return currentSize + 1;
114 }
115
116 public void reinit(int tracker) {
117 this.tracker = tracker;
118 }
119
120 void dump(File outDir, String filename) throws IOException {
121 FileOutputStream fileOut = new FileOutputStream(new File(outDir, filename));
122 DataOutputStream dataOut = new DataOutputStream(fileOut);
123
124 String currentClassName = null;
125
126 dataOut.writeInt(infoList.size());
127 for (Iterator<Info> it = infoList.iterator(); it.hasNext(); ) {
128 Info info = it.next();
129 if (!info.className.equals(currentClassName)) {
130 dataOut.writeInt(123456); // class name marker
131 currentClassName = info.className;
132 dataOut.writeUTF(currentClassName);
133 }
134 dataOut.writeInt(info.location);
135 dataOut.writeUTF(info.methodName);
136 }
137 dataOut.close();
138 }
139
140 public byte[] bytecodes(String className, String methodName, int location) {
141 byte[] injection = new byte[6];
142 int injectedIndex = options.fixedIndex != 0? options.fixedIndex : ++counter;
143 infoList.add(new Info(counter, className, methodName, location));
144 injection[0] = (byte)opc_sipush;
145 injection[1] = (byte)(injectedIndex >> 8);
146 injection[2] = (byte)injectedIndex;
147 injection[3] = (byte)opc_invokestatic;
148 injection[4] = (byte)(tracker >> 8);
149 injection[5] = (byte)tracker;
150 return injection;
151 }
152 }
153
154 Inject(String className, ClassReaderWriter c, boolean isSystem, Options options) {
155 this.className = className;
156 this.c = c;
157 this.isSystem = isSystem;
|
101
102 public byte[] bytecodes(String className, String methodName, int location) {
103 return injection;
104 }
105 }
106
107 class IndexedInjector implements TrackerInjector {
108 int counter = 0;
109 int tracker;
110 List<Info> infoList = new ArrayList<>();
111
112 public int stackSize(int currentSize) {
113 return currentSize + 1;
114 }
115
116 public void reinit(int tracker) {
117 this.tracker = tracker;
118 }
119
120 void dump(File outDir, String filename) throws IOException {
121 try (FileOutputStream fileOut =
122 new FileOutputStream(new File(outDir, filename));
123 DataOutputStream dataOut = new DataOutputStream(fileOut))
124 {
125 String currentClassName = null;
126
127 dataOut.writeInt(infoList.size());
128 for (Iterator<Info> it = infoList.iterator(); it.hasNext(); ) {
129 Info info = it.next();
130 if (!info.className.equals(currentClassName)) {
131 dataOut.writeInt(123456); // class name marker
132 currentClassName = info.className;
133 dataOut.writeUTF(currentClassName);
134 }
135 dataOut.writeInt(info.location);
136 dataOut.writeUTF(info.methodName);
137 }
138 }
139 }
140
141 public byte[] bytecodes(String className, String methodName, int location) {
142 byte[] injection = new byte[6];
143 int injectedIndex = options.fixedIndex != 0? options.fixedIndex : ++counter;
144 infoList.add(new Info(counter, className, methodName, location));
145 injection[0] = (byte)opc_sipush;
146 injection[1] = (byte)(injectedIndex >> 8);
147 injection[2] = (byte)injectedIndex;
148 injection[3] = (byte)opc_invokestatic;
149 injection[4] = (byte)(tracker >> 8);
150 injection[5] = (byte)tracker;
151 return injection;
152 }
153 }
154
155 Inject(String className, ClassReaderWriter c, boolean isSystem, Options options) {
156 this.className = className;
157 this.c = c;
158 this.isSystem = isSystem;
|