summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2014-01-29 11:22:38 +0100
committerJason Zaugg <jzaugg@gmail.com>2014-01-29 11:22:38 +0100
commitd8c78502b356256f9e098374f505fd883b6b84e2 (patch)
tree85e182e81c4d0de97dfad9b60bd13210ffb8f38f /test
parent1e9dcc2ed603e7179b7b5eee9212e73f773b02fd (diff)
downloadscala-d8c78502b356256f9e098374f505fd883b6b84e2.tar.gz
scala-d8c78502b356256f9e098374f505fd883b6b84e2.tar.bz2
scala-d8c78502b356256f9e098374f505fd883b6b84e2.zip
SI-8199 Account for module class suffix in -Xmax-classfile-name
The class file name of an inner class is based on the flattened name of its owner chain. But, if this is going to be unreasonably long, it is shortened with the help of a MD5 hash. However, after this shortening takes place, we sneakily add one more character (the infamous '$') to the name when it is used for the module class. It is thus possible to exceed the limit by one. The enclosed test failed on Mac with "filename too long" because of this. I have also tested for trait implementatation classes, but these seem to be suffixed with "$class" before the name compactification runs, so they weren't actually a problem. This change is binary incompatible as separately compiled defintions and usages of named, inner classes need to agree on this setting. Most typically, however, these long names crop up for inner anonymous classes / functions, which are not prone to the binary incompatiblity, assuming that their creation hasn't be inlined to a separately compiled client.
Diffstat (limited to 'test')
-rw-r--r--test/files/run/t8199.scala105
1 files changed, 105 insertions, 0 deletions
diff --git a/test/files/run/t8199.scala b/test/files/run/t8199.scala
new file mode 100644
index 0000000000..50994159ed
--- /dev/null
+++ b/test/files/run/t8199.scala
@@ -0,0 +1,105 @@
+class reallylongnamereallylongnamereallylongnamereallylongnamereallylongnamereallylongnamereallylongnamereallylongnamereallylongnamereallylongnamereallylongnamereallylongnamereallylongnamereallylongnamereallylongnamereallylongnamereallylongname {
+object obj0
+object obj01
+object obj012
+object obj0123
+object obj01234
+object obj012345
+object obj0123456
+object obj01234567
+object obj012345678
+object obj0123456789
+object obj01234567890
+class cls0
+class cls01
+class cls012
+class cls0123
+class cls01234
+class cls012345
+class cls0123456
+class cls01234567
+class cls012345678
+class cls0123456789
+class cls01234567890
+trait trt0 { def x = Test.checkCallerImplClassName() }
+trait trt01 { def x = Test.checkCallerImplClassName() }
+trait trt012 { def x = Test.checkCallerImplClassName() }
+trait trt0123 { def x = Test.checkCallerImplClassName() }
+trait trt01234 { def x = Test.checkCallerImplClassName() }
+trait trt012345 { def x = Test.checkCallerImplClassName() }
+trait trt0123456 { def x = Test.checkCallerImplClassName() }
+trait trt01234567 { def x = Test.checkCallerImplClassName() }
+trait trt012345678 { def x = Test.checkCallerImplClassName() }
+trait trt0123456789 { def x = Test.checkCallerImplClassName() }
+trait trt01234567890 { def x = Test.checkCallerImplClassName() }
+}
+
+object Test extends App {
+ def check(c: Class[_]) {
+ checkClassName(c.getName)
+ }
+ def checkClassName(name: String) {
+ val defaultMaxClassFileLength = 255
+ assert((name + ".class").length <= defaultMaxClassFileLength, name)
+ }
+ def checkCallerImplClassName() {
+ val name = Thread.currentThread.getStackTrace.apply(2).getClassName
+ assert(name.contains("$class"))
+ Test.checkClassName(name)
+ }
+
+ val c = new reallylongnamereallylongnamereallylongnamereallylongnamereallylongnamereallylongnamereallylongnamereallylongnamereallylongnamereallylongnamereallylongnamereallylongnamereallylongnamereallylongnamereallylongnamereallylongnamereallylongname
+ import c._
+
+ check(obj0.getClass)
+ check(obj01.getClass)
+ check(obj012.getClass)
+ check(obj0123.getClass)
+ check(obj01234.getClass)
+ check(obj012345.getClass)
+ check(obj0123456.getClass)
+ check(obj01234567.getClass)
+ check(obj012345678.getClass)
+ check(obj0123456789.getClass)
+ check(obj01234567890.getClass)
+
+ check(classOf[cls0])
+ check(classOf[cls01])
+ check(classOf[cls012])
+ check(classOf[cls0123])
+ check(classOf[cls01234])
+ check(classOf[cls012345])
+ check(classOf[cls0123456])
+ check(classOf[cls01234567])
+ check(classOf[cls012345678])
+ check(classOf[cls0123456789])
+ check(classOf[cls01234567890])
+
+ // interface facets
+ check(classOf[trt0])
+ check(classOf[trt01])
+ check(classOf[trt012])
+ check(classOf[trt0123])
+ check(classOf[trt01234])
+ check(classOf[trt012345])
+ check(classOf[trt0123456])
+ check(classOf[trt01234567])
+ check(classOf[trt012345678])
+ check(classOf[trt0123456789])
+ check(classOf[trt01234567890])
+
+ // impl classes are harder to find the names of to test!
+ (new trt0 {}).x
+ (new trt01 {}).x
+ (new trt012 {}).x
+ (new trt0123 {}).x
+ (new trt01234 {}).x
+ (new trt012345 {}).x
+ (new trt0123456 {}).x
+ (new trt01234567 {}).x
+ (new trt012345678 {}).x
+ (new trt0123456789 {}).x
+ (new trt01234567890 {}).x
+}
+
+// filename too long: reallylongnamereallylongnamereallylongnamereallylongnamereallylongnamereallylongnamereallylongnamereallylongnamereallylongnamereallylongnamereallylongnamereallylongnamereallylongnamereallylongnamereallylongnamereallylongnamereallylongname$obj012345$.class