8005542: jtreg test OverrideBridge.java contains @ignore

Fri, 04 Oct 2013 16:23:05 -0700

author
ksrini
date
Fri, 04 Oct 2013 16:23:05 -0700
changeset 2090
15651a673358
parent 2089
bb87db832b31
child 2091
4dd7ffbf01fb

8005542: jtreg test OverrideBridge.java contains @ignore
Reviewed-by: jjg
Contributed-by: steve.sides@oracle.com

test/tools/javac/generics/OverrideBridge.java file | annotate | diff | comparison | revisions
     1.1 --- a/test/tools/javac/generics/OverrideBridge.java	Fri Oct 04 16:08:18 2013 -0700
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,166 +0,0 @@
     1.4 -/*
     1.5 - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
     1.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 - *
     1.8 - * This code is free software; you can redistribute it and/or modify it
     1.9 - * under the terms of the GNU General Public License version 2 only, as
    1.10 - * published by the Free Software Foundation.
    1.11 - *
    1.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 - * version 2 for more details (a copy is included in the LICENSE file that
    1.16 - * accompanied this code).
    1.17 - *
    1.18 - * You should have received a copy of the GNU General Public License version
    1.19 - * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 - *
    1.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 - * or visit www.oracle.com if you need additional information or have any
    1.24 - * questions.
    1.25 - */
    1.26 -
    1.27 -/*
    1.28 - * @test
    1.29 - * @bug 6337171 6996415
    1.30 - * @ignore 6996758: Investigate better override bridges strategy
    1.31 - * @summary  javac should create bridge methods when type variable bounds restricted
    1.32 - * @run main OverrideBridge
    1.33 - */
    1.34 -
    1.35 -// fix, and test, has been disabled as a consequence of 6996415
    1.36 -
    1.37 -import java.io.*;
    1.38 -import java.net.URI;
    1.39 -import java.util.ArrayList;
    1.40 -import java.util.Arrays;
    1.41 -import java.util.List;
    1.42 -import java.util.Map;
    1.43 -import java.util.HashMap;
    1.44 -import javax.tools.JavaCompiler;
    1.45 -import javax.tools.JavaFileObject;
    1.46 -import javax.tools.SimpleJavaFileObject;
    1.47 -import javax.tools.ToolProvider;
    1.48 -
    1.49 -import com.sun.source.util.JavacTask;
    1.50 -import com.sun.tools.classfile.ClassFile;
    1.51 -import com.sun.tools.classfile.ConstantPoolException;
    1.52 -import com.sun.tools.classfile.Descriptor.InvalidDescriptor;
    1.53 -import com.sun.tools.classfile.Method;
    1.54 -
    1.55 -public class OverrideBridge {
    1.56 -
    1.57 -    enum Implementation {
    1.58 -        IMPLICIT(""),
    1.59 -        EXPLICIT("@Override public abstract X m(X x);");
    1.60 -
    1.61 -        String impl;
    1.62 -
    1.63 -        Implementation(String impl) {
    1.64 -            this.impl = impl;
    1.65 -        }
    1.66 -    }
    1.67 -
    1.68 -    static class JavaSource extends SimpleJavaFileObject {
    1.69 -
    1.70 -        final static String sourceStub =
    1.71 -                        "abstract class A<X> {\n" +
    1.72 -                        "   public abstract X m(X x);\n" +
    1.73 -                        "}\n" +
    1.74 -                        "interface I<X> {\n" +
    1.75 -                        "X m(X x);\n" +
    1.76 -                        "}\n" +
    1.77 -                        "abstract class B<X extends B<X>> extends A<X> implements I<X> { #B }\n" +
    1.78 -                        "abstract class C<X extends C<X>> extends B<X>  { #C }\n" +
    1.79 -                        "abstract class D<X extends D<X>> extends C<X>  { #D }\n";
    1.80 -
    1.81 -        String source;
    1.82 -
    1.83 -        public JavaSource(Implementation implB, Implementation implC, Implementation implD) {
    1.84 -            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
    1.85 -            source = sourceStub.replace("#B", implB.impl).replace("#C", implC.impl).replace("#D", implD.impl);
    1.86 -        }
    1.87 -
    1.88 -        @Override
    1.89 -        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
    1.90 -            return source;
    1.91 -        }
    1.92 -    }
    1.93 -
    1.94 -    public static void main(String... args) throws Exception {
    1.95 -        Map<ClassFile, List<Method>> refMembers =
    1.96 -                compile(Implementation.EXPLICIT, Implementation.EXPLICIT, Implementation.EXPLICIT, "ref");
    1.97 -        int i = 0;
    1.98 -        for (Implementation implB : Implementation.values()) {
    1.99 -            for (Implementation implC : Implementation.values()) {
   1.100 -                for (Implementation implD : Implementation.values()) {
   1.101 -                    Map<ClassFile, List<Method>> membersToCheck = compile(implB, implC, implD, "out_" + i++);
   1.102 -                    check(refMembers, membersToCheck);
   1.103 -                }
   1.104 -            }
   1.105 -        }
   1.106 -    }
   1.107 -
   1.108 -    static String workDir = System.getProperty("user.dir");
   1.109 -
   1.110 -    static Map<ClassFile, List<Method>> compile(Implementation implB, Implementation implC, Implementation implD, String destPath) throws Exception {
   1.111 -        File destDir = new File(workDir, destPath); destDir.mkdir();
   1.112 -        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
   1.113 -        JavaSource source = new JavaSource(implB, implC, implD);
   1.114 -        JavacTask ct = (JavacTask)tool.getTask(null, null, null,
   1.115 -                Arrays.asList("-d", destPath), null, Arrays.asList(source));
   1.116 -        ct.generate();
   1.117 -        Map<ClassFile, List<Method>> members = new HashMap<>();
   1.118 -        addMembers(destDir, members);
   1.119 -        return members;
   1.120 -    }
   1.121 -
   1.122 -    static void addMembers(File destDir, Map<ClassFile, List<Method>> members) {
   1.123 -        String[] names = { "B.class", "C.class", "D.class" };
   1.124 -        try {
   1.125 -            for (String name : names) {
   1.126 -                File f = new File(destDir, name);
   1.127 -                ClassFile cf = ClassFile.read(f);
   1.128 -                members.put(cf, readMethod(cf, "m"));
   1.129 -            }
   1.130 -        } catch (Exception e) {
   1.131 -            e.printStackTrace();
   1.132 -            throw new Error("error reading classes");
   1.133 -        }
   1.134 -    }
   1.135 -
   1.136 -    static List<Method> readMethod(ClassFile cf, String name) throws ConstantPoolException {
   1.137 -        List<Method> buf = new ArrayList<>();
   1.138 -        for (Method m : cf.methods) {
   1.139 -            if (m.getName(cf.constant_pool).equals(name)) {
   1.140 -                buf.add(m);
   1.141 -            }
   1.142 -        }
   1.143 -        return buf;
   1.144 -    }
   1.145 -
   1.146 -    static void check(Map<ClassFile, List<Method>> refMembers, Map<ClassFile, List<Method>> membersToCheck) throws ConstantPoolException, InvalidDescriptor {
   1.147 -        for (Map.Entry<ClassFile, List<Method>> ref : refMembers.entrySet()) {
   1.148 -            ClassFile cRef = ref.getKey();
   1.149 -            for (Method mRef : ref.getValue()) {
   1.150 -                boolean ok = false;
   1.151 -                for (Map.Entry<ClassFile, List<Method>> toCheck : membersToCheck.entrySet()) {
   1.152 -                    ClassFile cToCheck = toCheck.getKey();
   1.153 -                    for (Method mToCheck : toCheck.getValue()) {
   1.154 -                        if (cRef.getName().equals(cToCheck.getName()) &&
   1.155 -                                mRef.descriptor.getReturnType(cRef.constant_pool).equals(
   1.156 -                                mToCheck.descriptor.getReturnType(cToCheck.constant_pool)) &&
   1.157 -                                mRef.descriptor.getParameterTypes(cRef.constant_pool).equals(
   1.158 -                                mToCheck.descriptor.getParameterTypes(cToCheck.constant_pool))) {
   1.159 -                            ok = true;
   1.160 -                        }
   1.161 -                    }
   1.162 -                }
   1.163 -                if (!ok) {
   1.164 -                    throw new AssertionError("Matching method descriptor for " + mRef.descriptor.getParameterTypes(cRef.constant_pool) + "not found");
   1.165 -                }
   1.166 -            }
   1.167 -        }
   1.168 -    }
   1.169 -}

mercurial