diff --git a/src/org/jetbrains/java/decompiler/struct/StructMember.java b/src/org/jetbrains/java/decompiler/struct/StructMember.java index 6f6d09e..1b6866e 100644 --- a/src/org/jetbrains/java/decompiler/struct/StructMember.java +++ b/src/org/jetbrains/java/decompiler/struct/StructMember.java @@ -84,9 +84,7 @@ public class StructMember { in.discard(length); } else { - byte[] data = in.read(length); - attribute.setInfo(data); - attribute.initContent(pool); + attribute.initContent(in, pool); } return attribute; } diff --git a/src/org/jetbrains/java/decompiler/struct/attr/StructAnnDefaultAttribute.java b/src/org/jetbrains/java/decompiler/struct/attr/StructAnnDefaultAttribute.java index fbad47e..93a660f 100644 --- a/src/org/jetbrains/java/decompiler/struct/attr/StructAnnDefaultAttribute.java +++ b/src/org/jetbrains/java/decompiler/struct/attr/StructAnnDefaultAttribute.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ package org.jetbrains.java.decompiler.struct.attr; import org.jetbrains.java.decompiler.modules.decompiler.exps.Exprent; import org.jetbrains.java.decompiler.struct.consts.ConstantPool; +import org.jetbrains.java.decompiler.util.DataInputFullStream; import java.io.IOException; @@ -25,8 +26,8 @@ public class StructAnnDefaultAttribute extends StructGeneralAttribute { private Exprent defaultValue; @Override - public void initContent(ConstantPool pool) throws IOException { - defaultValue = StructAnnotationAttribute.parseAnnotationElement(stream(), pool); + public void initContent(DataInputFullStream data, ConstantPool pool) throws IOException { + defaultValue = StructAnnotationAttribute.parseAnnotationElement(data, pool); } public Exprent getDefaultValue() { diff --git a/src/org/jetbrains/java/decompiler/struct/attr/StructAnnotationAttribute.java b/src/org/jetbrains/java/decompiler/struct/attr/StructAnnotationAttribute.java index 55c138c..500e63c 100644 --- a/src/org/jetbrains/java/decompiler/struct/attr/StructAnnotationAttribute.java +++ b/src/org/jetbrains/java/decompiler/struct/attr/StructAnnotationAttribute.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ import org.jetbrains.java.decompiler.struct.consts.ConstantPool; import org.jetbrains.java.decompiler.struct.consts.PrimitiveConstant; import org.jetbrains.java.decompiler.struct.gen.FieldDescriptor; import org.jetbrains.java.decompiler.struct.gen.VarType; +import org.jetbrains.java.decompiler.util.DataInputFullStream; import java.io.DataInputStream; import java.io.IOException; @@ -32,8 +33,8 @@ public class StructAnnotationAttribute extends StructGeneralAttribute { private List annotations; @Override - public void initContent(ConstantPool pool) throws IOException { - annotations = parseAnnotations(pool, stream()); + public void initContent(DataInputFullStream data, ConstantPool pool) throws IOException { + annotations = parseAnnotations(pool, data); } public static List parseAnnotations(ConstantPool pool, DataInputStream data) throws IOException { diff --git a/src/org/jetbrains/java/decompiler/struct/attr/StructAnnotationParameterAttribute.java b/src/org/jetbrains/java/decompiler/struct/attr/StructAnnotationParameterAttribute.java index cee629c..4c2f804 100644 --- a/src/org/jetbrains/java/decompiler/struct/attr/StructAnnotationParameterAttribute.java +++ b/src/org/jetbrains/java/decompiler/struct/attr/StructAnnotationParameterAttribute.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,8 +17,8 @@ package org.jetbrains.java.decompiler.struct.attr; import org.jetbrains.java.decompiler.modules.decompiler.exps.AnnotationExprent; import org.jetbrains.java.decompiler.struct.consts.ConstantPool; +import org.jetbrains.java.decompiler.util.DataInputFullStream; -import java.io.DataInputStream; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; @@ -29,9 +29,7 @@ public class StructAnnotationParameterAttribute extends StructGeneralAttribute { private List> paramAnnotations; @Override - public void initContent(ConstantPool pool) throws IOException { - DataInputStream data = stream(); - + public void initContent(DataInputFullStream data, ConstantPool pool) throws IOException { int len = data.readUnsignedByte(); if (len > 0) { paramAnnotations = new ArrayList<>(len); diff --git a/src/org/jetbrains/java/decompiler/struct/attr/StructBootstrapMethodsAttribute.java b/src/org/jetbrains/java/decompiler/struct/attr/StructBootstrapMethodsAttribute.java index f9b5561..e3e203f 100644 --- a/src/org/jetbrains/java/decompiler/struct/attr/StructBootstrapMethodsAttribute.java +++ b/src/org/jetbrains/java/decompiler/struct/attr/StructBootstrapMethodsAttribute.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package org.jetbrains.java.decompiler.struct.attr; import org.jetbrains.java.decompiler.struct.consts.ConstantPool; import org.jetbrains.java.decompiler.struct.consts.LinkConstant; import org.jetbrains.java.decompiler.struct.consts.PooledConstant; +import org.jetbrains.java.decompiler.util.DataInputFullStream; import java.io.DataInputStream; import java.io.IOException; @@ -30,9 +31,7 @@ public class StructBootstrapMethodsAttribute extends StructGeneralAttribute { private final List> methodArguments = new ArrayList<>(); @Override - public void initContent(ConstantPool pool) throws IOException { - DataInputStream data = stream(); - + public void initContent(DataInputFullStream data, ConstantPool pool) throws IOException { int method_number = data.readUnsignedShort(); for (int i = 0; i < method_number; ++i) { diff --git a/src/org/jetbrains/java/decompiler/struct/attr/StructConstantValueAttribute.java b/src/org/jetbrains/java/decompiler/struct/attr/StructConstantValueAttribute.java index 07a5073..9dc636e 100644 --- a/src/org/jetbrains/java/decompiler/struct/attr/StructConstantValueAttribute.java +++ b/src/org/jetbrains/java/decompiler/struct/attr/StructConstantValueAttribute.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package org.jetbrains.java.decompiler.struct.attr; import org.jetbrains.java.decompiler.struct.consts.ConstantPool; +import org.jetbrains.java.decompiler.util.DataInputFullStream; import java.io.IOException; @@ -24,8 +25,8 @@ public class StructConstantValueAttribute extends StructGeneralAttribute { private int index; @Override - public void initContent(ConstantPool pool) throws IOException { - index = stream().readUnsignedShort(); + public void initContent(DataInputFullStream data, ConstantPool pool) throws IOException { + index = data.readUnsignedShort(); } public int getIndex() { diff --git a/src/org/jetbrains/java/decompiler/struct/attr/StructEnclosingMethodAttribute.java b/src/org/jetbrains/java/decompiler/struct/attr/StructEnclosingMethodAttribute.java index c9b9ebb..f869f96 100644 --- a/src/org/jetbrains/java/decompiler/struct/attr/StructEnclosingMethodAttribute.java +++ b/src/org/jetbrains/java/decompiler/struct/attr/StructEnclosingMethodAttribute.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ package org.jetbrains.java.decompiler.struct.attr; import org.jetbrains.java.decompiler.struct.consts.ConstantPool; import org.jetbrains.java.decompiler.struct.consts.LinkConstant; +import org.jetbrains.java.decompiler.util.DataInputFullStream; import java.io.DataInputStream; import java.io.IOException; @@ -28,8 +29,7 @@ public class StructEnclosingMethodAttribute extends StructGeneralAttribute { private String methodDescriptor; @Override - public void initContent(ConstantPool pool) throws IOException { - DataInputStream data = stream(); + public void initContent(DataInputFullStream data, ConstantPool pool) throws IOException { int classIndex = data.readUnsignedShort(); int methodIndex = data.readUnsignedShort(); diff --git a/src/org/jetbrains/java/decompiler/struct/attr/StructExceptionsAttribute.java b/src/org/jetbrains/java/decompiler/struct/attr/StructExceptionsAttribute.java index 946fa3c..0ac54c8 100644 --- a/src/org/jetbrains/java/decompiler/struct/attr/StructExceptionsAttribute.java +++ b/src/org/jetbrains/java/decompiler/struct/attr/StructExceptionsAttribute.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,8 +16,8 @@ package org.jetbrains.java.decompiler.struct.attr; import org.jetbrains.java.decompiler.struct.consts.ConstantPool; +import org.jetbrains.java.decompiler.util.DataInputFullStream; -import java.io.DataInputStream; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; @@ -28,8 +28,7 @@ public class StructExceptionsAttribute extends StructGeneralAttribute { private List throwsExceptions; @Override - public void initContent(ConstantPool pool) throws IOException { - DataInputStream data = stream(); + public void initContent(DataInputFullStream data, ConstantPool pool) throws IOException { int len = data.readUnsignedShort(); if (len > 0) { throwsExceptions = new ArrayList<>(len); diff --git a/src/org/jetbrains/java/decompiler/struct/attr/StructGeneralAttribute.java b/src/org/jetbrains/java/decompiler/struct/attr/StructGeneralAttribute.java index 98a4bae..1e8894a 100644 --- a/src/org/jetbrains/java/decompiler/struct/attr/StructGeneralAttribute.java +++ b/src/org/jetbrains/java/decompiler/struct/attr/StructGeneralAttribute.java @@ -50,7 +50,6 @@ public class StructGeneralAttribute { public static final String ATTRIBUTE_SOURCE_FILE = "SourceFile"; private String name; - private byte[] info; public static StructGeneralAttribute createAttribute(String name) { StructGeneralAttribute attr; @@ -109,15 +108,7 @@ public class StructGeneralAttribute { return attr; } - protected DataInputFullStream stream() { - return new DataInputFullStream(info); - } - - public void initContent(ConstantPool pool) throws IOException { } - - public void setInfo(byte[] info) { - this.info = info; - } + public void initContent(DataInputFullStream data, ConstantPool pool) throws IOException { } public String getName() { return name; diff --git a/src/org/jetbrains/java/decompiler/struct/attr/StructGenericSignatureAttribute.java b/src/org/jetbrains/java/decompiler/struct/attr/StructGenericSignatureAttribute.java index 62c892f..a6a1c2b 100644 --- a/src/org/jetbrains/java/decompiler/struct/attr/StructGenericSignatureAttribute.java +++ b/src/org/jetbrains/java/decompiler/struct/attr/StructGenericSignatureAttribute.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package org.jetbrains.java.decompiler.struct.attr; import org.jetbrains.java.decompiler.struct.consts.ConstantPool; +import org.jetbrains.java.decompiler.util.DataInputFullStream; import java.io.IOException; @@ -24,8 +25,8 @@ public class StructGenericSignatureAttribute extends StructGeneralAttribute { private String signature; @Override - public void initContent(ConstantPool pool) throws IOException { - int index = stream().readUnsignedShort(); + public void initContent(DataInputFullStream data, ConstantPool pool) throws IOException { + int index = data.readUnsignedShort(); signature = pool.getPrimitiveConstant(index).getString(); } diff --git a/src/org/jetbrains/java/decompiler/struct/attr/StructInnerClassesAttribute.java b/src/org/jetbrains/java/decompiler/struct/attr/StructInnerClassesAttribute.java index f576ecf..d55adec 100644 --- a/src/org/jetbrains/java/decompiler/struct/attr/StructInnerClassesAttribute.java +++ b/src/org/jetbrains/java/decompiler/struct/attr/StructInnerClassesAttribute.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,8 +16,8 @@ package org.jetbrains.java.decompiler.struct.attr; import org.jetbrains.java.decompiler.struct.consts.ConstantPool; +import org.jetbrains.java.decompiler.util.DataInputFullStream; -import java.io.DataInputStream; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; @@ -47,9 +47,7 @@ public class StructInnerClassesAttribute extends StructGeneralAttribute { private List entries; @Override - public void initContent(ConstantPool pool) throws IOException { - DataInputStream data = stream(); - + public void initContent(DataInputFullStream data, ConstantPool pool) throws IOException { int len = data.readUnsignedShort(); if (len > 0) { entries = new ArrayList<>(len); diff --git a/src/org/jetbrains/java/decompiler/struct/attr/StructLineNumberTableAttribute.java b/src/org/jetbrains/java/decompiler/struct/attr/StructLineNumberTableAttribute.java index 3cd757b..f21cf97 100644 --- a/src/org/jetbrains/java/decompiler/struct/attr/StructLineNumberTableAttribute.java +++ b/src/org/jetbrains/java/decompiler/struct/attr/StructLineNumberTableAttribute.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,9 +33,7 @@ public class StructLineNumberTableAttribute extends StructGeneralAttribute { private int[] myLineInfo = InterpreterUtil.EMPTY_INT_ARRAY; @Override - public void initContent(ConstantPool pool) throws IOException { - DataInputFullStream data = stream(); - + public void initContent(DataInputFullStream data, ConstantPool pool) throws IOException { int len = data.readUnsignedShort() * 2; if (len > 0) { myLineInfo = new int[len]; diff --git a/src/org/jetbrains/java/decompiler/struct/attr/StructLocalVariableTableAttribute.java b/src/org/jetbrains/java/decompiler/struct/attr/StructLocalVariableTableAttribute.java index b57d0cf..9564814 100644 --- a/src/org/jetbrains/java/decompiler/struct/attr/StructLocalVariableTableAttribute.java +++ b/src/org/jetbrains/java/decompiler/struct/attr/StructLocalVariableTableAttribute.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,9 +38,7 @@ public class StructLocalVariableTableAttribute extends StructGeneralAttribute { private Map mapVarNames = Collections.emptyMap(); @Override - public void initContent(ConstantPool pool) throws IOException { - DataInputFullStream data = stream(); - + public void initContent(DataInputFullStream data, ConstantPool pool) throws IOException { int len = data.readUnsignedShort(); if (len > 0) { mapVarNames = new HashMap<>(len); diff --git a/src/org/jetbrains/java/decompiler/struct/attr/StructLocalVariableTypeTableAttribute.java b/src/org/jetbrains/java/decompiler/struct/attr/StructLocalVariableTypeTableAttribute.java index 6fb2f4b..96bf630 100644 --- a/src/org/jetbrains/java/decompiler/struct/attr/StructLocalVariableTypeTableAttribute.java +++ b/src/org/jetbrains/java/decompiler/struct/attr/StructLocalVariableTypeTableAttribute.java @@ -37,9 +37,7 @@ public class StructLocalVariableTypeTableAttribute extends StructGeneralAttribut private Map mapVarSignatures = Collections.emptyMap(); @Override - public void initContent(ConstantPool pool) throws IOException { - DataInputFullStream data = stream(); - + public void initContent(DataInputFullStream data, ConstantPool pool) throws IOException { int len = data.readUnsignedShort(); if (len > 0) { mapVarSignatures = new HashMap<>(len); diff --git a/src/org/jetbrains/java/decompiler/struct/attr/StructSourceFileAttribute.java b/src/org/jetbrains/java/decompiler/struct/attr/StructSourceFileAttribute.java index 596d30f..85a7dff 100644 --- a/src/org/jetbrains/java/decompiler/struct/attr/StructSourceFileAttribute.java +++ b/src/org/jetbrains/java/decompiler/struct/attr/StructSourceFileAttribute.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package org.jetbrains.java.decompiler.struct.attr; import org.jetbrains.java.decompiler.struct.consts.ConstantPool; +import org.jetbrains.java.decompiler.util.DataInputFullStream; import java.io.IOException; @@ -24,8 +25,8 @@ public class StructSourceFileAttribute extends StructGeneralAttribute { private String fileName; @Override - public void initContent(ConstantPool pool) throws IOException { - int index = stream().readUnsignedShort(); + public void initContent(DataInputFullStream data, ConstantPool pool) throws IOException { + int index = data.readUnsignedShort(); fileName = pool.getPrimitiveConstant(index).getString(); } diff --git a/src/org/jetbrains/java/decompiler/struct/attr/StructTypeAnnotationAttribute.java b/src/org/jetbrains/java/decompiler/struct/attr/StructTypeAnnotationAttribute.java index 1cb9485..e7d7ac0 100644 --- a/src/org/jetbrains/java/decompiler/struct/attr/StructTypeAnnotationAttribute.java +++ b/src/org/jetbrains/java/decompiler/struct/attr/StructTypeAnnotationAttribute.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package org.jetbrains.java.decompiler.struct.attr; import org.jetbrains.java.decompiler.modules.decompiler.exps.AnnotationExprent; import org.jetbrains.java.decompiler.modules.decompiler.exps.TypeAnnotation; import org.jetbrains.java.decompiler.struct.consts.ConstantPool; +import org.jetbrains.java.decompiler.util.DataInputFullStream; import java.io.DataInputStream; import java.io.IOException; @@ -29,9 +30,7 @@ public class StructTypeAnnotationAttribute extends StructGeneralAttribute { private List annotations = Collections.emptyList(); @Override - public void initContent(ConstantPool pool) throws IOException { - DataInputStream data = stream(); - + public void initContent(DataInputFullStream data, ConstantPool pool) throws IOException { int len = data.readUnsignedShort(); if (len > 0) { annotations = new ArrayList<>(len);