Skip to content

Commit

Permalink
Shuffling classes around.
Browse files Browse the repository at this point in the history
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.)
  • Loading branch information
paulp committed Oct 1, 2011
1 parent ff5619e commit 55109d0
Show file tree
Hide file tree
Showing 34 changed files with 171 additions and 128 deletions.
2 changes: 1 addition & 1 deletion lib/scala-compiler.jar.desired.sha1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9361bf724565fdb20937e22c7dc4e6c67ff82221 ?scala-compiler.jar
14a0987b7538c3aadcfa9160965076dfe118ec0d ?scala-compiler.jar
2 changes: 1 addition & 1 deletion lib/scala-library-src.jar.desired.sha1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
b0308ec2747d2e1614a000298dacccdd78e57c2d ?scala-library-src.jar
6207899bfc2c03c7c9d014e332475eb313062e3c ?scala-library-src.jar
2 changes: 1 addition & 1 deletion lib/scala-library.jar.desired.sha1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1489cddb0e70ade4a03766ab3f9811697294ab0a ?scala-library.jar
f374329f89c77e8205a377060b21cf97ace5ac9b ?scala-library.jar
12 changes: 6 additions & 6 deletions src/compiler/scala/reflect/internal/Definitions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,12 @@ trait Definitions extends reflect.api.StandardDefinitions {
lazy val ElidableMethodClass = getClass("scala.annotation.elidable")
lazy val ImplicitNotFoundClass = getClass("scala.annotation.implicitNotFound")
lazy val VarargsClass = getClass("scala.annotation.varargs")
lazy val FieldTargetClass = getClass("scala.annotation.target.field")
lazy val GetterTargetClass = getClass("scala.annotation.target.getter")
lazy val SetterTargetClass = getClass("scala.annotation.target.setter")
lazy val BeanGetterTargetClass = getClass("scala.annotation.target.beanGetter")
lazy val BeanSetterTargetClass = getClass("scala.annotation.target.beanSetter")
lazy val ParamTargetClass = getClass("scala.annotation.target.param")
lazy val FieldTargetClass = getClass("scala.beans.meta.field")
lazy val GetterTargetClass = getClass("scala.beans.meta.getter")
lazy val SetterTargetClass = getClass("scala.beans.meta.setter")
lazy val BeanGetterTargetClass = getClass("scala.beans.meta.beanGetter")
lazy val BeanSetterTargetClass = getClass("scala.beans.meta.beanSetter")
lazy val ParamTargetClass = getClass("scala.beans.meta.param")
lazy val ScalaInlineClass = getClass("scala.inline")
lazy val ScalaNoInlineClass = getClass("scala.noinline")
lazy val SpecializedClass = getClass("scala.specialized")
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/scala/reflect/internal/StdNames.scala
Original file line number Diff line number Diff line change
Expand Up @@ -606,8 +606,8 @@ trait StdNames extends /*reflect.generic.StdNames with*/ NameManglers { self: Sy
}

private class J2SENames extends JavaNames {
final val BeanProperty: TypeName = "scala.reflect.BeanProperty"
final val BooleanBeanProperty: TypeName = "scala.reflect.BooleanBeanProperty"
final val BeanProperty: TypeName = "scala.beans.BeanProperty"
final val BooleanBeanProperty: TypeName = "scala.beans.BooleanBeanProperty"
final val Code: TypeName = "scala.reflect.Code"
final val JavaSerializable: TypeName = "java.io.Serializable"
}
Expand Down
12 changes: 6 additions & 6 deletions src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,10 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with
val MethodHandleType = new JObjectType("java.dyn.MethodHandle")

// Scala attributes
val BeanInfoAttr = definitions.getClass("scala.reflect.BeanInfo")
val BeanInfoSkipAttr = definitions.getClass("scala.reflect.BeanInfoSkip")
val BeanDisplayNameAttr = definitions.getClass("scala.reflect.BeanDisplayName")
val BeanDescriptionAttr = definitions.getClass("scala.reflect.BeanDescription")
val BeanInfoAttr = definitions.getClass("scala.beans.BeanInfo")
val BeanInfoSkipAttr = definitions.getClass("scala.beans.BeanInfoSkip")
val BeanDisplayNameAttr = definitions.getClass("scala.beans.BeanDisplayName")
val BeanDescriptionAttr = definitions.getClass("scala.beans.BeanDescription")

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

val beanInfoClass = fjbgContext.JClass(javaFlags(c.symbol),
javaName(c.symbol) + "BeanInfo",
"scala/reflect/ScalaBeanInfo",
"scala/beans/ScalaBeanInfo",
JClass.NO_INTERFACES,
c.cunit.source.toString)

Expand Down Expand Up @@ -497,7 +497,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with

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

// write the bean information class file.
Expand Down
93 changes: 27 additions & 66 deletions src/library/scala/annotation/target/package.scala
Original file line number Diff line number Diff line change
@@ -1,68 +1,29 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */

package scala.annotation

/**
* When defining a field, the Scala compiler creates up to four accessors
* for it: a getter, a setter, and if the field is annotated with
* `@BeanProperty`, a bean getter and a bean setter.
*
* For instance in the following class definition
*
* {{{
* class C(@myAnnot @BeanProperty var c: Int)
* }}}
*
* there are six entities which can carry the annotation `@myAnnot`: the
* constructor parameter, the generated field and the four accessors.
*
* By default, annotations on (`val`-, `var`- or plain) constructor parameters
* end up on the parameter, not on any other entity. Annotations on fields
* by default only end up on the field.
*
* The meta-annotations in package `scala.annotation.target` are used
* to control where annotations on fields and class parameters are copied.
* This is done by annotating either the annotation type or the annotation
* class with one or several of the meta-annotations in this package.
*
* ==Annotating the annotation type==
*
* The target meta-annotations can be put on the annotation type when
* instantiating the annotation. In the following example, the annotation
* `@Id` will be added only to the bean getter `getX`.
*
* {{{
* import javax.persistence.Id
* class A {
* @(Id @beanGetter) @BeanProperty val x = 0
* }
* }}}
*
* In order to annotate the field as well, the meta-annotation `@field`
* would need to be added.
*
* The syntax can be improved using a type alias:
*
* {{{
* object ScalaJPA {
* type Id = javax.persistence.Id @beanGetter
* }
* import ScalaJPA.Id
* class A {
* @Id @BeanProperty val x = 0
* }
* }}}
*
* ==Annotating the annotation class==
*
* For annotations defined in Scala, a default target can be specified
* in the annotation class itself, for example
*
* {{{
* @getter
* class myAnnotation extends Annotation
* }}}
*
* This only changes the default target for the annotation `myAnnotation`.
* When instantiating the annotation, the target can still be specified
* as described in the last section.
*/
package object target
package object target {
@deprecated("Use `@scala.beans.meta.beanGetter` instead", "2.10.0")
type beanGetter = scala.beans.meta.beanGetter

@deprecated("Use `@scala.beans.meta.beanSetter` instead", "2.10.0")
type beanSetter = scala.beans.meta.beanSetter

@deprecated("Use `@scala.beans.meta.field` instead", "2.10.0")
type field = scala.beans.meta.field

@deprecated("Use `@scala.beans.meta.getter` instead", "2.10.0")
type getter = scala.beans.meta.getter

@deprecated("Use `@scala.beans.meta.param` instead", "2.10.0")
type param = scala.beans.meta.param

@deprecated("Use `@scala.beans.meta.setter` instead", "2.10.0")
type setter = scala.beans.meta.setter
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
\* */


package scala.reflect
package scala.beans

/** Provides a short description that will be included when generating
* bean information. This annotation can be attached to the bean itself,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
\* */


package scala.reflect
package scala.beans

/** Provides a display name when generating bean information. This
* annotation can be attached to the bean itself, or to any member.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
** |/ **
\* */

package scala.reflect
package scala.beans

/** This annotation indicates that a JavaBean-compliant `BeanInfo` class
* should be generated for this annotated Scala class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
\* */


package scala.reflect
package scala.beans

/** This annotation indicates that bean information should
* <strong>not</strong> be generated for the val, var, or def that it is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
** |/ **
\* */

package scala.reflect
package scala.beans

import annotation.target._
import meta._

/** When attached to a field, this annotation adds a setter and a getter
* method following the Java Bean convention. For example:
Expand All @@ -22,7 +22,7 @@ import annotation.target._
* def getStatus: String = this.status
* }}}
* For fields of type `Boolean`, if you need a getter named `isStatus`,
* use the `scala.reflect.BooleanBeanProperty` annotation instead.
* use the `scala.beans.BooleanBeanProperty` annotation instead.
*/
@field
class BeanProperty extends annotation.StaticAnnotation
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
** |/ **
\* */

package scala.reflect
package scala.beans

import annotation.target._
import meta._

/** This annotation has the same functionality as
* `scala.reflect.BeanProperty`, but the generated Bean getter will be
* `scala.beans.BeanProperty`, but the generated Bean getter will be
* named `isFieldName` instead of `getFieldName`.
*/
@field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
\* */


package scala.reflect
package scala.beans

/** Provides some simple runtime processing necessary to create
* JavaBean descriptors for Scala entities. The compiler creates
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
package scala.annotation.target
package scala.beans.meta

/**
* Consult the documentation in package [[scala.annotation.target]].
* Consult the documentation in package [[scala.beans.meta]].
*/
final class beanGetter extends annotation.StaticAnnotation
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
package scala.annotation.target
package scala.beans.meta

/**
* Consult the documentation in package [[scala.annotation.target]].
* Consult the documentation in package [[scala.beans.meta]].
*/
final class beanSetter extends annotation.StaticAnnotation
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
package scala.annotation.target
package scala.beans.meta

/**
* Consult the documentation in package [[scala.annotation.target]].
* Consult the documentation in package [[scala.beans.meta]].
*/
final class field extends annotation.StaticAnnotation
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
package scala.annotation.target
package scala.beans.meta

/**
* Consult the documentation in package [[scala.annotation.target]].
* Consult the documentation in package [[scala.beans.meta]].
*/
final class getter extends annotation.StaticAnnotation
68 changes: 68 additions & 0 deletions src/library/scala/beans/meta/package.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package scala.beans

/**
* When defining a field, the Scala compiler creates up to four accessors
* for it: a getter, a setter, and if the field is annotated with
* `@BeanProperty`, a bean getter and a bean setter.
*
* For instance in the following class definition
*
* {{{
* class C(@myAnnot @BeanProperty var c: Int)
* }}}
*
* there are six entities which can carry the annotation `@myAnnot`: the
* constructor parameter, the generated field and the four accessors.
*
* By default, annotations on (`val`-, `var`- or plain) constructor parameters
* end up on the parameter, not on any other entity. Annotations on fields
* by default only end up on the field.
*
* The meta-annotations in package `scala.beans.meta` are used
* to control where annotations on fields and class parameters are copied.
* This is done by annotating either the annotation type or the annotation
* class with one or several of the meta-annotations in this package.
*
* ==Annotating the annotation type==
*
* The target meta-annotations can be put on the annotation type when
* instantiating the annotation. In the following example, the annotation
* `@Id` will be added only to the bean getter `getX`.
*
* {{{
* import javax.persistence.Id
* class A {
* @(Id @beanGetter) @BeanProperty val x = 0
* }
* }}}
*
* In order to annotate the field as well, the meta-annotation `@field`
* would need to be added.
*
* The syntax can be improved using a type alias:
*
* {{{
* object ScalaJPA {
* type Id = javax.persistence.Id @beanGetter
* }
* import ScalaJPA.Id
* class A {
* @Id @BeanProperty val x = 0
* }
* }}}
*
* ==Annotating the annotation class==
*
* For annotations defined in Scala, a default target can be specified
* in the annotation class itself, for example
*
* {{{
* @getter
* class myAnnotation extends Annotation
* }}}
*
* This only changes the default target for the annotation `myAnnotation`.
* When instantiating the annotation, the target can still be specified
* as described in the last section.
*/
package object meta
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
package scala.annotation.target
package scala.beans.meta

/**
* Consult the documentation in package [[scala.annotation.target]].
* Consult the documentation in package [[scala.beans.meta]].
*/
final class param extends annotation.StaticAnnotation
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
package scala.annotation.target
package scala.beans.meta

/**
* Consult the documentation in package [[scala.annotation.target]].
* Consult the documentation in package [[scala.beans.meta]].
*/
final class setter extends annotation.StaticAnnotation
2 changes: 1 addition & 1 deletion src/library/scala/deprecated.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

package scala

import annotation.target._
import beans.meta._

/** An annotation that designates that a definition is deprecated.
* Access to the member then generates a deprecated warning.
Expand Down
Loading

0 comments on commit 55109d0

Please sign in to comment.