Skip to content

Commit 55109d0

Browse files
committed
Shuffling classes around.
Old Man Reflection is coming home and he's not going to like finding out a bunch of beans have moved into his reflecting room. We had better evict those guys before he blows his stack. scala.reflect.*Bean* --> scala.beans.* scala.beans, that's kind of a fancy package name for some beans. I figure it's time to start fishing or cutting bait on this kind of thing. I don't even know what beans are, but if we're going to have them in the mainline, the least surprising place to find them is scala.beans. If we don't want to put them in scala.beans for whatever reason, then I say they don't belong in trunk at all. Bonus round: scala.annotation.target --> scala.beans.meta I don't know if there is any more unfortunate name for a package possible than "target". Maybe ".svn" or ".git" if you could have dots in package names. Package CVS wouldn't hit too hard these days. Package lib_managed? I'll try to come up with something. In any case this golden opportunity could not be squandered. There is a new starr included, because GenJVM contains all kinds of shooting-from-the-hip Bean-related name hardcoding. (Yes, still. I ran out of stones. So a few birds escape with their lives... this time.)
1 parent ff5619e commit 55109d0

34 files changed

+171
-128
lines changed

lib/scala-compiler.jar.desired.sha1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
9361bf724565fdb20937e22c7dc4e6c67ff82221 ?scala-compiler.jar
1+
14a0987b7538c3aadcfa9160965076dfe118ec0d ?scala-compiler.jar
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
b0308ec2747d2e1614a000298dacccdd78e57c2d ?scala-library-src.jar
1+
6207899bfc2c03c7c9d014e332475eb313062e3c ?scala-library-src.jar

lib/scala-library.jar.desired.sha1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1489cddb0e70ade4a03766ab3f9811697294ab0a ?scala-library.jar
1+
f374329f89c77e8205a377060b21cf97ace5ac9b ?scala-library.jar

src/compiler/scala/reflect/internal/Definitions.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,12 @@ trait Definitions extends reflect.api.StandardDefinitions {
209209
lazy val ElidableMethodClass = getClass("scala.annotation.elidable")
210210
lazy val ImplicitNotFoundClass = getClass("scala.annotation.implicitNotFound")
211211
lazy val VarargsClass = getClass("scala.annotation.varargs")
212-
lazy val FieldTargetClass = getClass("scala.annotation.target.field")
213-
lazy val GetterTargetClass = getClass("scala.annotation.target.getter")
214-
lazy val SetterTargetClass = getClass("scala.annotation.target.setter")
215-
lazy val BeanGetterTargetClass = getClass("scala.annotation.target.beanGetter")
216-
lazy val BeanSetterTargetClass = getClass("scala.annotation.target.beanSetter")
217-
lazy val ParamTargetClass = getClass("scala.annotation.target.param")
212+
lazy val FieldTargetClass = getClass("scala.beans.meta.field")
213+
lazy val GetterTargetClass = getClass("scala.beans.meta.getter")
214+
lazy val SetterTargetClass = getClass("scala.beans.meta.setter")
215+
lazy val BeanGetterTargetClass = getClass("scala.beans.meta.beanGetter")
216+
lazy val BeanSetterTargetClass = getClass("scala.beans.meta.beanSetter")
217+
lazy val ParamTargetClass = getClass("scala.beans.meta.param")
218218
lazy val ScalaInlineClass = getClass("scala.inline")
219219
lazy val ScalaNoInlineClass = getClass("scala.noinline")
220220
lazy val SpecializedClass = getClass("scala.specialized")

src/compiler/scala/reflect/internal/StdNames.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,8 +606,8 @@ trait StdNames extends /*reflect.generic.StdNames with*/ NameManglers { self: Sy
606606
}
607607

608608
private class J2SENames extends JavaNames {
609-
final val BeanProperty: TypeName = "scala.reflect.BeanProperty"
610-
final val BooleanBeanProperty: TypeName = "scala.reflect.BooleanBeanProperty"
609+
final val BeanProperty: TypeName = "scala.beans.BeanProperty"
610+
final val BooleanBeanProperty: TypeName = "scala.beans.BooleanBeanProperty"
611611
final val Code: TypeName = "scala.reflect.Code"
612612
final val JavaSerializable: TypeName = "java.io.Serializable"
613613
}

src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,10 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with
180180
val MethodHandleType = new JObjectType("java.dyn.MethodHandle")
181181

182182
// Scala attributes
183-
val BeanInfoAttr = definitions.getClass("scala.reflect.BeanInfo")
184-
val BeanInfoSkipAttr = definitions.getClass("scala.reflect.BeanInfoSkip")
185-
val BeanDisplayNameAttr = definitions.getClass("scala.reflect.BeanDisplayName")
186-
val BeanDescriptionAttr = definitions.getClass("scala.reflect.BeanDescription")
183+
val BeanInfoAttr = definitions.getClass("scala.beans.BeanInfo")
184+
val BeanInfoSkipAttr = definitions.getClass("scala.beans.BeanInfoSkip")
185+
val BeanDisplayNameAttr = definitions.getClass("scala.beans.BeanDisplayName")
186+
val BeanDescriptionAttr = definitions.getClass("scala.beans.BeanDescription")
187187

188188
lazy val CloneableClass = definitions.getClass("java.lang.Cloneable")
189189
lazy val RemoteInterface = definitions.getClass("java.rmi.Remote")
@@ -443,7 +443,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with
443443

444444
val beanInfoClass = fjbgContext.JClass(javaFlags(c.symbol),
445445
javaName(c.symbol) + "BeanInfo",
446-
"scala/reflect/ScalaBeanInfo",
446+
"scala/beans/ScalaBeanInfo",
447447
JClass.NO_INTERFACES,
448448
c.cunit.source.toString)
449449

@@ -497,7 +497,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with
497497

498498
// invoke the superclass constructor, which will do the
499499
// necessary java reflection and create Method objects.
500-
jcode.emitINVOKESPECIAL("scala/reflect/ScalaBeanInfo", "<init>", conType)
500+
jcode.emitINVOKESPECIAL("scala/beans/ScalaBeanInfo", "<init>", conType)
501501
jcode.emitRETURN()
502502

503503
// write the bean information class file.
Lines changed: 27 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,29 @@
1+
/* __ *\
2+
** ________ ___ / / ___ Scala API **
3+
** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL **
4+
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
5+
** /____/\___/_/ |_/____/_/ | | **
6+
** |/ **
7+
\* */
8+
19
package scala.annotation
210

3-
/**
4-
* When defining a field, the Scala compiler creates up to four accessors
5-
* for it: a getter, a setter, and if the field is annotated with
6-
* `@BeanProperty`, a bean getter and a bean setter.
7-
*
8-
* For instance in the following class definition
9-
*
10-
* {{{
11-
* class C(@myAnnot @BeanProperty var c: Int)
12-
* }}}
13-
*
14-
* there are six entities which can carry the annotation `@myAnnot`: the
15-
* constructor parameter, the generated field and the four accessors.
16-
*
17-
* By default, annotations on (`val`-, `var`- or plain) constructor parameters
18-
* end up on the parameter, not on any other entity. Annotations on fields
19-
* by default only end up on the field.
20-
*
21-
* The meta-annotations in package `scala.annotation.target` are used
22-
* to control where annotations on fields and class parameters are copied.
23-
* This is done by annotating either the annotation type or the annotation
24-
* class with one or several of the meta-annotations in this package.
25-
*
26-
* ==Annotating the annotation type==
27-
*
28-
* The target meta-annotations can be put on the annotation type when
29-
* instantiating the annotation. In the following example, the annotation
30-
* `@Id` will be added only to the bean getter `getX`.
31-
*
32-
* {{{
33-
* import javax.persistence.Id
34-
* class A {
35-
* @(Id @beanGetter) @BeanProperty val x = 0
36-
* }
37-
* }}}
38-
*
39-
* In order to annotate the field as well, the meta-annotation `@field`
40-
* would need to be added.
41-
*
42-
* The syntax can be improved using a type alias:
43-
*
44-
* {{{
45-
* object ScalaJPA {
46-
* type Id = javax.persistence.Id @beanGetter
47-
* }
48-
* import ScalaJPA.Id
49-
* class A {
50-
* @Id @BeanProperty val x = 0
51-
* }
52-
* }}}
53-
*
54-
* ==Annotating the annotation class==
55-
*
56-
* For annotations defined in Scala, a default target can be specified
57-
* in the annotation class itself, for example
58-
*
59-
* {{{
60-
* @getter
61-
* class myAnnotation extends Annotation
62-
* }}}
63-
*
64-
* This only changes the default target for the annotation `myAnnotation`.
65-
* When instantiating the annotation, the target can still be specified
66-
* as described in the last section.
67-
*/
68-
package object target
11+
package object target {
12+
@deprecated("Use `@scala.beans.meta.beanGetter` instead", "2.10.0")
13+
type beanGetter = scala.beans.meta.beanGetter
14+
15+
@deprecated("Use `@scala.beans.meta.beanSetter` instead", "2.10.0")
16+
type beanSetter = scala.beans.meta.beanSetter
17+
18+
@deprecated("Use `@scala.beans.meta.field` instead", "2.10.0")
19+
type field = scala.beans.meta.field
20+
21+
@deprecated("Use `@scala.beans.meta.getter` instead", "2.10.0")
22+
type getter = scala.beans.meta.getter
23+
24+
@deprecated("Use `@scala.beans.meta.param` instead", "2.10.0")
25+
type param = scala.beans.meta.param
26+
27+
@deprecated("Use `@scala.beans.meta.setter` instead", "2.10.0")
28+
type setter = scala.beans.meta.setter
29+
}

src/library/scala/reflect/BeanDescription.scala renamed to src/library/scala/beans/BeanDescription.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
\* */
88

99

10-
package scala.reflect
10+
package scala.beans
1111

1212
/** Provides a short description that will be included when generating
1313
* bean information. This annotation can be attached to the bean itself,

src/library/scala/reflect/BeanDisplayName.scala renamed to src/library/scala/beans/BeanDisplayName.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
\* */
88

99

10-
package scala.reflect
10+
package scala.beans
1111

1212
/** Provides a display name when generating bean information. This
1313
* annotation can be attached to the bean itself, or to any member.

src/library/scala/reflect/BeanInfo.scala renamed to src/library/scala/beans/BeanInfo.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
** |/ **
77
\* */
88

9-
package scala.reflect
9+
package scala.beans
1010

1111
/** This annotation indicates that a JavaBean-compliant `BeanInfo` class
1212
* should be generated for this annotated Scala class.

src/library/scala/reflect/BeanInfoSkip.scala renamed to src/library/scala/beans/BeanInfoSkip.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
\* */
88

99

10-
package scala.reflect
10+
package scala.beans
1111

1212
/** This annotation indicates that bean information should
1313
* <strong>not</strong> be generated for the val, var, or def that it is

src/library/scala/reflect/BeanProperty.scala renamed to src/library/scala/beans/BeanProperty.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
** |/ **
77
\* */
88

9-
package scala.reflect
9+
package scala.beans
1010

11-
import annotation.target._
11+
import meta._
1212

1313
/** When attached to a field, this annotation adds a setter and a getter
1414
* method following the Java Bean convention. For example:
@@ -22,7 +22,7 @@ import annotation.target._
2222
* def getStatus: String = this.status
2323
* }}}
2424
* For fields of type `Boolean`, if you need a getter named `isStatus`,
25-
* use the `scala.reflect.BooleanBeanProperty` annotation instead.
25+
* use the `scala.beans.BooleanBeanProperty` annotation instead.
2626
*/
2727
@field
2828
class BeanProperty extends annotation.StaticAnnotation

src/library/scala/reflect/BooleanBeanProperty.scala renamed to src/library/scala/beans/BooleanBeanProperty.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
** |/ **
77
\* */
88

9-
package scala.reflect
9+
package scala.beans
1010

11-
import annotation.target._
11+
import meta._
1212

1313
/** This annotation has the same functionality as
14-
* `scala.reflect.BeanProperty`, but the generated Bean getter will be
14+
* `scala.beans.BeanProperty`, but the generated Bean getter will be
1515
* named `isFieldName` instead of `getFieldName`.
1616
*/
1717
@field

src/library/scala/reflect/ScalaBeanInfo.scala renamed to src/library/scala/beans/ScalaBeanInfo.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
\* */
88

99

10-
package scala.reflect
10+
package scala.beans
1111

1212
/** Provides some simple runtime processing necessary to create
1313
* JavaBean descriptors for Scala entities. The compiler creates

src/library/scala/annotation/target/beanGetter.scala renamed to src/library/scala/beans/meta/beanGetter.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
** /____/\___/_/ |_/____/_/ | | **
66
** |/ **
77
\* */
8-
package scala.annotation.target
8+
package scala.beans.meta
99

1010
/**
11-
* Consult the documentation in package [[scala.annotation.target]].
11+
* Consult the documentation in package [[scala.beans.meta]].
1212
*/
1313
final class beanGetter extends annotation.StaticAnnotation

src/library/scala/annotation/target/beanSetter.scala renamed to src/library/scala/beans/meta/beanSetter.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
** /____/\___/_/ |_/____/_/ | | **
66
** |/ **
77
\* */
8-
package scala.annotation.target
8+
package scala.beans.meta
99

1010
/**
11-
* Consult the documentation in package [[scala.annotation.target]].
11+
* Consult the documentation in package [[scala.beans.meta]].
1212
*/
1313
final class beanSetter extends annotation.StaticAnnotation

src/library/scala/annotation/target/field.scala renamed to src/library/scala/beans/meta/field.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
** /____/\___/_/ |_/____/_/ | | **
66
** |/ **
77
\* */
8-
package scala.annotation.target
8+
package scala.beans.meta
99

1010
/**
11-
* Consult the documentation in package [[scala.annotation.target]].
11+
* Consult the documentation in package [[scala.beans.meta]].
1212
*/
1313
final class field extends annotation.StaticAnnotation

src/library/scala/annotation/target/getter.scala renamed to src/library/scala/beans/meta/getter.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
** /____/\___/_/ |_/____/_/ | | **
66
** |/ **
77
\* */
8-
package scala.annotation.target
8+
package scala.beans.meta
99

1010
/**
11-
* Consult the documentation in package [[scala.annotation.target]].
11+
* Consult the documentation in package [[scala.beans.meta]].
1212
*/
1313
final class getter extends annotation.StaticAnnotation
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package scala.beans
2+
3+
/**
4+
* When defining a field, the Scala compiler creates up to four accessors
5+
* for it: a getter, a setter, and if the field is annotated with
6+
* `@BeanProperty`, a bean getter and a bean setter.
7+
*
8+
* For instance in the following class definition
9+
*
10+
* {{{
11+
* class C(@myAnnot @BeanProperty var c: Int)
12+
* }}}
13+
*
14+
* there are six entities which can carry the annotation `@myAnnot`: the
15+
* constructor parameter, the generated field and the four accessors.
16+
*
17+
* By default, annotations on (`val`-, `var`- or plain) constructor parameters
18+
* end up on the parameter, not on any other entity. Annotations on fields
19+
* by default only end up on the field.
20+
*
21+
* The meta-annotations in package `scala.beans.meta` are used
22+
* to control where annotations on fields and class parameters are copied.
23+
* This is done by annotating either the annotation type or the annotation
24+
* class with one or several of the meta-annotations in this package.
25+
*
26+
* ==Annotating the annotation type==
27+
*
28+
* The target meta-annotations can be put on the annotation type when
29+
* instantiating the annotation. In the following example, the annotation
30+
* `@Id` will be added only to the bean getter `getX`.
31+
*
32+
* {{{
33+
* import javax.persistence.Id
34+
* class A {
35+
* @(Id @beanGetter) @BeanProperty val x = 0
36+
* }
37+
* }}}
38+
*
39+
* In order to annotate the field as well, the meta-annotation `@field`
40+
* would need to be added.
41+
*
42+
* The syntax can be improved using a type alias:
43+
*
44+
* {{{
45+
* object ScalaJPA {
46+
* type Id = javax.persistence.Id @beanGetter
47+
* }
48+
* import ScalaJPA.Id
49+
* class A {
50+
* @Id @BeanProperty val x = 0
51+
* }
52+
* }}}
53+
*
54+
* ==Annotating the annotation class==
55+
*
56+
* For annotations defined in Scala, a default target can be specified
57+
* in the annotation class itself, for example
58+
*
59+
* {{{
60+
* @getter
61+
* class myAnnotation extends Annotation
62+
* }}}
63+
*
64+
* This only changes the default target for the annotation `myAnnotation`.
65+
* When instantiating the annotation, the target can still be specified
66+
* as described in the last section.
67+
*/
68+
package object meta

src/library/scala/annotation/target/param.scala renamed to src/library/scala/beans/meta/param.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
** /____/\___/_/ |_/____/_/ | | **
66
** |/ **
77
\* */
8-
package scala.annotation.target
8+
package scala.beans.meta
99

1010
/**
11-
* Consult the documentation in package [[scala.annotation.target]].
11+
* Consult the documentation in package [[scala.beans.meta]].
1212
*/
1313
final class param extends annotation.StaticAnnotation

src/library/scala/annotation/target/setter.scala renamed to src/library/scala/beans/meta/setter.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
** /____/\___/_/ |_/____/_/ | | **
66
** |/ **
77
\* */
8-
package scala.annotation.target
8+
package scala.beans.meta
99

1010
/**
11-
* Consult the documentation in package [[scala.annotation.target]].
11+
* Consult the documentation in package [[scala.beans.meta]].
1212
*/
1313
final class setter extends annotation.StaticAnnotation

src/library/scala/deprecated.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
package scala
1010

11-
import annotation.target._
11+
import beans.meta._
1212

1313
/** An annotation that designates that a definition is deprecated.
1414
* Access to the member then generates a deprecated warning.

0 commit comments

Comments
 (0)