Skip to content

Commit f7f45d6

Browse files
authored
Merge pull request #54 from abego/wrong_dotj2s_literal
Bug: J2S compiler not activated on Linux/macOS (Wrong ".J2S" file name)
2 parents 4c08840 + 7622dc6 commit f7f45d6

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

sources/net.sf.j2s.core/src/net/sf/j2s/core/compiler/Java2ScriptCompiler.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,15 @@
1818
import java.util.Map;
1919
import java.util.Properties;
2020

21-
import org.eclipse.core.resources.IContainer;
2221
import org.eclipse.core.resources.IFile;
2322
import org.eclipse.core.resources.IProject;
2423
import org.eclipse.jdt.core.JavaCore;
2524
import org.eclipse.jdt.core.dom.AST;
2625
import org.eclipse.jdt.core.dom.ASTParser;
2726
import org.eclipse.jdt.core.dom.CompilationUnit;
28-
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
29-
import org.eclipse.jdt.internal.core.builder.SourceFile;
3027

3128
import net.sf.j2s.core.CorePlugin;
3229
import net.sf.j2s.core.astvisitors.Java2ScriptVisitor;
33-
//import net.sf.j2s.core.builder.SourceFile;
34-
//import net.sf.j2s.core.builder.SourceFileProxy;
35-
//import net.sf.j2s.core.hotspot.InnerHotspotServer;
3630

3731
/**
3832
* The main (and currently only operational) Java2Script compiler.
@@ -42,7 +36,11 @@
4236
*/
4337
@SuppressWarnings("restriction")
4438
public class Java2ScriptCompiler {
45-
39+
/**
40+
* The name of the J2S options file, aka as the "Dot-j2s" file.
41+
*/
42+
public static final String J2S_OPTIONS_FILE_NAME = ".j2s";
43+
4644
// BH: added "true".equals(getProperty(props,
4745
// "j2s.compiler.allow.compression")) to ensure compression only occurs when
4846
// desired
@@ -83,8 +81,8 @@ public class Java2ScriptCompiler {
8381

8482
public static boolean isActive(IProject project) {
8583
try {
86-
return new File(project.getProject().getLocation().toOSString(), ".J2S").exists();
87-
} catch (Exception e) {
84+
return new File(project.getProject().getLocation().toOSString(), J2S_OPTIONS_FILE_NAME).exists();
85+
} catch (@SuppressWarnings("unused") Exception e) {
8886
return false;
8987
}
9088
}
@@ -141,7 +139,7 @@ public boolean initializeProject(IProject project, boolean isCompilationParticip
141139
projectFolder = project.getLocation().toOSString();
142140
props = new Properties();
143141
try {
144-
File j2sFile = new File(projectFolder, ".j2s");
142+
File j2sFile = new File(projectFolder, J2S_OPTIONS_FILE_NAME);
145143
props.load(new FileInputStream(j2sFile));
146144
String status = getProperty("j2s.compiler.status");
147145
if (!"enable".equals(status) && !"enabled".equals(status)) {

0 commit comments

Comments
 (0)