Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_langtools
提交
85fe1ce9
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看板
提交
85fe1ce9
编写于
11月 14, 2012
作者:
J
jjg
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8003412: javac needs to understand java.lang.annotation.Native
Reviewed-by: mcimadamore
上级
47883245
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
148 addition
and
6 deletion
+148
-6
src/share/classes/com/sun/tools/javac/code/Symtab.java
src/share/classes/com/sun/tools/javac/code/Symtab.java
+3
-1
src/share/classes/com/sun/tools/javac/jvm/JNIWriter.java
src/share/classes/com/sun/tools/javac/jvm/JNIWriter.java
+8
-1
test/tools/javac/nativeHeaders/NativeHeaderTest.java
test/tools/javac/nativeHeaders/NativeHeaderTest.java
+26
-3
test/tools/javac/nativeHeaders/javahComparison/CompareTest.java
...ools/javac/nativeHeaders/javahComparison/CompareTest.java
+1
-1
test/tools/javac/nativeHeaders/javahComparison/TestClass4.java
...tools/javac/nativeHeaders/javahComparison/TestClass4.java
+50
-0
test/tools/javac/nativeHeaders/javahComparison/TestClass5.java
...tools/javac/nativeHeaders/javahComparison/TestClass5.java
+60
-0
未找到文件。
src/share/classes/com/sun/tools/javac/code/Symtab.java
浏览文件 @
85fe1ce9
...
...
@@ -130,6 +130,7 @@ public class Symtab {
public
final
Type
methodHandleLookupType
;
public
final
Type
methodTypeType
;
public
final
Type
nativeHeaderType
;
public
final
Type
nativeHeaderType_old
;
public
final
Type
throwableType
;
public
final
Type
errorType
;
public
final
Type
interruptedExceptionType
;
...
...
@@ -505,7 +506,8 @@ public class Symtab {
List
.
of
(
exceptionType
),
methodClass
),
autoCloseableType
.
tsym
);
trustMeType
=
enterClass
(
"java.lang.SafeVarargs"
);
nativeHeaderType
=
enterClass
(
"javax.tools.annotation.GenerateNativeHeader"
);
nativeHeaderType
=
enterClass
(
"java.lang.annotation.Native"
);
nativeHeaderType_old
=
enterClass
(
"javax.tools.annotation.GenerateNativeHeader"
);
lambdaMetafactory
=
enterClass
(
"java.lang.invoke.LambdaMetafactory"
);
synthesizeEmptyInterfaceIfMissing
(
autoCloseableType
);
...
...
src/share/classes/com/sun/tools/javac/jvm/JNIWriter.java
浏览文件 @
85fe1ce9
...
...
@@ -157,13 +157,20 @@ public class JNIWriter {
if
(
c
.
isLocal
()
||
(
c
.
flags
()
&
Flags
.
SYNTHETIC
)
!=
0
)
return
false
;
/* temporary code for backwards compatibility */
for
(
Attribute
.
Compound
a:
c
.
annotations
.
getAttributes
())
{
if
(
a
.
type
.
tsym
==
syms
.
nativeHeaderType
.
tsym
)
if
(
a
.
type
.
tsym
==
syms
.
nativeHeaderType
_old
.
tsym
)
return
true
;
}
/* end of temporary code for backwards compatibility */
for
(
Scope
.
Entry
i
=
c
.
members_field
.
elems
;
i
!=
null
;
i
=
i
.
sibling
)
{
if
(
i
.
sym
.
kind
==
Kinds
.
MTH
&&
(
i
.
sym
.
flags
()
&
Flags
.
NATIVE
)
!=
0
)
return
true
;
for
(
Attribute
.
Compound
a:
i
.
sym
.
annotations
.
getAttributes
())
{
if
(
a
.
type
.
tsym
==
syms
.
nativeHeaderType
.
tsym
)
return
true
;
}
}
if
(
checkNestedClasses
)
{
for
(
Scope
.
Entry
i
=
c
.
members_field
.
elems
;
i
!=
null
;
i
=
i
.
sibling
)
{
...
...
test/tools/javac/nativeHeaders/NativeHeaderTest.java
浏览文件 @
85fe1ce9
...
...
@@ -23,7 +23,7 @@
/*
* @test
* @bug 7150368
* @bug 7150368
8003412
* @summary javac should include basic ability to generate native headers
*/
...
...
@@ -125,7 +125,7 @@ public class NativeHeaderTest {
}
@Test
void
a
nnoTest
(
RunKind
rk
,
GenKind
gk
)
throws
Exception
{
void
oldA
nnoTest
(
RunKind
rk
,
GenKind
gk
)
throws
Exception
{
List
<
File
>
files
=
new
ArrayList
<
File
>();
files
.
add
(
createFile
(
"p/C.java"
,
"@javax.tools.annotation.GenerateNativeHeader class C { }"
));
...
...
@@ -136,7 +136,18 @@ public class NativeHeaderTest {
}
@Test
void
annoNestedClassTest
(
RunKind
rk
,
GenKind
gk
)
throws
Exception
{
void
annoTest
(
RunKind
rk
,
GenKind
gk
)
throws
Exception
{
List
<
File
>
files
=
new
ArrayList
<
File
>();
files
.
add
(
createFile
(
"p/C.java"
,
"class C { @java.lang.annotation.Native public static final int i = 1907; }"
));
Set
<
String
>
expect
=
createSet
(
"C.h"
);
test
(
rk
,
gk
,
files
,
expect
);
}
@Test
void
oldAnnoNestedClassTest
(
RunKind
rk
,
GenKind
gk
)
throws
Exception
{
List
<
File
>
files
=
new
ArrayList
<
File
>();
files
.
add
(
createFile
(
"p/C.java"
,
"class C { @javax.tools.annotation.GenerateNativeHeader class Inner { } }"
));
...
...
@@ -147,6 +158,18 @@ public class NativeHeaderTest {
test
(
rk
,
gk
,
files
,
expect
);
}
@Test
void
annoNestedClassTest
(
RunKind
rk
,
GenKind
gk
)
throws
Exception
{
List
<
File
>
files
=
new
ArrayList
<
File
>();
files
.
add
(
createFile
(
"p/C.java"
,
"class C { class Inner { @java.lang.annotation.Native public static final int i = 1907; } }"
));
Set
<
String
>
expect
=
createSet
(
"C_Inner.h"
);
if
(
gk
==
GenKind
.
FULL
)
expect
.
add
(
"C.h"
);
test
(
rk
,
gk
,
files
,
expect
);
}
/**
* The worker method for each test case.
* Compile the files and verify that exactly the expected set of header files
...
...
test/tools/javac/nativeHeaders/javahComparison/CompareTest.java
浏览文件 @
85fe1ce9
...
...
@@ -23,7 +23,7 @@
/*
* @test
* @bug 7150368
* @bug 7150368
8003412
* @summary javac should include basic ability to generate native headers
*/
...
...
test/tools/javac/nativeHeaders/javahComparison/TestClass4.java
0 → 100644
浏览文件 @
85fe1ce9
/*
* Copyright (c) 2007, 2012, 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.
*/
import
java.lang.annotation.Native
;
public
class
TestClass4
{
@Native
public
static
final
byte
b
=
1
;
@Native
public
static
final
short
s
=
2
;
@Native
public
static
final
int
i
=
3
;
@Native
public
static
final
long
l
=
4
;
@Native
public
static
final
float
f
=
5.0f
;
@Native
public
static
final
double
d
=
6.0
;
@Native
public
static
final
Object
o
=
null
;
@Native
public
static
final
String
t
=
"8"
;
}
test/tools/javac/nativeHeaders/javahComparison/TestClass5.java
0 → 100644
浏览文件 @
85fe1ce9
/*
* Copyright (c) 2007, 2012, 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.
*/
import
java.lang.annotation.Native
;
public
class
TestClass5
{
@Native
public
static
final
int
tc5
=
1
;
public
class
Inner1
{
@Native
public
static
final
int
tc5i1
=
2
;
public
class
Inner1A
{
@Native
public
static
final
int
tc5i1i1a
=
3
;
}
public
class
Inner1B
{
@Native
public
static
final
int
tc5i1i1b
=
4
;
}
}
public
class
Inner2
{
@Native
public
static
final
int
tc521
=
5
;
public
class
Inner2A
{
@Native
public
static
final
int
tc5i2i2a
=
6
;
}
public
class
Inner2B
{
@Native
public
static
final
int
tc5i2i2b
=
7
;
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录