Skip to content

Commit 2f95a24

Browse files
authored
Merge pull request scala#5267 from lrytz/deprecateRemote
Deprecate @Remote
2 parents fd36aa2 + 4c33a55 commit 2f95a24

File tree

4 files changed

+21
-19
lines changed

4 files changed

+21
-19
lines changed

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

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -883,25 +883,22 @@ abstract class BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
883883
*
884884
* must-single-thread
885885
*/
886-
private def addForwarder(isRemoteClass: Boolean, jclass: asm.ClassVisitor, module: Symbol, m: Symbol): Unit = {
887-
def staticForwarderGenericSignature(sym: Symbol, moduleClass: Symbol): String = {
888-
if (sym.isDeferred) null // only add generic signature if method concrete; bug #1745
889-
else {
890-
// SI-3452 Static forwarder generation uses the same erased signature as the method if forwards to.
891-
// By rights, it should use the signature as-seen-from the module class, and add suitable
892-
// primitive and value-class boxing/unboxing.
893-
// But for now, just like we did in mixin, we just avoid writing a wrong generic signature
894-
// (one that doesn't erase to the actual signature). See run/t3452b for a test case.
895-
val memberTpe = enteringErasure(moduleClass.thisType.memberInfo(sym))
896-
val erasedMemberType = erasure.erasure(sym)(memberTpe)
897-
if (erasedMemberType =:= sym.info)
898-
getGenericSignature(sym, moduleClass, memberTpe)
899-
else null
900-
}
886+
private def addForwarder(isRemoteClass: Boolean, jclass: asm.ClassVisitor, moduleClass: Symbol, m: Symbol): Unit = {
887+
def staticForwarderGenericSignature: String = {
888+
// SI-3452 Static forwarder generation uses the same erased signature as the method if forwards to.
889+
// By rights, it should use the signature as-seen-from the module class, and add suitable
890+
// primitive and value-class boxing/unboxing.
891+
// But for now, just like we did in mixin, we just avoid writing a wrong generic signature
892+
// (one that doesn't erase to the actual signature). See run/t3452b for a test case.
893+
val memberTpe = enteringErasure(moduleClass.thisType.memberInfo(m))
894+
val erasedMemberType = erasure.erasure(m)(memberTpe)
895+
if (erasedMemberType =:= m.info)
896+
getGenericSignature(m, moduleClass, memberTpe)
897+
else null
901898
}
902899

903-
val moduleName = internalName(module)
904-
val methodInfo = module.thisType.memberInfo(m)
900+
val moduleName = internalName(moduleClass)
901+
val methodInfo = moduleClass.thisType.memberInfo(m)
905902
val paramJavaTypes: List[BType] = methodInfo.paramTypes map typeToBType
906903
// val paramNames = 0 until paramJavaTypes.length map ("x_" + _)
907904

@@ -916,7 +913,7 @@ abstract class BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
916913
)
917914

918915
// TODO needed? for(ann <- m.annotations) { ann.symbol.initialize }
919-
val jgensig = staticForwarderGenericSignature(m, module)
916+
val jgensig = staticForwarderGenericSignature
920917
addRemoteExceptionAnnot(isRemoteClass, hasPublicBitSet(flags), m)
921918
val (throws, others) = m.annotations partition (_.symbol == definitions.ThrowsClass)
922919
val thrownExceptions: List[String] = getExceptions(throws)
@@ -937,7 +934,7 @@ abstract class BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
937934

938935
mirrorMethod.visitCode()
939936

940-
mirrorMethod.visitFieldInsn(asm.Opcodes.GETSTATIC, moduleName, strMODULE_INSTANCE_FIELD, classBTypeFromSymbol(module).descriptor)
937+
mirrorMethod.visitFieldInsn(asm.Opcodes.GETSTATIC, moduleName, strMODULE_INSTANCE_FIELD, classBTypeFromSymbol(moduleClass).descriptor)
941938

942939
var index = 0
943940
for(jparamType <- paramJavaTypes) {

src/library/scala/remote.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ package scala
2424
* }
2525
* }}}
2626
*/
27+
@deprecated("extend java.rmi.Remote instead and add @throws[java.rmi.RemoteException] to public methods", "2.12.0")
2728
class remote extends scala.annotation.StaticAnnotation {}

test/files/jvm/annotations.check

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
annotations.scala:7: warning: class remote in package scala is deprecated (since 2.12.0): extend java.rmi.Remote instead and add @throws[java.rmi.RemoteException] to public methods
2+
def foo: Unit = ()
3+
^
14
class java.rmi.RemoteException
25
class java.io.IOException
36
@java.lang.Deprecated()

test/files/jvm/annotations.flags

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-deprecation

0 commit comments

Comments
 (0)