CODETOOLS-7902549 Asmtools processes Runtime{In}VisibleTypeAnnotations incorrectly
CODETOOLS-7902563 jdec: wrong interpretation of the module_name_index in the Module attribute Codebase, build updated to support JDK 8
This commit is contained in:
parent
187e90eb4a
commit
a136ef54ee
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!--
|
<!--
|
||||||
Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
|
Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
|
||||||
This code is free software; you can redistribute it and/or modify it
|
This code is free software; you can redistribute it and/or modify it
|
||||||
@ -251,8 +251,8 @@ Other values for TARGET are:
|
|||||||
<target name="compileClasses" depends="prepare">
|
<target name="compileClasses" depends="prepare">
|
||||||
<mkdir dir="${build.classes.dir}"/>
|
<mkdir dir="${build.classes.dir}"/>
|
||||||
<javac fork="true"
|
<javac fork="true"
|
||||||
target="9"
|
target="1.8"
|
||||||
source="9"
|
source="1.8"
|
||||||
srcdir="${build.src.classes.dir}"
|
srcdir="${build.src.classes.dir}"
|
||||||
destdir="${build.classes.dir}"
|
destdir="${build.classes.dir}"
|
||||||
debug="${javac.debug}"
|
debug="${javac.debug}"
|
||||||
|
@ -27,5 +27,5 @@ PRODUCT_NAME = asmtools
|
|||||||
PRODUCT_JAR_NAME = asmtools.jar
|
PRODUCT_JAR_NAME = asmtools.jar
|
||||||
PRODUCT_VERSION = 7.0
|
PRODUCT_VERSION = 7.0
|
||||||
PRODUCT_MILESTONE = beta
|
PRODUCT_MILESTONE = beta
|
||||||
PRODUCT_BUILDNUMBER = b01
|
PRODUCT_BUILDNUMBER = b02
|
||||||
PRODUCT_NAME_LONG = Java Assembler Tools
|
PRODUCT_NAME_LONG = Java Assembler Tools
|
||||||
|
@ -48,7 +48,6 @@ class FieldData extends MemberData {
|
|||||||
return nape;
|
return nape;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void SetValue(Argument value_cpx) {
|
public void SetValue(Argument value_cpx) {
|
||||||
initValue = new CPXAttr(cls, AttrTag.ATT_ConstantValue.parsekey(),
|
initValue = new CPXAttr(cls, AttrTag.ATT_ConstantValue.parsekey(),
|
||||||
value_cpx);
|
value_cpx);
|
||||||
@ -56,17 +55,7 @@ class FieldData extends MemberData {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected DataVector getAttrVector() {
|
protected DataVector getAttrVector() {
|
||||||
return getDataVector( new ArrayList<>(){{
|
return getDataVector(initValue, syntheticAttr, deprecatedAttr);
|
||||||
if (initValue != null) {
|
|
||||||
add(initValue);
|
|
||||||
};
|
|
||||||
if (syntheticAttr != null) {
|
|
||||||
add(syntheticAttr);
|
|
||||||
}
|
|
||||||
if (deprecatedAttr != null) {
|
|
||||||
add(deprecatedAttr);
|
|
||||||
}
|
|
||||||
}} );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void write(CheckedDataOutputStream out) throws IOException, Parser.CompilerError {
|
public void write(CheckedDataOutputStream out) throws IOException, Parser.CompilerError {
|
||||||
|
@ -65,6 +65,10 @@ public class Main extends Tool {
|
|||||||
error( i18n.getString("jasm.error.cannot_read", fname));
|
error( i18n.getString("jasm.error.cannot_read", fname));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Main(PrintStream out, String program) {
|
||||||
|
this(new PrintWriter(out), program);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void usage() {
|
public void usage() {
|
||||||
println(i18n.getString("jasm.usage"));
|
println(i18n.getString("jasm.usage"));
|
||||||
|
@ -75,11 +75,14 @@ abstract public class MemberData {
|
|||||||
|
|
||||||
protected abstract DataVector getAttrVector();
|
protected abstract DataVector getAttrVector();
|
||||||
|
|
||||||
protected final DataVector getDataVector(List<Data> extraAttrs) {
|
protected final DataVector getDataVector(Data... extraAttrs) {
|
||||||
DataVector attrs = new DataVector();
|
DataVector attrs = new DataVector();
|
||||||
if (extraAttrs != null) {
|
for( Data extra : extraAttrs ) {
|
||||||
attrs.addAll(extraAttrs);
|
if (extra != null) {
|
||||||
|
attrs.add(extra);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
// common set for [ FieldData, MethodData, RecordData ]
|
||||||
if (annotAttrVis != null) {
|
if (annotAttrVis != null) {
|
||||||
attrs.add(annotAttrVis);
|
attrs.add(annotAttrVis);
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ import org.openjdk.asmtools.jasm.Tables.AttrTag;
|
|||||||
import org.openjdk.asmtools.jasm.ConstantPool.ConstCell;
|
import org.openjdk.asmtools.jasm.ConstantPool.ConstCell;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -206,35 +207,13 @@ class MethodData extends MemberData {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected DataVector getAttrVector() {
|
protected DataVector getAttrVector() {
|
||||||
DataVector dv = getDataVector( new ArrayList<>(){{
|
DataVector dv = getDataVector( exceptions, syntheticAttr, deprecatedAttr, paramNames, code, defaultAnnot);
|
||||||
if (exceptions != null) {
|
|
||||||
add(exceptions);
|
|
||||||
}
|
|
||||||
if (syntheticAttr != null) {
|
|
||||||
add(syntheticAttr);
|
|
||||||
}
|
|
||||||
if (deprecatedAttr != null) {
|
|
||||||
add(deprecatedAttr);
|
|
||||||
}
|
|
||||||
if (paramNames != null) {
|
|
||||||
add(paramNames);
|
|
||||||
}
|
|
||||||
if (code != null) {
|
|
||||||
add(code);
|
|
||||||
}
|
|
||||||
if (defaultAnnot != null) {
|
|
||||||
add(defaultAnnot);
|
|
||||||
}
|
|
||||||
}});
|
|
||||||
dv.addAll(
|
|
||||||
new ArrayList<>() {{
|
|
||||||
if (pannotAttrVis != null) {
|
if (pannotAttrVis != null) {
|
||||||
add(pannotAttrVis);
|
dv.add(pannotAttrVis);
|
||||||
}
|
}
|
||||||
if (pannotAttrInv != null) {
|
if (pannotAttrInv != null) {
|
||||||
add(pannotAttrInv);
|
dv.add(pannotAttrInv);
|
||||||
}
|
}
|
||||||
}});
|
|
||||||
return dv;
|
return dv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -22,6 +22,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.openjdk.asmtools.jasm;
|
package org.openjdk.asmtools.jasm;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -417,10 +419,10 @@ public class Modifiers {
|
|||||||
sb.append(Token.ABSTRACT.parsekey() + " ");
|
sb.append(Token.ABSTRACT.parsekey() + " ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( Set.of(CF_Context.CTX_CLASS, CF_Context.CTX_INNERCLASS, CF_Context.CTX_FIELD).contains(context) && isFinal(mod)) {
|
if ( context.isOneOf(CF_Context.CTX_CLASS, CF_Context.CTX_INNERCLASS, CF_Context.CTX_FIELD) && isFinal(mod)) {
|
||||||
sb.append(Token.FINAL.parsekey() + " ");
|
sb.append(Token.FINAL.parsekey() + " ");
|
||||||
}
|
}
|
||||||
if (Set.of(CF_Context.CTX_CLASS, CF_Context.CTX_INNERCLASS).contains(context) && isInterface(mod)) {
|
if (context.isOneOf(CF_Context.CTX_CLASS, CF_Context.CTX_INNERCLASS) && isInterface(mod)) {
|
||||||
if (isAnnotation(mod)) {
|
if (isAnnotation(mod)) {
|
||||||
sb.append(Token.ANNOTATION_ACCESS.parsekey() + " ");
|
sb.append(Token.ANNOTATION_ACCESS.parsekey() + " ");
|
||||||
}
|
}
|
||||||
@ -438,7 +440,7 @@ public class Modifiers {
|
|||||||
if (isEnum(mod)) {
|
if (isEnum(mod)) {
|
||||||
sb.append(Token.ENUM.parsekey() + " ");
|
sb.append(Token.ENUM.parsekey() + " ");
|
||||||
}
|
}
|
||||||
if (Set.of(CF_Context.CTX_METHOD, CF_Context.CTX_FIELD).contains(context) && isMandated(mod)) {
|
if (context.isOneOf(CF_Context.CTX_METHOD, CF_Context.CTX_FIELD) && isMandated(mod)) {
|
||||||
sb.append(Token.MANDATED.parsekey() + " ");
|
sb.append(Token.MANDATED.parsekey() + " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,11 +85,7 @@ public class RecordData extends AttrData {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected DataVector getAttrVector() {
|
protected DataVector getAttrVector() {
|
||||||
return getDataVector(new ArrayList<>() {{
|
return getDataVector(signature);
|
||||||
if (signature != null) {
|
|
||||||
add(signature);
|
|
||||||
}
|
|
||||||
}});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void write(CheckedDataOutputStream out) throws IOException, Parser.CompilerError {
|
public void write(CheckedDataOutputStream out) throws IOException, Parser.CompilerError {
|
||||||
|
@ -644,7 +644,7 @@ public class Tables {
|
|||||||
/**
|
/**
|
||||||
* CF_Context enums
|
* CF_Context enums
|
||||||
*/
|
*/
|
||||||
static public enum CF_Context {
|
public enum CF_Context {
|
||||||
|
|
||||||
CTX_CLASS (0, "class"),
|
CTX_CLASS (0, "class"),
|
||||||
CTX_FIELD (1, "field"),
|
CTX_FIELD (1, "field"),
|
||||||
@ -660,6 +660,15 @@ public class Tables {
|
|||||||
printval = print;
|
printval = print;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean isOneOf(CF_Context... items) {
|
||||||
|
for(CF_Context item : items) {
|
||||||
|
if(item.value == value) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public int val() {
|
public int val() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
@ -26,10 +26,7 @@ import org.openjdk.asmtools.common.Tool;
|
|||||||
import org.openjdk.asmtools.util.I18NResourceBundle;
|
import org.openjdk.asmtools.util.I18NResourceBundle;
|
||||||
import org.openjdk.asmtools.util.ProductInfo;
|
import org.openjdk.asmtools.util.ProductInfo;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.*;
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
@ -49,6 +46,10 @@ public class Main extends Tool {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Main(PrintStream out, String program) {
|
||||||
|
this(new PrintWriter(out), program);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void usage() {
|
public void usage() {
|
||||||
println(i18n.getString("jcoder.usage"));
|
println(i18n.getString("jcoder.usage"));
|
||||||
|
@ -43,7 +43,7 @@ jcoder.error.fatal_error=fatal error
|
|||||||
jcoder.error.fatal_exception=fatal exception
|
jcoder.error.fatal_exception=fatal exception
|
||||||
|
|
||||||
err.eof.in.comment=Comment not terminated at end of input.
|
err.eof.in.comment=Comment not terminated at end of input.
|
||||||
err.invalid.number=Invalid character '{0}' in number.
|
err.invalid.number=Invalid character '%s' in number.
|
||||||
#err.invalid.octal.number=Invalid character in octal number.
|
#err.invalid.octal.number=Invalid character in octal number.
|
||||||
err.overflow=Numeric overflow.
|
err.overflow=Numeric overflow.
|
||||||
#err.float.format=Invalid floating point format.
|
#err.float.format=Invalid floating point format.
|
||||||
|
@ -503,7 +503,7 @@ class ClassData {
|
|||||||
}
|
}
|
||||||
// [4.7.20.2]
|
// [4.7.20.2]
|
||||||
int path_length = in.readUnsignedByte(); // type_path { u1 path_length; ...}
|
int path_length = in.readUnsignedByte(); // type_path { u1 path_length; ...}
|
||||||
startArrayCmt(path_length, "type_paths");
|
startArrayCmtB(path_length, "type_paths");
|
||||||
try {
|
try {
|
||||||
for (int i = 0; i < path_length; i++) {
|
for (int i = 0; i < path_length; i++) {
|
||||||
// print the type_path elements
|
// print the type_path elements
|
||||||
@ -1078,7 +1078,13 @@ class ClassData {
|
|||||||
private void decodeModule(DataInputStream in) throws IOException {
|
private void decodeModule(DataInputStream in) throws IOException {
|
||||||
//u2 module_name_index
|
//u2 module_name_index
|
||||||
int index = in.readUnsignedShort();
|
int index = in.readUnsignedShort();
|
||||||
printUtf8InfoIndex((Integer)cpool[index], "name_index");
|
entityName = (String) cpool[(Integer) cpool[index]];
|
||||||
|
out_print("#" + index + "; // ");
|
||||||
|
if (printDetails) {
|
||||||
|
out.println(String.format("%-16s","name_index") + " : " + entityName);
|
||||||
|
} else {
|
||||||
|
out.println("name_index");
|
||||||
|
}
|
||||||
|
|
||||||
// u2 module_flags
|
// u2 module_flags
|
||||||
int moduleFlags = in.readUnsignedShort();
|
int moduleFlags = in.readUnsignedShort();
|
||||||
|
@ -28,6 +28,7 @@ import org.openjdk.asmtools.util.I18NResourceBundle;
|
|||||||
import org.openjdk.asmtools.util.ProductInfo;
|
import org.openjdk.asmtools.util.ProductInfo;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
|
import java.io.PrintStream;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
@ -47,6 +48,10 @@ public class Main extends Tool {
|
|||||||
error( i18n.getString("jdec.error.cannot_read", fname));
|
error( i18n.getString("jdec.error.cannot_read", fname));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Main(PrintStream out, String program) {
|
||||||
|
this(new PrintWriter(out), new PrintWriter(System.err), program);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void usage() {
|
public void usage() {
|
||||||
println(i18n.getString("jdec.usage"));
|
println(i18n.getString("jdec.usage"));
|
||||||
|
@ -27,6 +27,7 @@ import org.openjdk.asmtools.util.I18NResourceBundle;
|
|||||||
import org.openjdk.asmtools.util.ProductInfo;
|
import org.openjdk.asmtools.util.ProductInfo;
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
|
import java.io.PrintStream;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
@ -48,6 +49,10 @@ public class Main extends Tool {
|
|||||||
printCannotReadMsg = (fname) -> error( i18n.getString("jdis.error.cannot_read", fname));
|
printCannotReadMsg = (fname) -> error( i18n.getString("jdis.error.cannot_read", fname));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Main(PrintStream out, String program) {
|
||||||
|
this(new PrintWriter(out), new PrintWriter(System.err), program);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void usage() {
|
public void usage() {
|
||||||
println(i18n.getString("jdis.usage"));
|
println(i18n.getString("jdis.usage"));
|
||||||
|
Loading…
Reference in New Issue
Block a user