Micro places compiled Java programs into incorrect directory when auto-compiling
Description of the problem or steps to reproduce
Upon saving any Java program that throws no compiler errors, Micro will automatically compile and save a .class file with the same name as the .java file that was saved. However, when certain .java programs are saved as part of a package, Micro will place the compiled file in the wrong directory.
To reproduce:
- Create a directory to serve as your project source. I'm using
~/Documents/JavaProjects/ProjectSource, but you can use anything, and I'll just refer to this assrcfrom now on. - Create a folder such as
src/MyPackage. - Navigate to
src/MyPackageand, using Micro, create a file such assrc/MyPackage/PackagedClass.java. The class should includepackage MyPackage;as the first line, and the contents can probably be anything, as long as the result is a valid Java class. Upon saving, notice that Micro has taken the liberty of creating a new directory,src/MyPackage/MyPackage, and within this new directory, the compiled.classfile can be found,src/MyPackage/MyPackage/PackagedClass.class. This is the crux of the issue. When correctly compiled, the resulting compiled class should be found in the same directory as the original.javafile. (The reason this is an issue is because a developer may wish to structure their.javafiles in accordance with their package structure, and so having Micro create the compiled.classfiles in the wrong directory creates hassle and confusion).
I've also been able to create situations where a .java file in the default package causes the same issue on a much larger scale. For example, I had a situation where I had a file in /home/[User]/Documents/JavaProjects/TestCore/Test.java that, when saved after being edited with Micro, created a class in /home/[User]/Documents/JavaProjects/TestCore/home/[User]/Documents/JavaProjects/TestCore/Test.class, and I have... no idea how or why this happens. I'm not able to consistently reproduce it, with some projects it happens and with some it doesn't
I apologize if I have made any errors in my explanation, and please let me know if there is anything I should clarify or change.
Specifications
Commit hash: 68d88b57 OS: Linux Terminal: Konsole (KDE's Terminal Emulator)
Source: micro-editor/micro