From ca01d9877bd3a6872b697ddc6ad4cd60e613cc2d Mon Sep 17 00:00:00 2001 From: Egor Ushakov Date: Mon, 17 Dec 2018 16:30:18 +0300 Subject: [PATCH] IDEA-174243 Decompiler Switch-Enum Sugaring Doesn't Support Obfuscated Code --- .../java/decompiler/modules/decompiler/SwitchHelper.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/SwitchHelper.java b/src/org/jetbrains/java/decompiler/modules/decompiler/SwitchHelper.java index 92ee80e..b49bf39 100644 --- a/src/org/jetbrains/java/decompiler/modules/decompiler/SwitchHelper.java +++ b/src/org/jetbrains/java/decompiler/modules/decompiler/SwitchHelper.java @@ -1,4 +1,4 @@ -// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.java.decompiler.modules.decompiler; import org.jetbrains.java.decompiler.code.CodeConstants; @@ -70,7 +70,10 @@ public class SwitchHelper { private static boolean isEnumArray(Exprent exprent) { if (exprent instanceof ArrayExprent) { Exprent field = ((ArrayExprent)exprent).getArray(); - return field instanceof FieldExprent && ((FieldExprent)field).getName().startsWith("$SwitchMap"); + Exprent index = ((ArrayExprent)exprent).getIndex(); + return field instanceof FieldExprent && + (((FieldExprent)field).getName().startsWith("$SwitchMap") || + (index instanceof InvocationExprent && ((InvocationExprent)index).getName().equals("ordinal"))); } return false; }