OpenJDK / bsd-port / jdk9 / jdk
changeset 13583:14716231231b
8143317: jdk/lambda/vm/InterfaceAccessFlagsTest.java fails with IncompatibleClassChangeError
Summary: ClassToInterfaceConverter.java converts class to interface without changing corresponding method tag to interface method tag. This leads failure after 8145148.
Reviewed-by: psandoz, hseigel
author | minqi |
---|---|
date | Fri, 15 Jan 2016 08:53:23 -0800 |
parents | af335ad593d6 |
children | 29815876c49e |
files | test/jdk/lambda/separate/ClassToInterfaceConverter.java |
diffstat | 1 files changed, 20 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/test/jdk/lambda/separate/ClassToInterfaceConverter.java Wed Jan 06 02:31:59 2016 +0000 +++ b/test/jdk/lambda/separate/ClassToInterfaceConverter.java Fri Jan 15 08:53:23 2016 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -62,6 +62,25 @@ } } cf.methods = new_methods; + // Convert method tag. Find Methodref, which is not "<init>" and only invoked by other methods + // in the interface, convert it to InterfaceMethodref + ArrayList<ClassFile.CpEntry> cpool = new ArrayList<>(); + for (int i = 0; i < cf.constant_pool.size(); i++) { + ClassFile.CpEntry ce = cf.constant_pool.get(i); + if (ce instanceof ClassFile.CpMethodRef) { + ClassFile.CpMethodRef me = (ClassFile.CpMethodRef)ce; + ClassFile.CpNameAndType nameType = (ClassFile.CpNameAndType)cf.constant_pool.get(me.name_and_type_index); + ClassFile.CpEntry name = cf.constant_pool.get(nameType.name_index); + if (!utf8Matches(name, "<init>") && cf.this_class == me.class_index) { + ClassFile.CpInterfaceMethodRef newEntry = new ClassFile.CpInterfaceMethodRef(); + newEntry.class_index = me.class_index; + newEntry.name_and_type_index = me.name_and_type_index; + ce = newEntry; + } + } + cpool.add(ce); + } + cf.constant_pool = cpool; } public byte[] preprocess(String classname, byte[] bytes) {