mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 19:14:38 +02:00
6734819: Javac performs flows analysis on already translated classes
Regression in JavaCompiler.desugar introduced in 6726015 Reviewed-by: jjg
This commit is contained in:
parent
a7cdf34685
commit
054a64704a
7 changed files with 154 additions and 3 deletions
|
@ -27,6 +27,7 @@ package com.sun.tools.javac.main;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.MissingResourceException;
|
import java.util.MissingResourceException;
|
||||||
|
@ -1185,14 +1186,16 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
|
||||||
* are processed through attribute and flow before subtypes are translated.
|
* are processed through attribute and flow before subtypes are translated.
|
||||||
*/
|
*/
|
||||||
class ScanNested extends TreeScanner {
|
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) {
|
public void visitClassDef(JCClassDecl node) {
|
||||||
Type st = types.supertype(node.sym.type);
|
Type st = types.supertype(node.sym.type);
|
||||||
if (st.tag == TypeTags.CLASS) {
|
if (st.tag == TypeTags.CLASS) {
|
||||||
ClassSymbol c = st.tsym.outermostClass();
|
ClassSymbol c = st.tsym.outermostClass();
|
||||||
Env<AttrContext> stEnv = enter.getEnv(c);
|
Env<AttrContext> stEnv = enter.getEnv(c);
|
||||||
if (stEnv != null && env != stEnv)
|
if (stEnv != null && env != stEnv) {
|
||||||
dependencies.add(stEnv);
|
if (dependencies.add(stEnv))
|
||||||
|
scan(stEnv.tree);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
super.visitClassDef(node);
|
super.visitClassDef(node);
|
||||||
}
|
}
|
||||||
|
@ -1204,6 +1207,11 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
|
||||||
flow(attribute(dep));
|
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)
|
if (verboseCompilePolicy)
|
||||||
log.printLines(log.noticeWriter, "[desugar " + env.enclClass.sym + "]");
|
log.printLines(log.noticeWriter, "[desugar " + env.enclClass.sym + "]");
|
||||||
|
|
||||||
|
|
39
langtools/test/tools/javac/6734819/T6734819a.java
Normal file
39
langtools/test/tools/javac/6734819/T6734819a.java
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
}
|
12
langtools/test/tools/javac/6734819/T6734819a.out
Normal file
12
langtools/test/tools/javac/6734819/T6734819a.out
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
[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]
|
35
langtools/test/tools/javac/6734819/T6734819b.java
Normal file
35
langtools/test/tools/javac/6734819/T6734819b.java
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* 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 {}
|
||||||
|
}
|
9
langtools/test/tools/javac/6734819/T6734819b.out
Normal file
9
langtools/test/tools/javac/6734819/T6734819b.out
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
[attribute A]
|
||||||
|
[flow A]
|
||||||
|
[attribute B]
|
||||||
|
[flow B]
|
||||||
|
[desugar A]
|
||||||
|
[generate code A]
|
||||||
|
[desugar B]
|
||||||
|
[generate code B]
|
||||||
|
[generate code B]
|
40
langtools/test/tools/javac/6734819/T6734819c.java
Normal file
40
langtools/test/tools/javac/6734819/T6734819c.java
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
}
|
8
langtools/test/tools/javac/6734819/T6734819c.out
Normal file
8
langtools/test/tools/javac/6734819/T6734819c.out
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
[attribute Y]
|
||||||
|
[flow Y]
|
||||||
|
[attribute W]
|
||||||
|
[flow W]
|
||||||
|
[attribute Z]
|
||||||
|
[flow Z]
|
||||||
|
T6734819c.java:38:11: compiler.err.unreachable.stmt
|
||||||
|
1 error
|
Loading…
Add table
Add a link
Reference in a new issue