summaryrefslogtreecommitdiffstats
path: root/dexdump
diff options
context:
space:
mode:
authorOrion Hodson <oth@google.com>2018-08-24 14:01:14 +0100
committerOrion Hodson <oth@google.com>2018-08-24 15:50:47 +0100
commitfe42d218cf8a3dcaa832651ea62e49ce7384c867 (patch)
treecca4e8ed50410e965363ff7e776de7eda4ebea1a /dexdump
parentd3678dc2531f95ced2d015b800ecd9018ce96c73 (diff)
downloadart-fe42d218cf8a3dcaa832651ea62e49ce7384c867.tar.gz
art-fe42d218cf8a3dcaa832651ea62e49ce7384c867.tar.bz2
art-fe42d218cf8a3dcaa832651ea62e49ce7384c867.zip
dexdump2: Remove conversion from dollar sign to dot
This was presumably added to render nested classes similar to how they are referred to in source, but since a dollar sign ('$') is a valid character in a class name and its use is growing thanks to annotation processors and D8/R8 it only resulted in very wrong names. If you are at the level where you can understand dexdump's output, you can handle dollar signs being present in nested class names. Before: [000234] -..Lambda.Lambda.fcyZxanqBZSHC_nf-noKh-e3bnY.<clinit>:()V 0000: new-instance v0, L-$$Lambda$Lambda$fcyZxanqBZSHC_nf-noKh-e3bnY; // type@0000 0002: invoke-direct {v0}, L-$$Lambda$Lambda$fcyZxanqBZSHC_nf-noKh-e3bnY;.<init>:()V // method@0001 0005: sput-object v0, L-$$Lambda$Lambda$fcyZxanqBZSHC_nf-noKh-e3bnY;.INSTANCE:L-$$Lambda$Lambda$fcyZxanqBZSHC_nf-noKh-e3bnY; // field@0000 0007: return-void After: [000234] -$$Lambda$Lambda$fcyZxanqBZSHC_nf-noKh-e3bnY.<clinit>:()V 0000: new-instance v0, L-$$Lambda$Lambda$fcyZxanqBZSHC_nf-noKh-e3bnY; // type@0000 0002: invoke-direct {v0}, L-$$Lambda$Lambda$fcyZxanqBZSHC_nf-noKh-e3bnY;.<init>:()V // method@0001 0005: sput-object v0, L-$$Lambda$Lambda$fcyZxanqBZSHC_nf-noKh-e3bnY;.INSTANCE:L-$$Lambda$Lambda$fcyZxanqBZSHC_nf-noKh-e3bnY; // field@0000 0007: return-void Bug: 113152880 Test: art/test/dexdump/run-all-tests Test: dalvik/dx/tests/run-all-tests Change-Id: I22a1d3db5b7e0fe6b6c77b5cf8f37e7254bd40f4
Diffstat (limited to 'dexdump')
-rw-r--r--dexdump/dexdump.cc17
1 files changed, 7 insertions, 10 deletions
diff --git a/dexdump/dexdump.cc b/dexdump/dexdump.cc
index f8274e2f9a..e9b64028de 100644
--- a/dexdump/dexdump.cc
+++ b/dexdump/dexdump.cc
@@ -123,8 +123,7 @@ static const char* primitiveTypeLabel(char typeChar) {
/*
* Converts a type descriptor to human-readable "dotted" form. For
* example, "Ljava/lang/String;" becomes "java.lang.String", and
- * "[I" becomes "int[]". Also converts '$' to '.', which means this
- * form can't be converted back to a descriptor.
+ * "[I" becomes "int[]".
*/
static std::unique_ptr<char[]> descriptorToDot(const char* str) {
int targetLen = strlen(str);
@@ -157,7 +156,7 @@ static std::unique_ptr<char[]> descriptorToDot(const char* str) {
int i = 0;
for (; i < targetLen; i++) {
const char ch = str[offset + i];
- newStr[i] = (ch == '/' || ch == '$') ? '.' : ch;
+ newStr[i] = (ch == '/') ? '.' : ch;
} // for
// Add the appropriate number of brackets for arrays.
@@ -171,10 +170,9 @@ static std::unique_ptr<char[]> descriptorToDot(const char* str) {
}
/*
- * Converts the class name portion of a type descriptor to human-readable
- * "dotted" form. For example, "Ljava/lang/String;" becomes "String".
+ * Retrieves the class name portion of a type descriptor.
*/
-static std::unique_ptr<char[]> descriptorClassToDot(const char* str) {
+static std::unique_ptr<char[]> descriptorClassToName(const char* str) {
// Reduce to just the class name prefix.
const char* lastSlash = strrchr(str, '/');
if (lastSlash == nullptr) {
@@ -187,8 +185,7 @@ static std::unique_ptr<char[]> descriptorClassToDot(const char* str) {
const int targetLen = strlen(lastSlash);
std::unique_ptr<char[]> newStr(new char[targetLen]);
for (int i = 0; i < targetLen - 1; i++) {
- const char ch = lastSlash[i];
- newStr[i] = ch == '$' ? '.' : ch;
+ newStr[i] = lastSlash[i];
} // for
newStr[targetLen - 1] = '\0';
return newStr;
@@ -1250,7 +1247,7 @@ static void dumpMethod(const ClassAccessor::Method& method, int i) {
// Method name and prototype.
if (constructor) {
- std::unique_ptr<char[]> dot(descriptorClassToDot(backDescriptor));
+ std::unique_ptr<char[]> dot(descriptorClassToName(backDescriptor));
fprintf(gOutFile, "<constructor name=\"%s\"\n", dot.get());
dot = descriptorToDot(backDescriptor);
fprintf(gOutFile, " type=\"%s\"\n", dot.get());
@@ -1469,7 +1466,7 @@ static void dumpClass(const DexFile* pDexFile, int idx, char** pLastPackage) {
}
fprintf(gOutFile, " Interfaces -\n");
} else {
- std::unique_ptr<char[]> dot(descriptorClassToDot(classDescriptor));
+ std::unique_ptr<char[]> dot(descriptorClassToName(classDescriptor));
fprintf(gOutFile, "<class name=\"%s\"\n", dot.get());
if (superclassDescriptor != nullptr) {
dot = descriptorToDot(superclassDescriptor);