提交 1daa4059 编写于 作者: M mcimadamore

6734819: Javac performs flows analysis on already translated classes

Summary: Regression in JavaCompiler.desugar introduced in 6726015
Reviewed-by: jjg
上级 be2ce51f
......@@ -27,6 +27,7 @@ package com.sun.tools.javac.main;
import java.io.*;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.MissingResourceException;
......@@ -1185,14 +1186,16 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
* are processed through attribute and flow before subtypes are translated.
*/
class ScanNested extends TreeScanner {
Set<Env<AttrContext>> dependencies = new HashSet<Env<AttrContext>>();
Set<Env<AttrContext>> dependencies = new LinkedHashSet<Env<AttrContext>>();
public void visitClassDef(JCClassDecl node) {
Type st = types.supertype(node.sym.type);
if (st.tag == TypeTags.CLASS) {
ClassSymbol c = st.tsym.outermostClass();
Env<AttrContext> stEnv = enter.getEnv(c);
if (stEnv != null && env != stEnv)
dependencies.add(stEnv);
if (stEnv != null && env != stEnv) {
if (dependencies.add(stEnv))
scan(stEnv.tree);
}
}
super.visitClassDef(node);
}
......@@ -1204,6 +1207,11 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
flow(attribute(dep));
}
//We need to check for error another time as more classes might
//have been attributed and analyzed at this stage
if (errorCount() > 0)
return;
if (verboseCompilePolicy)
log.printLines(log.noticeWriter, "[desugar " + env.enclClass.sym + "]");
......
/*
* Copyright 2008 Sun Microsystems, Inc. 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 6734819
* @summary Javac performs flows analysis on already translated classes
* @author Maurizio Cimadamore
*
* @compile/ref=T6734819a.out -XDrawDiagnostics -Xlint:all -XDverboseCompilePolicy T6734819a.java
*/
class Y extends W {}
class W extends Z {}
class Z {
void m(Z z) {
W w = (W)z;
}
}
[attribute Y]
[flow Y]
[attribute W]
[flow W]
[attribute Z]
[flow Z]
[desugar Y]
[generate code Y]
[desugar W]
[generate code W]
[desugar Z]
[generate code Z]
/*
* Copyright 2008 Sun Microsystems, Inc. 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 6734819
* @summary Javac performs flows analysis on already translated classes
* @author Maurizio Cimadamore
*
* @compile/ref=T6734819b.out -XDrawDiagnostics -Xlint:all -XDverboseCompilePolicy T6734819b.java
*/
class A extends B {}
class B {
class C extends B {}
}
[attribute A]
[flow A]
[attribute B]
[flow B]
[desugar A]
[generate code A]
[desugar B]
[generate code B]
[generate code B]
/*
* Copyright 2008 Sun Microsystems, Inc. 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 6734819
* @summary Javac performs flows analysis on already translated classes
* @author Maurizio Cimadamore
*
* @compile/fail/ref=T6734819c.out -XDrawDiagnostics -Xlint:all -XDverboseCompilePolicy T6734819c.java
*/
class Y extends W {}
class W extends Z {}
class Z {
void m(Z z) {
return;
W w = (W)z;
}
}
[attribute Y]
[flow Y]
[attribute W]
[flow W]
[attribute Z]
[flow Z]
T6734819c.java:38:11: compiler.err.unreachable.stmt
1 error
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册