--- old/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/MethodGenerator.java 2019-07-10 22:50:16.861068434 +0000 +++ new/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/MethodGenerator.java 2019-07-10 22:50:16.486059468 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -75,7 +75,7 @@ /** * @author Jacek Ambroziak * @author Santiago Pericas-Geertsen - * @LastModified: Nov 2017 + * @LastModified: July 2019 */ public class MethodGenerator extends MethodGen implements com.sun.org.apache.xalan.internal.xsltc.compiler.Constants { @@ -207,7 +207,7 @@ _nextNode = new INVOKEINTERFACE(index, 1); _slotAllocator = new SlotAllocator(); - _slotAllocator.initialize(getLocalVariableRegistry().getLocals(false)); + _slotAllocator.initialize(getLocalVariableRegistry().getLocals()); _allocatorInit = true; } @@ -445,7 +445,7 @@ } } } else { - _nameToLVGMap.remove(lvg); + _nameToLVGMap.remove(lvg.getName()); } } @@ -480,55 +480,31 @@ } /** - *

Gets all {@link LocalVariableGen} objects for this method.

- *

When the includeRemoved argument has the value - * false, this method replaces uses of - * {@link MethodGen#getLocalVariables()} which has + * Gets all {@link LocalVariableGen} objects. + * This method replaces {@link MethodGen#getLocalVariables()} which has * a side-effect of setting the start and end range for any - * LocalVariableGen if either was null. That + * {@code LocalVariableGen} if either was {@code null}. That * side-effect causes problems for outlining of code in XSLTC. - * @param includeRemoved Specifies whether all local variables ever - * declared should be returned (true) or only those not - * removed (false) - * @return an array of LocalVariableGen containing all the + * + * @return an array of {@code LocalVariableGen} containing all the * local variables */ @SuppressWarnings("unchecked") - protected LocalVariableGen[] getLocals(boolean includeRemoved) { + private LocalVariableGen[] getLocals() { LocalVariableGen[] locals = null; List allVarsEverDeclared = new ArrayList<>(); - if (includeRemoved) { - int slotCount = allVarsEverDeclared.size(); - - for (int i = 0; i < slotCount; i++) { - Object slotEntries = _variables.get(i); - if (slotEntries != null) { - if (slotEntries instanceof ArrayList) { - List slotList = - (List)slotEntries; - - for (int j = 0; j < slotList.size(); j++) { - allVarsEverDeclared.add(slotList.get(i)); - } - } else { - allVarsEverDeclared.add((LocalVariableGen)slotEntries); - } - } - } - } else { - for (Map.Entry nameVarsPair : _nameToLVGMap.entrySet()) { - Object vars = nameVarsPair.getValue(); - if (vars != null) { - if (vars instanceof ArrayList) { - List varsList = - (List) vars; - for (int i = 0; i < varsList.size(); i++) { - allVarsEverDeclared.add(varsList.get(i)); - } - } else { - allVarsEverDeclared.add((LocalVariableGen)vars); + for (Map.Entry nameVarsPair : _nameToLVGMap.entrySet()) { + Object vars = nameVarsPair.getValue(); + if (vars != null) { + if (vars instanceof ArrayList) { + List varsList = + (List) vars; + for (int i = 0; i < varsList.size(); i++) { + allVarsEverDeclared.add(varsList.get(i)); } + } else { + allVarsEverDeclared.add((LocalVariableGen)vars); } } }