From e54dc7d531fd25cd4559fdc9a31f89438972e4ae Mon Sep 17 00:00:00 2001 From: "Egor.Ushakov" Date: Wed, 14 Jan 2015 20:55:30 +0300 Subject: [PATCH] IDEA-126885 Decompiler exception on jdk.nashorn.internal.objects.Global --- .../code/interpreter/InstructionImpact.java | 10 +++++++--- .../decompiler/modules/decompiler/ExprProcessor.java | 12 +++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/org/jetbrains/java/decompiler/code/interpreter/InstructionImpact.java b/src/org/jetbrains/java/decompiler/code/interpreter/InstructionImpact.java index 55d4f5d..553ad84 100644 --- a/src/org/jetbrains/java/decompiler/code/interpreter/InstructionImpact.java +++ b/src/org/jetbrains/java/decompiler/code/interpreter/InstructionImpact.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -19,6 +19,7 @@ import org.jetbrains.java.decompiler.code.CodeConstants; import org.jetbrains.java.decompiler.code.Instruction; 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.struct.consts.PrimitiveConstant; import org.jetbrains.java.decompiler.struct.gen.DataPoint; import org.jetbrains.java.decompiler.struct.gen.MethodDescriptor; @@ -394,8 +395,8 @@ public class InstructionImpact { case CodeConstants.opc_ldc: case CodeConstants.opc_ldc_w: case CodeConstants.opc_ldc2_w: - cn = pool.getPrimitiveConstant(instr.getOperand(0)); - switch (cn.type) { + PooledConstant constant = pool.getConstant(instr.getOperand(0)); + switch (constant.type) { case CodeConstants.CONSTANT_Integer: stack.push(new VarType(CodeConstants.TYPE_INT)); break; @@ -416,6 +417,9 @@ public class InstructionImpact { case CodeConstants.CONSTANT_Class: stack.push(new VarType(CodeConstants.TYPE_OBJECT, 0, "java/lang/Class")); break; + case CodeConstants.CONSTANT_MethodHandle: + stack.push(new VarType(((LinkConstant)constant).descriptor)); + break; } break; case CodeConstants.opc_aload: diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/ExprProcessor.java b/src/org/jetbrains/java/decompiler/modules/decompiler/ExprProcessor.java index fbd579b..292d865 100644 --- a/src/org/jetbrains/java/decompiler/modules/decompiler/ExprProcessor.java +++ b/src/org/jetbrains/java/decompiler/modules/decompiler/ExprProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 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. @@ -362,8 +362,14 @@ public class ExprProcessor implements CodeConstants { case opc_ldc: case opc_ldc_w: case opc_ldc2_w: - PrimitiveConstant cn = pool.getPrimitiveConstant(instr.getOperand(0)); - pushEx(stack, exprlist, new ConstExprent(consts[cn.type - CONSTANT_Integer], cn.value, bytecode_offsets)); + PooledConstant cn = pool.getConstant(instr.getOperand(0)); + if (cn instanceof PrimitiveConstant) { + pushEx(stack, exprlist, new ConstExprent(consts[cn.type - CONSTANT_Integer], ((PrimitiveConstant)cn).value, bytecode_offsets)); + } + else if (cn instanceof LinkConstant) { + //TODO: for now treat Links as Strings + pushEx(stack, exprlist, new ConstExprent(VarType.VARTYPE_STRING, ((LinkConstant)cn).elementname , bytecode_offsets)); + } break; case opc_iload: case opc_lload: