mirror of
https://github.com/Guardsquare/proguard.git
synced 2026-03-13 09:50:34 +08:00
Fix string comparison in MappingPrinter and LineNumberLinearizer
This commit is contained in:
committed by
Oberon Swings
parent
b9cf51b119
commit
8a7e846ec7
@@ -24,14 +24,24 @@ import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import proguard.classfile.*;
|
||||
import proguard.classfile.attribute.*;
|
||||
import proguard.classfile.Clazz;
|
||||
import proguard.classfile.JavaTypeConstants;
|
||||
import proguard.classfile.Method;
|
||||
import proguard.classfile.ProgramClass;
|
||||
import proguard.classfile.ProgramField;
|
||||
import proguard.classfile.ProgramMethod;
|
||||
import proguard.classfile.attribute.Attribute;
|
||||
import proguard.classfile.attribute.CodeAttribute;
|
||||
import proguard.classfile.attribute.LineNumberInfo;
|
||||
import proguard.classfile.attribute.LineNumberTableAttribute;
|
||||
import proguard.classfile.attribute.SourceFileAttribute;
|
||||
import proguard.classfile.attribute.visitor.AttributeVisitor;
|
||||
import proguard.classfile.util.*;
|
||||
import proguard.classfile.visitor.*;
|
||||
import proguard.classfile.util.ClassUtil;
|
||||
import proguard.classfile.visitor.ClassVisitor;
|
||||
import proguard.classfile.visitor.MemberVisitor;
|
||||
import proguard.optimize.peephole.LineNumberLinearizer;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Stack;
|
||||
|
||||
|
||||
@@ -196,7 +206,7 @@ implements ClassVisitor,
|
||||
|
||||
// Print out the line numbers of any inlined methods and their
|
||||
// enclosing methods.
|
||||
Stack enclosingLineNumbers = new Stack();
|
||||
Stack<LineNumberInfo> enclosingLineNumbers = new Stack<>();
|
||||
|
||||
LineNumberInfo previousInfo = new LineNumberInfo(0, 0);
|
||||
|
||||
@@ -209,7 +219,7 @@ implements ClassVisitor,
|
||||
String previousSource = previousInfo.getSource();
|
||||
String source = info.getSource();
|
||||
// Source can be null for injected code.
|
||||
if (source != null && source != previousSource)
|
||||
if (source != null && !source.equals(previousSource))
|
||||
{
|
||||
// Are we entering or exiting the block?
|
||||
int previousLineNumber = previousInfo.u2lineNumber;
|
||||
@@ -263,12 +273,12 @@ implements ClassVisitor,
|
||||
* Prints out the mapping of the specified inlined methods and its
|
||||
* enclosing methods.
|
||||
*/
|
||||
private void printInlinedMethodMapping(String className,
|
||||
String methodName,
|
||||
String methodDescriptor,
|
||||
LineNumberInfo inlinedInfo,
|
||||
Stack enclosingLineNumbers,
|
||||
String obfuscatedMethodName)
|
||||
private void printInlinedMethodMapping(String className,
|
||||
String methodName,
|
||||
String methodDescriptor,
|
||||
LineNumberInfo inlinedInfo,
|
||||
Stack<LineNumberInfo> enclosingLineNumbers,
|
||||
String obfuscatedMethodName)
|
||||
{
|
||||
String source = inlinedInfo.getSource();
|
||||
|
||||
@@ -307,8 +317,7 @@ implements ClassVisitor,
|
||||
// methods.
|
||||
for (int enclosingIndex = enclosingLineNumbers.size()-1; enclosingIndex >= 0; enclosingIndex--)
|
||||
{
|
||||
LineNumberInfo enclosingInfo =
|
||||
(LineNumberInfo)enclosingLineNumbers.get(enclosingIndex);
|
||||
LineNumberInfo enclosingInfo = enclosingLineNumbers.get(enclosingIndex);
|
||||
|
||||
printEnclosingMethodMapping(className,
|
||||
methodName,
|
||||
|
||||
@@ -23,13 +23,25 @@ package proguard.optimize.peephole;
|
||||
import proguard.AppView;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import proguard.classfile.*;
|
||||
import proguard.classfile.attribute.*;
|
||||
import proguard.classfile.attribute.visitor.*;
|
||||
import proguard.classfile.visitor.*;
|
||||
import proguard.classfile.Clazz;
|
||||
import proguard.classfile.Method;
|
||||
import proguard.classfile.ProgramClass;
|
||||
import proguard.classfile.ProgramMethod;
|
||||
import proguard.classfile.attribute.Attribute;
|
||||
import proguard.classfile.attribute.CodeAttribute;
|
||||
import proguard.classfile.attribute.ExtendedLineNumberInfo;
|
||||
import proguard.classfile.attribute.LineNumberInfo;
|
||||
import proguard.classfile.attribute.LineNumberTableAttribute;
|
||||
import proguard.classfile.attribute.visitor.AllAttributeVisitor;
|
||||
import proguard.classfile.attribute.visitor.AllLineNumberInfoVisitor;
|
||||
import proguard.classfile.attribute.visitor.AttributeVisitor;
|
||||
import proguard.classfile.attribute.visitor.LineNumberInfoVisitor;
|
||||
import proguard.classfile.attribute.visitor.LineNumberRangeFinder;
|
||||
import proguard.classfile.visitor.ClassVisitor;
|
||||
import proguard.classfile.visitor.MemberVisitor;
|
||||
import proguard.pass.Pass;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Stack;
|
||||
|
||||
/**
|
||||
* This pass disambiguates line numbers, in the classes that it
|
||||
@@ -53,10 +65,10 @@ implements Pass,
|
||||
private static final int SHIFT_ROUNDING_LIMIT = 50000;
|
||||
|
||||
|
||||
private Stack enclosingLineNumbers = new Stack();
|
||||
private LineNumberInfo previousLineNumberInfo;
|
||||
private int highestUsedLineNumber;
|
||||
private int currentLineNumberShift;
|
||||
private final Stack<MyLineNumberBlock> enclosingLineNumbers = new Stack<>();
|
||||
private LineNumberInfo previousLineNumberInfo;
|
||||
private int highestUsedLineNumber;
|
||||
private int currentLineNumberShift;
|
||||
|
||||
|
||||
/**
|
||||
@@ -155,7 +167,7 @@ implements Pass,
|
||||
|
||||
// Are we entering or exiting a new inlined block?
|
||||
if (previousLineNumberInfo == null ||
|
||||
previousLineNumberInfo.getSource() != source)
|
||||
!source.equals(previousLineNumberInfo.getSource()))
|
||||
{
|
||||
// Are we entering a new inlined block?
|
||||
if (lineNumber != MethodInliner.INLINED_METHOD_END_LINE_NUMBER)
|
||||
@@ -206,8 +218,7 @@ implements Pass,
|
||||
else
|
||||
{
|
||||
// Pop information about the enclosing line number.
|
||||
MyLineNumberBlock lineNumberBlock =
|
||||
(MyLineNumberBlock)enclosingLineNumbers.pop();
|
||||
MyLineNumberBlock lineNumberBlock = enclosingLineNumbers.pop();
|
||||
|
||||
// Set this end of the block to the line at which it was
|
||||
// inlined.
|
||||
|
||||
Reference in New Issue
Block a user