< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java

Print this page

1682                 public void visitVarDef(JCVariableDecl tree) {
1683                     if (tree.init != null && tree.init.type.constValue() == null)
1684                         tree.init = null;
1685                     super.visitVarDef(tree);
1686                 }
1687                 @Override
1688                 public void visitClassDef(JCClassDecl tree) {
1689                     ListBuffer<JCTree> newdefs = new ListBuffer<>();
1690                     for (List<JCTree> it = tree.defs; it.tail != null; it = it.tail) {
1691                         JCTree t = it.head;
1692                         switch (t.getTag()) {
1693                         case CLASSDEF:
1694                             if (isInterface ||
1695                                 (((JCClassDecl) t).mods.flags & (Flags.PROTECTED|Flags.PUBLIC)) != 0 ||
1696                                 (((JCClassDecl) t).mods.flags & (Flags.PRIVATE)) == 0 && ((JCClassDecl) t).sym.packge().getQualifiedName() == names.java_lang)
1697                                 newdefs.append(t);
1698                             break;
1699                         case METHODDEF:
1700                             if (isInterface ||
1701                                 (((JCMethodDecl) t).mods.flags & (Flags.PROTECTED|Flags.PUBLIC)) != 0 ||
1702                                 ((JCMethodDecl) t).sym.name == names.init ||
1703                                 (((JCMethodDecl) t).mods.flags & (Flags.PRIVATE)) == 0 && ((JCMethodDecl) t).sym.packge().getQualifiedName() == names.java_lang)
1704                                 newdefs.append(t);
1705                             break;
1706                         case VARDEF:
1707                             if (isInterface || (((JCVariableDecl) t).mods.flags & (Flags.PROTECTED|Flags.PUBLIC)) != 0 ||
1708                                 (((JCVariableDecl) t).mods.flags & (Flags.PRIVATE)) == 0 && ((JCVariableDecl) t).sym.packge().getQualifiedName() == names.java_lang)
1709                                 newdefs.append(t);
1710                             break;
1711                         default:
1712                             break;
1713                         }
1714                     }
1715                     tree.defs = newdefs.toList();
1716                     super.visitClassDef(tree);
1717                 }
1718             }
1719             MethodBodyRemover r = new MethodBodyRemover();
1720             return r.translate(cdef);
1721         }
1722 

1682                 public void visitVarDef(JCVariableDecl tree) {
1683                     if (tree.init != null && tree.init.type.constValue() == null)
1684                         tree.init = null;
1685                     super.visitVarDef(tree);
1686                 }
1687                 @Override
1688                 public void visitClassDef(JCClassDecl tree) {
1689                     ListBuffer<JCTree> newdefs = new ListBuffer<>();
1690                     for (List<JCTree> it = tree.defs; it.tail != null; it = it.tail) {
1691                         JCTree t = it.head;
1692                         switch (t.getTag()) {
1693                         case CLASSDEF:
1694                             if (isInterface ||
1695                                 (((JCClassDecl) t).mods.flags & (Flags.PROTECTED|Flags.PUBLIC)) != 0 ||
1696                                 (((JCClassDecl) t).mods.flags & (Flags.PRIVATE)) == 0 && ((JCClassDecl) t).sym.packge().getQualifiedName() == names.java_lang)
1697                                 newdefs.append(t);
1698                             break;
1699                         case METHODDEF:
1700                             if (isInterface ||
1701                                 (((JCMethodDecl) t).mods.flags & (Flags.PROTECTED|Flags.PUBLIC)) != 0 ||
1702                                 names.isInitOrVNew(((JCMethodDecl) t).sym.name) ||
1703                                 (((JCMethodDecl) t).mods.flags & (Flags.PRIVATE)) == 0 && ((JCMethodDecl) t).sym.packge().getQualifiedName() == names.java_lang)
1704                                 newdefs.append(t);
1705                             break;
1706                         case VARDEF:
1707                             if (isInterface || (((JCVariableDecl) t).mods.flags & (Flags.PROTECTED|Flags.PUBLIC)) != 0 ||
1708                                 (((JCVariableDecl) t).mods.flags & (Flags.PRIVATE)) == 0 && ((JCVariableDecl) t).sym.packge().getQualifiedName() == names.java_lang)
1709                                 newdefs.append(t);
1710                             break;
1711                         default:
1712                             break;
1713                         }
1714                     }
1715                     tree.defs = newdefs.toList();
1716                     super.visitClassDef(tree);
1717                 }
1718             }
1719             MethodBodyRemover r = new MethodBodyRemover();
1720             return r.translate(cdef);
1721         }
1722 
< prev index next >