Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a java file to a jar results in a space in front of the path. #291

Closed
RobertZenz opened this issue Aug 29, 2019 · 0 comments · Fixed by #292
Closed

Adding a java file to a jar results in a space in front of the path. #291

RobertZenz opened this issue Aug 29, 2019 · 0 comments · Fixed by #292

Comments

@RobertZenz
Copy link

I'm not sure whether this is a bug in Engrampa itself, as I can reproduce the same with the GNOME Archiver.

If you create a jar (by creating a zip and renaming it) and then drop a java source file into it, the directory structure according to the java source file is being created inside the archive. However, the path is prepended with a space which should not be there.

  1. Create a new zip archive with any file in it.
  2. Rename it from "file.zip" to "file.jar".
  3. Grab a java file (for example this one) and drag it into the archive.
  4. The folder structure according to the java package of the source file has been created ("org/bonsaimind/jmathpaper/Main.java").

Trying to delete or edit the file will be met with an error message. When listing the files with unzip -l file.jar we find the following output:

Archive:  file.jar
  Length      Date    Time    Name
---------  ---------- -----   ----
     2105  2019-04-22 13:26   overlord.text
     6228  2019-08-29 21:40    org/bonsaimind/jmathpaper/Main.java
---------                     -------
     8333                     2 files

You can clearly see that a space has been added to the directory structure.

What is even more confusing, is that any leading space is ignored by Engrampa. So we can have a file like this:

Archive:  file.jar
  Length      Date    Time    Name
---------  ---------- -----   ----
     2105  2019-04-22 13:26   overlord.text
     6228  2019-08-29 21:40   org/bonsaimind/jmathpaper/AnotherFile.java
     6228  2019-08-29 21:40    org/bonsaimind/jmathpaper/Main.java
---------                     -------
     8333                     2 files

And Engrampa will display it as one "org" directory.

rbuj added a commit that referenced this issue Aug 29, 2019
Closes #291

Test:

touch test.txt
zip test.zip test.txt
mv test.zip test.jar
cat << EOF > HelloWorld.java
package org.mate.tests;

class HelloWorld
{
    public static void main(String args[])
    {
        System.out.println("Hello, World");
    }
}
EOF
engrampa -a test.jar HelloWorld.java
jar tf ~/test.jar

Output:

test.txt
org/mate/tests/HelloWorld.java
rbuj added a commit that referenced this issue Aug 29, 2019
Closes #291

Test:

touch test.txt
zip test.zip test.txt
mv test.zip test.jar
cat << EOF > HelloWorld.java
package org.mate.tests;

class HelloWorld
{
    public static void main(String args[])
    {
        System.out.println("Hello, World");
    }
}
EOF
engrampa -a test.jar HelloWorld.java
jar tf ~/test.jar

Output:

test.txt
org/mate/tests/HelloWorld.java
rbuj added a commit that referenced this issue Aug 29, 2019
Closes #291

Test:

touch test.txt
zip test.zip test.txt
mv test.zip test.jar
cat << EOF > HelloWorld.java
package org.mate.tests;

class HelloWorld
{
    public static void main(String args[])
    {
        System.out.println("Hello, World");
    }
}
EOF
engrampa -a test.jar HelloWorld.java
jar tf test.jar

Output:

test.txt
org/mate/tests/HelloWorld.java
raveit65 pushed a commit that referenced this issue Sep 2, 2019
Closes #291

Test:

touch test.txt
zip test.zip test.txt
mv test.zip test.jar
cat << EOF > HelloWorld.java
package org.mate.tests;

class HelloWorld
{
    public static void main(String args[])
    {
        System.out.println("Hello, World");
    }
}
EOF
engrampa -a test.jar HelloWorld.java
jar tf test.jar

Output:

test.txt
org/mate/tests/HelloWorld.java
rbuj added a commit that referenced this issue Sep 2, 2019
Closes #291

Test:

touch test.txt
zip test.zip test.txt
mv test.zip test.jar
cat << EOF > HelloWorld.java
package org.mate.tests;

class HelloWorld
{
    public static void main(String args[])
    {
        System.out.println("Hello, World");
    }
}
EOF
engrampa -a test.jar HelloWorld.java
jar tf test.jar

Output:

test.txt
org/mate/tests/HelloWorld.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant