Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_langtools
提交
7510b419
D
dragonwell8_langtools
项目概览
openanolis
/
dragonwell8_langtools
通知
0
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_langtools
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
7510b419
编写于
8月 28, 2013
作者:
J
jjg
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8010310: [javadoc] Error processing sources with -private
Reviewed-by: vromero, mcimadamore
上级
a3e13d46
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
168 addition
and
1 deletion
+168
-1
src/share/classes/com/sun/tools/javac/code/Symbol.java
src/share/classes/com/sun/tools/javac/code/Symbol.java
+1
-1
src/share/classes/com/sun/tools/javadoc/JavadocMemberEnter.java
...are/classes/com/sun/tools/javadoc/JavadocMemberEnter.java
+105
-0
test/tools/javadoc/nonConstExprs/Test.java
test/tools/javadoc/nonConstExprs/Test.java
+62
-0
未找到文件。
src/share/classes/com/sun/tools/javac/code/Symbol.java
浏览文件 @
7510b419
...
...
@@ -1179,7 +1179,7 @@ public abstract class Symbol implements Element {
/**
* The variable's constant value, if this is a constant.
* Before the constant value is evaluated, it points to an
* initalizer environment. If this is not a constant, it can
* init
i
alizer environment. If this is not a constant, it can
* be used for other stuff.
*/
private
Object
data
;
...
...
src/share/classes/com/sun/tools/javadoc/JavadocMemberEnter.java
浏览文件 @
7510b419
...
...
@@ -30,9 +30,12 @@ import com.sun.tools.javac.code.Flags;
import
com.sun.tools.javac.code.Kinds
;
import
com.sun.tools.javac.code.Symbol.*
;
import
com.sun.tools.javac.comp.MemberEnter
;
import
com.sun.tools.javac.tree.JCTree
;
import
com.sun.tools.javac.tree.JCTree.*
;
import
com.sun.tools.javac.util.Context
;
import
static
com
.
sun
.
tools
.
javac
.
code
.
Flags
.*;
/**
* Javadoc's own memberEnter phase does a few things above and beyond that
* done by javac.
...
...
@@ -86,6 +89,17 @@ public class JavadocMemberEnter extends MemberEnter {
@Override
public
void
visitVarDef
(
JCVariableDecl
tree
)
{
if
(
tree
.
init
!=
null
)
{
boolean
isFinal
=
(
tree
.
mods
.
flags
&
FINAL
)
!=
0
||
(
env
.
enclClass
.
mods
.
flags
&
INTERFACE
)
!=
0
;
if
(!
isFinal
||
containsNonConstantExpression
(
tree
.
init
))
{
// Avoid unnecessary analysis and release resources.
// In particular, remove non-constant expressions
// which may trigger Attr.attribClass, since
// method bodies are also removed, in visitMethodDef.
tree
.
init
=
null
;
}
}
super
.
visitVarDef
(
tree
);
if
(
tree
.
sym
!=
null
&&
tree
.
sym
.
kind
==
Kinds
.
VAR
&&
...
...
@@ -101,4 +115,95 @@ public class JavadocMemberEnter extends MemberEnter {
private
static
boolean
isParameter
(
VarSymbol
var
)
{
return
(
var
.
flags
()
&
Flags
.
PARAMETER
)
!=
0
;
}
/**
* Simple analysis of an expression tree to see if it contains tree nodes
* for any non-constant expression. This does not include checking references
* to other fields which may or may not be constant.
*/
private
static
boolean
containsNonConstantExpression
(
JCExpression
tree
)
{
return
new
MaybeConstantExpressionScanner
().
containsNonConstantExpression
(
tree
);
}
/**
* See JLS 15.18, Constant Expression
*/
private
static
class
MaybeConstantExpressionScanner
extends
JCTree
.
Visitor
{
boolean
maybeConstantExpr
=
true
;
public
boolean
containsNonConstantExpression
(
JCExpression
tree
)
{
scan
(
tree
);
return
!
maybeConstantExpr
;
}
public
void
scan
(
JCTree
tree
)
{
// short circuit scan when end result is definitely false
if
(
maybeConstantExpr
&&
tree
!=
null
)
tree
.
accept
(
this
);
}
@Override
/** default for any non-overridden visit method. */
public
void
visitTree
(
JCTree
tree
)
{
maybeConstantExpr
=
false
;
}
@Override
public
void
visitBinary
(
JCBinary
tree
)
{
switch
(
tree
.
getTag
())
{
case
MUL:
case
DIV:
case
MOD:
case
PLUS:
case
MINUS:
case
SL:
case
SR:
case
USR:
case
LT:
case
LE:
case
GT:
case
GE:
case
EQ:
case
NE:
case
BITAND:
case
BITXOR:
case
BITOR:
case
AND:
case
OR:
break
;
default
:
maybeConstantExpr
=
false
;
}
}
@Override
public
void
visitConditional
(
JCConditional
tree
)
{
scan
(
tree
.
cond
);
scan
(
tree
.
truepart
);
scan
(
tree
.
falsepart
);
}
@Override
public
void
visitIdent
(
JCIdent
tree
)
{
}
@Override
public
void
visitLiteral
(
JCLiteral
tree
)
{
}
@Override
public
void
visitParens
(
JCParens
tree
)
{
scan
(
tree
.
expr
);
}
@Override
public
void
visitSelect
(
JCTree
.
JCFieldAccess
tree
)
{
scan
(
tree
.
selected
);
}
@Override
public
void
visitTypeCast
(
JCTypeCast
tree
)
{
scan
(
tree
.
clazz
);
scan
(
tree
.
expr
);
}
@Override
public
void
visitTypeIdent
(
JCPrimitiveTypeTree
tree
)
{
}
@Override
public
void
visitUnary
(
JCUnary
tree
)
{
switch
(
tree
.
getTag
())
{
case
POS:
case
NEG:
case
COMPL:
case
NOT:
break
;
default
:
maybeConstantExpr
=
false
;
}
}
}
}
test/tools/javadoc/nonConstExprs/Test.java
0 → 100644
浏览文件 @
7510b419
/*
* Copyright (c) 2013, 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
* 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @test
* @bug 8010310
* @summary Error processing sources with -private
*/
import
java.io.File
;
public
class
Test
{
public
static
void
main
(
String
...
args
)
throws
Exception
{
File
testSrc
=
new
File
(
System
.
getProperty
(
"test.src"
));
String
[]
jdoc_args
=
{
"-d"
,
"out"
,
new
File
(
testSrc
,
Test
.
class
.
getSimpleName
()
+
".java"
).
getPath
()
};
int
rc
=
com
.
sun
.
tools
.
javadoc
.
Main
.
execute
(
jdoc_args
);
if
(
rc
!=
0
)
throw
new
Exception
(
"unexpected return code from javadoc: "
+
rc
);
}
static
int
array
[]
=
{
1
,
2
,
3
};
static
int
method
(
int
p
)
{
return
p
;
}
static
int
value
=
0
;
public
int
not_static_not_final
=
1
;
public
static
int
static_not_final
=
2
;
public
final
int
not_static_final
=
3
;
public
static
final
int
static_final
=
4
;
public
static
final
int
array_index
=
array
[
0
];
public
static
final
int
method_call
=
method
(
0
);
public
static
final
int
inner_class
=
new
Test
()
{
}.
method
(
0
);
public
static
final
int
new_class
=
new
Test
().
method
(
0
);
public
static
final
int
pre_inc
=
++
value
;
public
static
final
int
pre_dec
=
--
value
;
public
static
final
int
post_inc
=
value
++;
public
static
final
int
post_dec
=
value
--;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录