Skip to content

File name too long error #14129

@rickie

Description

@rickie

I use Linux Ubuntu 20.04.1 on my machine and my file system is encrypted with eCryptfs. As a result, there is a maximum allowed filename size for folders and files. For context, see this StackOverflow question.

If I do a mvn clean install on Checkstyle master, I end up with the following error:

[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /home/rick/repos/oss/checkstyle/src/test/resources/com/puppycrawl/tools/checkstyle/checks/modifier/redundantmodifier/InputRedundantModifierNestedClassInPublicInterfaceRedundantModifiers.java:[14,13] error while writing com.puppycrawl.tools.checkstyle.checks.modifier.redundantmodifier.InputRedundantModifierNestedClassInPublicInterfaceRedundantModifiers.PublicInnerInterface.PublicInnerInnerInterface.PublicInnerClassInNestedPublicInterfaces: /home/rick/repos/oss/checkstyle/target/test-classes/com/puppycrawl/tools/checkstyle/checks/modifier/redundantmodifier/InputRedundantModifierNestedClassInPublicInterfaceRedundantModifiers$PublicInnerInterface$PublicInnerInnerInterface$PublicInnerClassInNestedPublicInterfaces.class: File name too long

The problem is that the names of all the inner classes and interfaces are chained together with a $ in between for the file names. This results in fairly long file names as can be seen in the example.

I realize this is quite an uncommon case and asking the following feels like a long shot, but here is my question.
Would you be open to fixing this problem? If yes, I'm open to creating a PR for it based on your decision on how to best fix this. The simple way would of course be renaming some of the classes and interfaces, to prevent this problem from happening. However, I can see how this is not an ideal way of fixing this.

To give you a potential solution, see this diff.
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/modifier/RedundantModifierCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/modifier/RedundantModifierCheckTest.java
index af4601e7f..c7a01f7c6 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/modifier/RedundantModifierCheckTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/modifier/RedundantModifierCheckTest.java
@@ -135,7 +135,7 @@ public class RedundantModifierCheckTest
        };

        verifyWithInlineConfigParser(
-            getPath("InputRedundantModifierNestedClassInPublicInterfaceRedundantModifiers.java"),
+            getPath("InputRedundantModifierNestedClassInInt.java"),
            expected);
    }
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/modifier/redundantmodifier/InputRedundantModifierNestedClassInPublicInterfaceRedundantModifiers.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/modifier/redundantmodifier/InputRedundantModifierNestedClassInInt.java
similarity index 60%
rename from src/test/resources/com/puppycrawl/tools/checkstyle/checks/modifier/redundantmodifier/InputRedundantModifierNestedClassInPublicInterfaceRedundantModifiers.java
rename to src/test/resources/com/puppycrawl/tools/checkstyle/checks/modifier/redundantmodifier/InputRedundantModifierNestedClassInInt.java
index 03a0cb906..bafe3ca16 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/modifier/redundantmodifier/InputRedundantModifierNestedClassInPublicInterfaceRedundantModifiers.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/modifier/redundantmodifier/InputRedundantModifierNestedClassInInt.java
@@ -8,7 +8,7 @@ tokens = (default)METHOD_DEF, VARIABLE_DEF, ANNOTATION_FIELD_DEF, INTERFACE_DEF,

package com.puppycrawl.tools.checkstyle.checks.modifier.redundantmodifier;

-public interface InputRedundantModifierNestedClassInPublicInterfaceRedundantModifiers {
+public interface InputRedundantModifierNestedClassInInt {
    interface PublicInnerInterface {
        interface PublicInnerInnerInterface {
            class PublicInnerClassInNestedPublicInterfaces {
@@ -16,14 +16,14 @@ public interface InputRedundantModifierNestedClassInPublicInterfaceRedundantModi
            }
        }
    }
-    class PublicClassInsideInterface {
-        private interface PrivateNestedInterface {
-            class ClassInPrivateNestedInterface {
-                public ClassInPrivateNestedInterface() { } // violation
+    class PublicClassInsideInt {
+        private interface PrivateNestedInt {
+            class ClassInPrivateNestedInt {
+                public ClassInPrivateNestedInt() { } // violation
            }
-            public interface PrivateNestedInterfaceWithPublicModifier { // violation
-                class ClassInPrivateNestedInterface {
-                    public ClassInPrivateNestedInterface() { } // violation
+            public interface PrivateNestedIntWithPublicModifier { // violation
+                class ClassInPrivateNestedInt {
+                    public ClassInPrivateNestedInt() { } // violation
                }
            }
        }
@@ -33,13 +33,13 @@ public interface InputRedundantModifierNestedClassInPublicInterfaceRedundantModi
            }
        }
        protected interface PublicInnerInnerProtectedInterface {
-          class PublicInnerClassInNestedProtectedInterfaces {
-           public PublicInnerClassInNestedProtectedInterfaces() { } // violation
+          class PublicInnerClassInNestedProtectedInt {
+           public PublicInnerClassInNestedProtectedInt() { } // violation
          }
        }
    }
-    class PublicNestedClassInInterfaceWithPublicConstructor {
-        public PublicNestedClassInInterfaceWithPublicConstructor() { } // OK in public class
+    class PublicNestedClassInInterfaceWithPublicConst {
+        public PublicNestedClassInInterfaceWithPublicConst() { } // OK in public class
        private class PrivateClassInPublicNestedClass {
            public class PublicInPrivateClass {
                public PublicInPrivateClass() { } // violation

This was identified by working with our integration-test framework from Error Prone Support, which also identified this issue: #14042.

Let me know if I need to clarify something or elaborate.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions