Skip to content

Commit 5463d7e

Browse files
committed
Remove unused code from ByteCodeAnalyzer
These lines were identified by Eclipse as unneeded. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent ee73f02 commit 5463d7e

File tree

1 file changed

+0
-163
lines changed

1 file changed

+0
-163
lines changed

src/main/java/org/scijava/annotations/ByteCodeAnalyzer.java

Lines changed: 0 additions & 163 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import java.io.FileInputStream;
3737
import java.io.IOException;
3838
import java.io.InputStream;
39-
import java.util.Iterator;
4039
import java.util.Map;
4140
import java.util.TreeMap;
4241

@@ -68,19 +67,6 @@ private ByteCodeAnalyzer(final byte[] buffer) {
6867
getAllAttributes();
6968
}
7069

71-
private String getPathForClass() {
72-
final int thisOffset = dereferenceOffset(endOffset + 2);
73-
if (getU1(thisOffset) != 7) throw new RuntimeException("Parse error");
74-
return getString(dereferenceOffset(thisOffset + 1));
75-
}
76-
77-
private String getClassNameConstant(final int index) {
78-
final int offset = poolOffsets[index - 1];
79-
if (getU1(offset) != 7) throw new RuntimeException("Constant " + index +
80-
" does not refer to a class");
81-
return getStringConstant(getU2(offset + 1)).replace('/', '.');
82-
}
83-
8470
private String getStringConstant(final int index) {
8571
return getString(poolOffsets[index - 1]);
8672
}
@@ -114,17 +100,6 @@ private double getDoubleConstant(final int index) {
114100
getU4(offset + 5));
115101
}
116102

117-
private boolean containsDebugInfo() {
118-
for (final Method method : methods)
119-
if (method.containsDebugInfo()) return true;
120-
return false;
121-
}
122-
123-
private int dereferenceOffset(final int offset) {
124-
final int index = getU2(offset);
125-
return poolOffsets[index - 1];
126-
}
127-
128103
private void getConstantPoolOffsets() {
129104
final int poolCount = getU2(8) - 1;
130105
poolOffsets = new int[poolCount];
@@ -145,85 +120,6 @@ else if (tag == 5 || tag == 6) {
145120
endOffset = offset;
146121
}
147122

148-
private class ClassNameIterator implements Iterator<String> {
149-
150-
private int index;
151-
152-
private ClassNameIterator() {
153-
index = 0;
154-
findNext();
155-
}
156-
157-
private void findNext() {
158-
while (++index <= poolOffsets.length)
159-
if (getU1(poolOffsets[index - 1]) == 7) break;
160-
}
161-
162-
@Override
163-
public boolean hasNext() {
164-
return index <= poolOffsets.length;
165-
}
166-
167-
@Override
168-
public String next() {
169-
final int current = index;
170-
findNext();
171-
return getClassNameConstant(current);
172-
}
173-
174-
@Override
175-
public void remove() throws UnsupportedOperationException {
176-
throw new UnsupportedOperationException();
177-
}
178-
}
179-
180-
private class InterfaceIterator implements Iterator<String> {
181-
182-
private int index, count;
183-
184-
private InterfaceIterator() {
185-
index = 0;
186-
count = getU2(endOffset + 6);
187-
}
188-
189-
@Override
190-
public boolean hasNext() {
191-
return index < count;
192-
}
193-
194-
@Override
195-
public String next() {
196-
return getClassNameConstant(getU2(endOffset + 8 + index++ * 2));
197-
}
198-
199-
@Override
200-
public void remove() throws UnsupportedOperationException {
201-
throw new UnsupportedOperationException();
202-
}
203-
}
204-
205-
private Iterable<String> getInterfaces() {
206-
return new Iterable<String>() {
207-
208-
@Override
209-
public Iterator<String> iterator() {
210-
return new InterfaceIterator();
211-
}
212-
};
213-
}
214-
215-
private String getSuperclass() {
216-
final int index = getU2(endOffset + 4);
217-
if (index == 0) return null;
218-
return getClassNameConstant(index);
219-
}
220-
221-
private String getSourceFile() {
222-
for (final Attribute attribute : attributes)
223-
if (getStringConstant(attribute.nameIndex).equals("SourceFile")) return getStringConstant(getU2(attribute.attributeEndOffset - 2));
224-
return null;
225-
}
226-
227123
@Override
228124
public String toString() {
229125
String result = "";
@@ -308,15 +204,7 @@ private void getAllInterfaces() {
308204

309205
private class Interface {
310206

311-
private int nameIndex;
312-
313207
private Interface(final int offset) {
314-
nameIndex = getU2(offset);
315-
}
316-
317-
@Override
318-
public String toString() {
319-
return getClassNameConstant(nameIndex);
320208
}
321209
}
322210

@@ -330,33 +218,19 @@ private void getAllFields() {
330218

331219
private class Field {
332220

333-
private int accessFlags, nameIndex, descriptorIndex;
334221
private Attribute[] fieldAttributes;
335222
private int fieldEndOffset;
336223

337224
private Field(final int offset) {
338-
accessFlags = getU2(offset);
339-
nameIndex = getU2(offset + 2);
340-
descriptorIndex = getU2(offset + 4);
341225
fieldAttributes = getAttributes(offset + 6);
342226
fieldEndOffset =
343227
fieldAttributes.length == 0 ? offset + 8
344228
: fieldAttributes[fieldAttributes.length - 1].attributeEndOffset;
345229
}
346230

347-
protected Attribute[] getFieldAttributes() {
348-
return fieldAttributes;
349-
}
350-
351231
protected int getFieldEndOffset() {
352232
return fieldEndOffset;
353233
}
354-
355-
@Override
356-
public String toString() {
357-
return getStringConstant(nameIndex) +
358-
ByteCodeAnalyzer.this.toString(fieldAttributes);
359-
}
360234
}
361235

362236
private void getAllMethods() {
@@ -375,12 +249,6 @@ private class Method extends Field {
375249
private Method(final int offset) {
376250
super(offset);
377251
}
378-
379-
private boolean containsDebugInfo() {
380-
for (final Attribute attribute : getFieldAttributes())
381-
if (attribute.containsDebugInfo()) return true;
382-
return false;
383-
}
384252
}
385253

386254
private void getAllAttributes() {
@@ -414,30 +282,6 @@ private Attribute(final int offset) {
414282
private String getName() {
415283
return getStringConstant(nameIndex);
416284
}
417-
418-
private boolean containsDebugInfo() {
419-
if (!getStringConstant(nameIndex).equals("Code")) return false;
420-
for (final Attribute attribute : getAttributes())
421-
if (attribute.getName().equals("LocalVariableTable")) return true;
422-
return false;
423-
}
424-
425-
private Attribute[] getAttributes() {
426-
final int offset = attributeEndOffset - 6 - attribute.length;
427-
final int codeLength = (int) getU4(offset + 10);
428-
final int exceptionTableLength = getU2(offset + 14 + codeLength);
429-
final int attributesOffset =
430-
offset + 14 + codeLength + 2 + 8 * exceptionTableLength;
431-
return ByteCodeAnalyzer.this.getAttributes(attributesOffset);
432-
}
433-
434-
@Override
435-
public String toString() {
436-
if ("Code".equals(getName())) return "Code" +
437-
ByteCodeAnalyzer.this.toString(getAttributes());
438-
return getName() + " (length " + attribute.length +
439-
")";
440-
}
441285
}
442286

443287
private Map<String, Map<String, Object>> getAnnotations() {
@@ -570,13 +414,6 @@ private static String raw2className(final String rawName) {
570414
return rawName.substring(1, rawName.length() - 1).replace('/', '.');
571415
}
572416

573-
private String toString(final Attribute[] attributes) {
574-
String result = "";
575-
for (final Attribute attribute : attributes)
576-
result += (result.equals("") ? "(" : ";") + attribute;
577-
return result.equals("") ? "" : result + ")";
578-
}
579-
580417
private static byte[] readFile(final File file) throws IOException {
581418
final InputStream in = new FileInputStream(file);
582419
final ByteArrayOutputStream out = new ByteArrayOutputStream();

0 commit comments

Comments
 (0)