Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kotlin: On linux with encrypted home: java.io.FileNotFoundException (File name too long)

Tags:

java

kotlin

Under an encrypted linux home directory my Kotlin build (using maven) is failing with a "java.io.FileNotFoundException (File name too long)".

The filename looks something like this, and is 298 characters long:

/home/niel/projects/project/bla/.../bla/.../bla/SomeTest$test name with spaces$1.class

The test looks something like this:

@Test
fun `test with nice descriptive name`() {
    // ...
}

getconf NAME_MAX / returns 255, more than the 298 of the file name.

Scala has a way of dealing with this using the max-classfile-name option.

Is there a solution for this in Kotlin?

like image 434
Niel de Wet Avatar asked Jan 19 '18 09:01

Niel de Wet


2 Answers

I've been bumping my head on the same issue. The problem is exacerbated (occurs primarily?) when using lambdas inside of such descriptively named test methods.

In my case I'm using ecryptfs with encrypted filenames on top of ext4. Given the payload and padding that's added to the start of the filename by ecryptfs, it seems that ~140 bytes is the usable maximum filename length.

I don't know of a mechanism in Kotlin for working around this problem, but if you're using JUnit 5 you could make use of the @DisplayName annotation for your more verbose test names.

like image 67
Robert Taylor Avatar answered Sep 24 '22 00:09

Robert Taylor


You could use the @JvmName annotation to rename your test I believe. See the reference and the api

like image 22
snowe Avatar answered Sep 26 '22 00:09

snowe