Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_langtools
提交
5941a8c4
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看板
提交
5941a8c4
编写于
11月 23, 2012
作者:
V
vromero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7144981: javac should ignore ignorable characters in input
Reviewed-by: jjg, mcimadamore
上级
62d00f7f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
110 addition
and
9 deletion
+110
-9
src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java
...are/classes/com/sun/tools/javac/parser/JavaTokenizer.java
+18
-9
test/tools/javac/7144981/IgnoreIgnorableCharactersInInput.java
...tools/javac/7144981/IgnoreIgnorableCharactersInInput.java
+92
-0
未找到文件。
src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java
浏览文件 @
5941a8c4
...
...
@@ -348,8 +348,8 @@ public class JavaTokenizer {
private
void
scanIdent
()
{
boolean
isJavaIdentifierPart
;
char
high
;
reader
.
putChar
(
true
);
do
{
reader
.
putChar
(
true
);
switch
(
reader
.
ch
)
{
case
'A'
:
case
'B'
:
case
'C'
:
case
'D'
:
case
'E'
:
case
'F'
:
case
'G'
:
case
'H'
:
case
'I'
:
case
'J'
:
...
...
@@ -366,6 +366,7 @@ public class JavaTokenizer {
case
'$'
:
case
'_'
:
case
'0'
:
case
'1'
:
case
'2'
:
case
'3'
:
case
'4'
:
case
'5'
:
case
'6'
:
case
'7'
:
case
'8'
:
case
'9'
:
break
;
case
'\u0000'
:
case
'\u0001'
:
case
'\u0002'
:
case
'\u0003'
:
case
'\u0004'
:
case
'\u0005'
:
case
'\u0006'
:
case
'\u0007'
:
case
'\u0008'
:
case
'\
u000E
'
:
case
'\
u000F
'
:
case
'\u0010'
:
...
...
@@ -373,26 +374,33 @@ public class JavaTokenizer {
case
'\u0015'
:
case
'\u0016'
:
case
'\u0017'
:
case
'\u0018'
:
case
'\u0019'
:
case
'\
u001B
'
:
case
'\
u007F
'
:
break
;
reader
.
scanChar
();
continue
;
case
'\
u001A
'
:
// EOI is also a legal identifier part
if
(
reader
.
bp
>=
reader
.
buflen
)
{
name
=
reader
.
name
();
tk
=
tokens
.
lookupKind
(
name
);
return
;
}
break
;
reader
.
scanChar
();
continue
;
default
:
if
(
reader
.
ch
<
'\u0080'
)
{
// all ASCII range chars already handled, above
isJavaIdentifierPart
=
false
;
}
else
{
high
=
reader
.
scanSurrogates
();
if
(
high
!=
0
)
{
reader
.
putChar
(
high
);
isJavaIdentifierPart
=
Character
.
isJavaIdentifierPart
(
Character
.
toCodePoint
(
high
,
reader
.
ch
));
if
(
Character
.
isIdentifierIgnorable
(
reader
.
ch
))
{
reader
.
scanChar
();
continue
;
}
else
{
isJavaIdentifierPart
=
Character
.
isJavaIdentifierPart
(
reader
.
ch
);
high
=
reader
.
scanSurrogates
();
if
(
high
!=
0
)
{
reader
.
putChar
(
high
);
isJavaIdentifierPart
=
Character
.
isJavaIdentifierPart
(
Character
.
toCodePoint
(
high
,
reader
.
ch
));
}
else
{
isJavaIdentifierPart
=
Character
.
isJavaIdentifierPart
(
reader
.
ch
);
}
}
}
if
(!
isJavaIdentifierPart
)
{
...
...
@@ -401,6 +409,7 @@ public class JavaTokenizer {
return
;
}
}
reader
.
putChar
(
true
);
}
while
(
true
);
}
...
...
test/tools/javac/7144981/IgnoreIgnorableCharactersInInput.java
0 → 100644
浏览文件 @
5941a8c4
/*
* @test /nodynamiccopyright/
* @bug 7144981
* @summary javac should ignore ignorable characters in input
* @run main IgnoreIgnorableCharactersInInput
*/
import
com.sun.source.util.JavacTask
;
import
java.io.File
;
import
java.net.URI
;
import
java.util.Arrays
;
import
java.util.Set
;
import
java.util.TreeSet
;
import
javax.tools.JavaCompiler
;
import
javax.tools.JavaFileObject
;
import
javax.tools.SimpleJavaFileObject
;
import
javax.tools.ToolProvider
;
public
class
IgnoreIgnorableCharactersInInput
{
public
static
void
main
(
String
...
args
)
throws
Exception
{
new
IgnoreIgnorableCharactersInInput
().
run
();
}
void
run
()
throws
Exception
{
JavaCompiler
comp
=
ToolProvider
.
getSystemJavaCompiler
();
File
classesDir
=
new
File
(
System
.
getProperty
(
"user.dir"
),
"classes"
);
classesDir
.
mkdirs
();
JavaSource
[]
sources
=
new
JavaSource
[]{
new
JavaSource
(
"TestOneIgnorableChar"
,
"AA\\u0000BB"
),
new
JavaSource
(
"TestMultipleIgnorableChar"
,
"AA\\u0000\\u0000\\u0000BB"
)};
JavacTask
ct
=
(
JavacTask
)
comp
.
getTask
(
null
,
null
,
null
,
Arrays
.
asList
(
"-d"
,
classesDir
.
getPath
()),
null
,
Arrays
.
asList
(
sources
));
try
{
if
(!
ct
.
call
())
{
throw
new
AssertionError
(
"Error thrown when compiling test cases"
);
}
}
catch
(
Throwable
ex
)
{
throw
new
AssertionError
(
"Error thrown when compiling test cases"
);
}
check
(
classesDir
,
"TestOneIgnorableChar.class"
,
"TestOneIgnorableChar$AABB.class"
,
"TestMultipleIgnorableChar.class"
,
"TestMultipleIgnorableChar$AABB.class"
);
if
(
errors
>
0
)
throw
new
AssertionError
(
"There are some errors in the test check the error output"
);
}
/**
* Check that a directory contains the expected files.
*/
void
check
(
File
dir
,
String
...
paths
)
{
Set
<
String
>
found
=
new
TreeSet
<
String
>(
Arrays
.
asList
(
dir
.
list
()));
Set
<
String
>
expect
=
new
TreeSet
<
String
>(
Arrays
.
asList
(
paths
));
if
(
found
.
equals
(
expect
))
return
;
for
(
String
f:
found
)
{
if
(!
expect
.
contains
(
f
))
error
(
"Unexpected file found: "
+
f
);
}
for
(
String
e:
expect
)
{
if
(!
found
.
contains
(
e
))
error
(
"Expected file not found: "
+
e
);
}
}
int
errors
;
void
error
(
String
msg
)
{
System
.
err
.
println
(
msg
);
errors
++;
}
class
JavaSource
extends
SimpleJavaFileObject
{
String
internalSource
=
"public class #O {public class #I {} }"
;
public
JavaSource
(
String
outerClassName
,
String
innerClassName
)
{
super
(
URI
.
create
(
outerClassName
+
".java"
),
JavaFileObject
.
Kind
.
SOURCE
);
internalSource
=
internalSource
.
replace
(
"#O"
,
outerClassName
).
replace
(
"#I"
,
innerClassName
);
}
@Override
public
CharSequence
getCharContent
(
boolean
ignoreEncodingErrors
)
{
return
internalSource
;
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录