diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2014-01-29 11:22:38 +0100 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2014-01-29 11:22:38 +0100 |
commit | d8c78502b356256f9e098374f505fd883b6b84e2 (patch) | |
tree | 85e182e81c4d0de97dfad9b60bd13210ffb8f38f /src | |
parent | 1e9dcc2ed603e7179b7b5eee9212e73f773b02fd (diff) | |
download | scala-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 'src')
-rw-r--r-- | src/reflect/scala/reflect/internal/StdNames.scala | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/reflect/scala/reflect/internal/StdNames.scala b/src/reflect/scala/reflect/internal/StdNames.scala index 7015105261..01881c6693 100644 --- a/src/reflect/scala/reflect/internal/StdNames.scala +++ b/src/reflect/scala/reflect/internal/StdNames.scala @@ -53,14 +53,17 @@ trait StdNames { * * We obtain the formula: * - * FileNameLength = 2*(MaxNameLength / 4) + 2.marker.length + 32 + 6 + * FileNameLength = 2*(MaxNameLength / 4) + 2.marker.length + 32 + suffixLength * - * (+6 for ".class"). MaxNameLength can therefore be computed as follows: + * (+suffixLength for ".class" and potential module class suffix that is added *after* this transform). + * + * MaxNameLength can therefore be computed as follows: */ val marker = "$$$$" + val maxSuffixLength = "$.class".length + 1 // potential module class suffix and file extension val MaxNameLength = math.min( - settings.maxClassfileName.value - 6, - 2 * (settings.maxClassfileName.value - 6 - 2*marker.length - 32) + settings.maxClassfileName.value - maxSuffixLength, + 2 * (settings.maxClassfileName.value - maxSuffixLength - 2*marker.length - 32) ) def toMD5(s: String, edge: Int): String = { val prefix = s take edge |