Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
硅谷海盗
kotlin
提交
2c848b8b
K
kotlin
项目概览
硅谷海盗
/
kotlin
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
kotlin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2c848b8b
编写于
10月 02, 2015
作者:
Y
Yan Zhulanow
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add JvmSynthetic annotation
上级
9eeb89a6
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
127 addition
and
52 deletion
+127
-52
compiler/backend/src/org/jetbrains/kotlin/codegen/AsmUtil.java
...ler/backend/src/org/jetbrains/kotlin/codegen/AsmUtil.java
+4
-1
compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyCodegen.java
...end/src/org/jetbrains/kotlin/codegen/PropertyCodegen.java
+5
-0
compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationUtil.kt
...ontend/src/org/jetbrains/kotlin/resolve/AnnotationUtil.kt
+7
-0
compiler/testData/codegen/bytecodeListing/annotations/JvmSynthetic.kt
...tData/codegen/bytecodeListing/annotations/JvmSynthetic.kt
+17
-0
compiler/testData/codegen/bytecodeListing/annotations/JvmSynthetic.txt
...Data/codegen/bytecodeListing/annotations/JvmSynthetic.txt
+16
-0
compiler/testData/codegen/bytecodeListing/annotations/defaultTargets.txt
...ta/codegen/bytecodeListing/annotations/defaultTargets.txt
+8
-8
compiler/testData/codegen/bytecodeListing/annotations/literals.txt
...testData/codegen/bytecodeListing/annotations/literals.txt
+19
-19
compiler/testData/codegen/bytecodeListing/annotations/onProperties.txt
...Data/codegen/bytecodeListing/annotations/onProperties.txt
+12
-12
compiler/testData/codegen/bytecodeListing/annotations/onReceiver.txt
...stData/codegen/bytecodeListing/annotations/onReceiver.txt
+10
-10
compiler/tests/org/jetbrains/kotlin/codegen/AbstractBytecodeListingTest.kt
...g/jetbrains/kotlin/codegen/AbstractBytecodeListingTest.kt
+19
-2
compiler/tests/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java
...etbrains/kotlin/codegen/BytecodeListingTestGenerated.java
+6
-0
libraries/stdlib/src/kotlin/jvm/JvmPlatformAnnotations.kt
libraries/stdlib/src/kotlin/jvm/JvmPlatformAnnotations.kt
+4
-0
未找到文件。
compiler/backend/src/org/jetbrains/kotlin/codegen/AsmUtil.java
浏览文件 @
2c848b8b
...
...
@@ -41,6 +41,7 @@ import org.jetbrains.kotlin.load.java.JvmAnnotationNames;
import
org.jetbrains.kotlin.load.java.descriptors.JavaCallableMemberDescriptor
;
import
org.jetbrains.kotlin.name.FqName
;
import
org.jetbrains.kotlin.resolve.DescriptorUtils
;
import
org.jetbrains.kotlin.resolve.annotations.AnnotationUtilKt
;
import
org.jetbrains.kotlin.resolve.annotations.AnnotationsPackage
;
import
org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilPackage
;
import
org.jetbrains.kotlin.resolve.inline.InlineUtil
;
...
...
@@ -212,7 +213,9 @@ public class AsmUtil {
flags
|=
ACC_ABSTRACT
;
}
if
(
JetTypeMapper
.
isAccessor
(
functionDescriptor
)
||
functionDescriptor
.
getVisibility
()
==
Visibilities
.
INTERNAL
)
{
if
(
JetTypeMapper
.
isAccessor
(
functionDescriptor
)
||
functionDescriptor
.
getVisibility
()
==
Visibilities
.
INTERNAL
||
AnnotationUtilKt
.
hasJvmSyntheticAnnotation
(
functionDescriptor
))
{
flags
|=
ACC_SYNTHETIC
;
}
...
...
compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyCodegen.java
浏览文件 @
2c848b8b
...
...
@@ -36,6 +36,7 @@ import org.jetbrains.kotlin.psi.psiUtil.PsiUtilPackage;
import
org.jetbrains.kotlin.resolve.BindingContext
;
import
org.jetbrains.kotlin.resolve.DescriptorFactory
;
import
org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
;
import
org.jetbrains.kotlin.resolve.annotations.AnnotationUtilKt
;
import
org.jetbrains.kotlin.resolve.annotations.AnnotationsPackage
;
import
org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
;
import
org.jetbrains.kotlin.resolve.constants.ConstantValue
;
...
...
@@ -293,6 +294,10 @@ public class PropertyCodegen {
modifiers
|=
ACC_FINAL
;
}
if
(
AnnotationUtilKt
.
hasJvmSyntheticAnnotation
(
propertyDescriptor
))
{
modifiers
|=
ACC_SYNTHETIC
;
}
Type
type
=
typeMapper
.
mapType
(
jetType
);
ClassBuilder
builder
=
v
;
...
...
compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationUtil.kt
浏览文件 @
2c848b8b
...
...
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import
org.jetbrains.kotlin.descriptors.*
import
org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
import
org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptorImpl
import
org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget
import
org.jetbrains.kotlin.descriptors.annotations.Annotations
import
org.jetbrains.kotlin.lexer.JetTokens
import
org.jetbrains.kotlin.name.FqName
...
...
@@ -40,6 +41,12 @@ public fun DeclarationDescriptor.findPublicFieldAnnotation(): AnnotationDescript
return
getAnnotations
().
findAnnotation
(
FqName
(
"kotlin.jvm.publicField"
))
}
public
fun
DeclarationDescriptor
.
hasJvmSyntheticAnnotation
():
Boolean
{
val
jvmSyntheticName
=
FqName
(
"kotlin.jvm.JvmSynthetic"
)
return
annotations
.
findAnnotation
(
jvmSyntheticName
)
!=
null
||
Annotations
.
findUseSiteTargetedAnnotation
(
annotations
,
AnnotationUseSiteTarget
.
FIELD
,
jvmSyntheticName
)
!=
null
}
public
fun
DeclarationDescriptor
.
hasIntrinsicAnnotation
():
Boolean
{
return
getAnnotations
().
findAnnotation
(
FqName
(
"kotlin.jvm.internal.Intrinsic"
))
!=
null
}
...
...
compiler/testData/codegen/bytecodeListing/annotations/JvmSynthetic.kt
0 → 100644
浏览文件 @
2c848b8b
class
Example
{
@JvmSynthetic
val
prop
:
String
=
"ABC"
var
prop2
=
5
@JvmSynthetic
public
get
@JvmSynthetic
public
set
@
field
:
JvmSynthetic
val
useSite
=
0
@
get
:
JvmSynthetic
@
set
:
JvmSynthetic
var
useSite2
=
0
@JvmSynthetic
fun
job
()
{}
}
\ No newline at end of file
compiler/testData/codegen/bytecodeListing/annotations/JvmSynthetic.txt
0 → 100644
浏览文件 @
2c848b8b
@kotlin.jvm.internal.KotlinClass Example {
public synthetic field $kotlinClass: kotlin.reflect.KClass
private synthetic @org.jetbrains.annotations.NotNull field prop: java.lang.String
private field prop2: int
private synthetic field useSite: int
private field useSite2: int
method <clinit>(): void
public @org.jetbrains.annotations.NotNull method getProp(): java.lang.String
public synthetic method getProp2(): int
public synthetic method setProp2(p0: int): void
public method getUseSite(): int
public method getUseSite2(): int
public method setUseSite2(p0: int): void
public synthetic method job(): void
public method <init>(): void
}
\ No newline at end of file
compiler/testData/codegen/bytecodeListing/annotations/defaultTargets.txt
浏览文件 @
2c848b8b
@kotlin.jvm.internal.KotlinClass A {
field $kotlinClass: kotlin.reflect.KClass
@AnnField @AnnParameterField @AnnTypeField field a: int
@AnnField @AnnTypeField field x: int
public synthetic
field $kotlinClass: kotlin.reflect.KClass
private
@AnnField @AnnParameterField @AnnTypeField field a: int
private
@AnnField @AnnTypeField field x: int
method <clinit>(): void
@AnnProperty @AnnFieldProperty @AnnParameterProperty method a$annotations(): void
method getA(): int
@AnnProperty @AnnFieldProperty method x$annotations(): void
method getX(): int
method <init>(@AnnParameterProperty @AnnParameterField p0: int): void
private synthetic deprecated
@AnnProperty @AnnFieldProperty @AnnParameterProperty method a$annotations(): void
public
method getA(): int
private synthetic deprecated
@AnnProperty @AnnFieldProperty method x$annotations(): void
public
method getX(): int
public
method <init>(@AnnParameterProperty @AnnParameterField p0: int): void
}
@kotlin.annotation.Target @java.lang.annotation.Retention @java.lang.annotation.Target @kotlin.jvm.internal.KotlinClass AnnField
...
...
compiler/testData/codegen/bytecodeListing/annotations/literals.txt
浏览文件 @
2c848b8b
...
...
@@ -6,32 +6,32 @@
@kotlin.jvm.internal.KotlinSyntheticClass @kotlin.jvm.internal.KotlinCallable LiteralsKt$foo$1 {
inner class LiteralsKt$foo$1
field $arg: int
method invoke(): java.lang.Object
@FunAnn method invoke(): int
synthetic
field $arg: int
public
method invoke(): java.lang.Object
public
@FunAnn method invoke(): int
method <init>(p0: int): void
}
@kotlin.jvm.internal.KotlinSyntheticClass @kotlin.jvm.internal.KotlinCallable LiteralsKt$foo$2 {
inner class LiteralsKt$foo$2
field $arg: int
method invoke(): java.lang.Object
method invoke(): int
synthetic
field $arg: int
public
method invoke(): java.lang.Object
public
method invoke(): int
method <init>(p0: int): void
}
@kotlin.jvm.internal.KotlinLocalClass @kotlin.jvm.internal.KotlinClass LiteralsKt$foo$3 {
inner class LiteralsKt$foo$3
field $kotlinClass: kotlin.reflect.KClass
public synthetic
field $kotlinClass: kotlin.reflect.KClass
method <clinit>(): void
method <init>(): void
}
@kotlin.jvm.internal.KotlinSyntheticClass @kotlin.jvm.internal.KotlinCallable LiteralsKt$foo$x$1 {
inner class LiteralsKt$foo$x$1
field $arg: int
method invoke(): java.lang.Object
@FunAnn method invoke(): int
synthetic
field $arg: int
public
method invoke(): java.lang.Object
public
@FunAnn method invoke(): int
method <init>(p0: int): void
}
...
...
@@ -40,20 +40,20 @@
inner class LiteralsKt$foo$2
inner class LiteralsKt$foo$x$1
inner class LiteralsKt$foo$3
method bar(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): int
@org.jetbrains.annotations.NotNull method foo(p0: int): My
public
method bar(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): int
public
@org.jetbrains.annotations.NotNull method foo(p0: int): My
}
@kotlin.jvm.internal.KotlinClass My {
field $kotlinClass: kotlin.reflect.KClass
public synthetic
field $kotlinClass: kotlin.reflect.KClass
method <clinit>(): void
method <init>(): void
public
method <init>(): void
}
@java.lang.Deprecated @kotlin.jvm.internal.KotlinPackage _DefaultPackage {
field $kotlinPackage: kotlin.reflect.KPackage
field $moduleName: java.lang.String
public synthetic
field $kotlinPackage: kotlin.reflect.KPackage
public synthetic
field $moduleName: java.lang.String
method <clinit>(): void
@kotlin.jvm.internal.KotlinDelegatedMethod method bar(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): int
@kotlin.jvm.internal.KotlinDelegatedMethod @org.jetbrains.annotations.NotNull method foo(p0: int): My
}
public
@kotlin.jvm.internal.KotlinDelegatedMethod method bar(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): int
public
@kotlin.jvm.internal.KotlinDelegatedMethod @org.jetbrains.annotations.NotNull method foo(p0: int): My
}
\ No newline at end of file
compiler/testData/codegen/bytecodeListing/annotations/onProperties.txt
浏览文件 @
2c848b8b
@kotlin.jvm.internal.KotlinClass A {
field $kotlinClass: kotlin.reflect.KClass
@AnnField field p: int
@AnnField field x: int
field y: int
public synthetic
field $kotlinClass: kotlin.reflect.KClass
private
@AnnField field p: int
private
@AnnField field x: int
private
field y: int
method <clinit>(): void
@AnnProp @AnnProp2 method p$annotations(): void
@AnnGetter method getP(): int
@AnnSetter method setP(@AnnParam p0: int): void
@AnnProp2 method x$annotations(): void
method getX(): int
@AnnGetter method getY(): int
@AnnSetter method setY(p0: int): void
method <init>(@AnnParam p0: int, @AnnParam p1: int): void
private synthetic deprecated
@AnnProp @AnnProp2 method p$annotations(): void
public
@AnnGetter method getP(): int
public
@AnnSetter method setP(@AnnParam p0: int): void
private synthetic deprecated
@AnnProp2 method x$annotations(): void
public
method getX(): int
public
@AnnGetter method getY(): int
public
@AnnSetter method setY(p0: int): void
public
method <init>(@AnnParam p0: int, @AnnParam p1: int): void
}
@java.lang.annotation.Retention @kotlin.jvm.internal.KotlinClass AnnField
...
...
compiler/testData/codegen/bytecodeListing/annotations/onReceiver.txt
浏览文件 @
2c848b8b
@kotlin.jvm.internal.KotlinClass A {
field $kotlinClass: kotlin.reflect.KClass
public synthetic
field $kotlinClass: kotlin.reflect.KClass
method <clinit>(): void
@org.jetbrains.annotations.NotNull method f(@Ann p0: java.lang.String): java.lang.String
@org.jetbrains.annotations.NotNull method getP(@Ann p0: java.lang.String): java.lang.String
method <init>(): void
public
@org.jetbrains.annotations.NotNull method f(@Ann p0: java.lang.String): java.lang.String
public
@org.jetbrains.annotations.NotNull method getP(@Ann p0: java.lang.String): java.lang.String
public
method <init>(): void
}
@java.lang.annotation.Retention @kotlin.jvm.internal.KotlinClass Ann
@kotlin.jvm.internal.KotlinFileFacade OnReceiverKt {
@org.jetbrains.annotations.NotNull method topLevelF(@Ann p0: java.lang.String): java.lang.String
@org.jetbrains.annotations.NotNull method getTopLevelP(@Ann p0: java.lang.String): java.lang.String
public
@org.jetbrains.annotations.NotNull method topLevelF(@Ann p0: java.lang.String): java.lang.String
public
@org.jetbrains.annotations.NotNull method getTopLevelP(@Ann p0: java.lang.String): java.lang.String
}
@java.lang.Deprecated @kotlin.jvm.internal.KotlinPackage _DefaultPackage {
field $kotlinPackage: kotlin.reflect.KPackage
field $moduleName: java.lang.String
public synthetic
field $kotlinPackage: kotlin.reflect.KPackage
public synthetic
field $moduleName: java.lang.String
method <clinit>(): void
@kotlin.jvm.internal.KotlinDelegatedMethod @org.jetbrains.annotations.NotNull method getTopLevelP(@Ann p0: java.lang.String): java.lang.String
@kotlin.jvm.internal.KotlinDelegatedMethod @org.jetbrains.annotations.NotNull method topLevelF(@Ann p0: java.lang.String): java.lang.String
public
@kotlin.jvm.internal.KotlinDelegatedMethod @org.jetbrains.annotations.NotNull method getTopLevelP(@Ann p0: java.lang.String): java.lang.String
public
@kotlin.jvm.internal.KotlinDelegatedMethod @org.jetbrains.annotations.NotNull method topLevelF(@Ann p0: java.lang.String): java.lang.String
}
\ No newline at end of file
compiler/tests/org/jetbrains/kotlin/codegen/AbstractBytecodeListingTest.kt
浏览文件 @
2c848b8b
...
...
@@ -48,9 +48,22 @@ public abstract class AbstractBytecodeListingTest : CodegenTestCase() {
private
val
classAnnotations
=
arrayListOf
<
String
>()
private
var
className
=
""
private
fun
addAnnotation
(
desc
:
String
)
{
private
fun
addAnnotation
(
desc
:
String
,
list
:
MutableList
<
String
>
=
declarationsInsideClass
.
last
().
annotations
)
{
val
name
=
Type
.
getType
(
desc
).
className
declarationsInsideClass
.
last
().
annotations
.
add
(
"@$name "
)
list
.
add
(
"@$name "
)
}
private
fun
addModifier
(
text
:
String
,
list
:
MutableList
<
String
>)
{
list
.
add
(
"$text "
)
}
private
fun
handleModifiers
(
access
:
Int
,
list
:
MutableList
<
String
>
=
declarationsInsideClass
.
last
().
annotations
)
{
if
((
access
and
Opcodes
.
ACC_PUBLIC
)
!=
0
)
addModifier
(
"public"
,
list
)
if
((
access
and
Opcodes
.
ACC_PROTECTED
)
!=
0
)
addModifier
(
"protected"
,
list
)
if
((
access
and
Opcodes
.
ACC_PRIVATE
)
!=
0
)
addModifier
(
"private"
,
list
)
if
((
access
and
Opcodes
.
ACC_SYNTHETIC
)
!=
0
)
addModifier
(
"synthetic"
,
list
)
if
((
access
and
Opcodes
.
ACC_DEPRECATED
)
!=
0
)
addModifier
(
"deprecated"
,
list
)
}
public
val
text
:
String
...
...
@@ -78,6 +91,8 @@ public abstract class AbstractBytecodeListingTest : CodegenTestCase() {
val
methodAnnotations
=
arrayListOf
<
String
>()
val
parameterAnnotations
=
hashMapOf
<
Int
,
MutableList
<
String
>>()
handleModifiers
(
access
,
methodAnnotations
)
return
object
:
MethodVisitor
(
Opcodes
.
ASM5
)
{
override
fun
visitAnnotation
(
desc
:
String
,
visible
:
Boolean
):
AnnotationVisitor
?
{
val
type
=
Type
.
getType
(
desc
).
className
...
...
@@ -105,6 +120,8 @@ public abstract class AbstractBytecodeListingTest : CodegenTestCase() {
override
fun
visitField
(
access
:
Int
,
name
:
String
,
desc
:
String
,
signature
:
String
?,
value
:
Any
?):
FieldVisitor
?
{
val
type
=
Type
.
getType
(
desc
).
className
declarationsInsideClass
.
add
(
Declaration
(
"field $name: $type"
))
handleModifiers
(
access
)
return
object
:
FieldVisitor
(
Opcodes
.
ASM5
)
{
override
fun
visitAnnotation
(
desc
:
String
,
visible
:
Boolean
):
AnnotationVisitor
?
{
addAnnotation
(
desc
)
...
...
compiler/tests/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java
浏览文件 @
2c848b8b
...
...
@@ -49,6 +49,12 @@ public class BytecodeListingTestGenerated extends AbstractBytecodeListingTest {
doTest
(
fileName
);
}
@TestMetadata
(
"JvmSynthetic.kt"
)
public
void
testJvmSynthetic
()
throws
Exception
{
String
fileName
=
JetTestUtils
.
navigationMetadata
(
"compiler/testData/codegen/bytecodeListing/annotations/JvmSynthetic.kt"
);
doTest
(
fileName
);
}
@TestMetadata
(
"literals.kt"
)
public
void
testLiterals
()
throws
Exception
{
String
fileName
=
JetTestUtils
.
navigationMetadata
(
"compiler/testData/codegen/bytecodeListing/annotations/literals.kt"
);
...
...
libraries/stdlib/src/kotlin/jvm/JvmPlatformAnnotations.kt
浏览文件 @
2c848b8b
...
...
@@ -61,6 +61,10 @@ public annotation class JvmName(public val name: String)
@MustBeDocumented
public
annotation
class
JvmMultifileClass
@Target
(
AnnotationTarget
.
FUNCTION
,
AnnotationTarget
.
PROPERTY_GETTER
,
AnnotationTarget
.
PROPERTY_SETTER
,
AnnotationTarget
.
FIELD
)
@Retention
(
AnnotationRetention
.
SOURCE
)
public
annotation
class
JvmSynthetic
/**
* Instructs the Kotlin compiler to generate a public backing field for this property.
*/
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录