Now --no-debug option works
Bug: 18517951
(cherry picked from commit 5986ee7fbd9dc5697cea5f935a066f44f2699934)
Change-Id: I432c68e840d625b63fafd03a5862ce15295be515
diff --git a/jill/src/com/android/jill/Options.java b/jill/src/com/android/jill/Options.java
index b3828f7..7b41c57 100644
--- a/jill/src/com/android/jill/Options.java
+++ b/jill/src/com/android/jill/Options.java
@@ -56,7 +56,7 @@
protected ContainerType container = ContainerType.ZIP;
@Option(name = "--no-debug", usage = "disable debug info emission")
- protected boolean emitDebugInfo = true;
+ protected boolean disableEmitDebugInfo = false;
public void checkValidity() throws IllegalOptionsException {
if (askForVersion() || askForHelp()) {
@@ -110,7 +110,7 @@
}
public boolean isEmitDebugInfo() {
- return emitDebugInfo;
+ return !disableEmitDebugInfo;
}
@Nonnull
diff --git a/jill/src/com/android/jill/frontend/java/ClassNodeWriter.java b/jill/src/com/android/jill/frontend/java/ClassNodeWriter.java
index 1df263b..2cab6d1 100644
--- a/jill/src/com/android/jill/frontend/java/ClassNodeWriter.java
+++ b/jill/src/com/android/jill/frontend/java/ClassNodeWriter.java
@@ -16,6 +16,7 @@
package com.android.jill.frontend.java;
+import com.android.jill.Options;
import com.android.jill.backend.jayce.JayceWriter;
import com.android.jill.backend.jayce.Token;
@@ -45,10 +46,15 @@
private static final int ORDINAL_UNKNOWN = -1;
+ @Nonnull
+ private final Options options;
+
public ClassNodeWriter(@Nonnull JayceWriter writer,
- @Nonnull SourceInfoWriter sourceInfoWriter) {
+ @Nonnull SourceInfoWriter sourceInfoWriter,
+ @Nonnull Options options) {
super(writer, sourceInfoWriter);
annotWriter = new AnnotationWriter(writer, sourceInfoWriter);
+ this.options = options;
}
public void write(@Nonnull ClassNode cn) throws IOException {
@@ -282,7 +288,7 @@
writer.writeOpenNodeList();
for (MethodNode mn : cn.methods) {
- new MethodBodyWriter(writer, annotWriter, cn, mn, sourceInfoWriter).write();
+ new MethodBodyWriter(writer, annotWriter, cn, mn, sourceInfoWriter, options).write();
}
writer.writeCloseNodeList();
}
@@ -291,7 +297,7 @@
writer.writeOpenNodeList();
for (MethodNode mn : cn.methods) {
- new MethodBodyWriter(writer, annotWriter, cn, mn, sourceInfoWriter).write();
+ new MethodBodyWriter(writer, annotWriter, cn, mn, sourceInfoWriter, options).write();
}
writer.writeCloseNodeList();
}
diff --git a/jill/src/com/android/jill/frontend/java/JavaTransformer.java b/jill/src/com/android/jill/frontend/java/JavaTransformer.java
index 04b610b..9f56d00 100644
--- a/jill/src/com/android/jill/frontend/java/JavaTransformer.java
+++ b/jill/src/com/android/jill/frontend/java/JavaTransformer.java
@@ -352,7 +352,7 @@
JayceWriter writer = createWriter(os);
ClassNodeWriter asm2jayce =
- new ClassNodeWriter(writer, new SourceInfoWriter(writer));
+ new ClassNodeWriter(writer, new SourceInfoWriter(writer), options);
asm2jayce.write(cn);
diff --git a/jill/src/com/android/jill/frontend/java/MethodBodyWriter.java b/jill/src/com/android/jill/frontend/java/MethodBodyWriter.java
index efe9285..46f5e92 100644
--- a/jill/src/com/android/jill/frontend/java/MethodBodyWriter.java
+++ b/jill/src/com/android/jill/frontend/java/MethodBodyWriter.java
@@ -17,6 +17,7 @@
package com.android.jill.frontend.java;
import com.android.jill.JillException;
+import com.android.jill.Options;
import com.android.jill.backend.jayce.JayceWriter;
import com.android.jill.backend.jayce.Token;
import com.android.jill.frontend.java.analyzer.JillAnalyzer;
@@ -177,15 +178,20 @@
private int endLine = -1;
@Nonnull
+ private final Options options;
+
+ @Nonnull
private final Map<TryCatchBlockNode, Variable> catchBlockToCatchedVariable =
new HashMap<TryCatchBlockNode, Variable>();
public MethodBodyWriter(@Nonnull JayceWriter writer,
@Nonnull AnnotationWriter annotWriter,
@Nonnull ClassNode cn, @Nonnull MethodNode mn,
- @Nonnull SourceInfoWriter sourceInfoWriter) {
+ @Nonnull SourceInfoWriter sourceInfoWriter,
+ @Nonnull Options options) {
super(writer, sourceInfoWriter);
this.annotWriter = annotWriter;
+ this.options = options;
currentClass = cn;
currentMethod = getMethodWithoutJSR(mn);
@@ -2285,7 +2291,7 @@
@CheckForNull
private LocalVariableNode getLocalVariableNode(@Nonnegative int localIdx) {
assert localIdx >= 0;
- if (currentMethod.localVariables != null) {
+ if (options.isEmitDebugInfo() && currentMethod.localVariables != null) {
for (LocalVariableNode lvn : currentMethod.localVariables) {
int startScope = currentMethod.instructions.indexOf(lvn.start) - 1;
int endScope = currentMethod.instructions.indexOf(lvn.end);