Skip to content

Commit 4ae9de6

Browse files
committed
adds zlib; deprecation of .j2smap
1 parent 1ffe0e0 commit 4ae9de6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+10129
-546
lines changed

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

Lines changed: 63 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@
88
import java.text.SimpleDateFormat;
99
import java.util.ArrayList;
1010
import java.util.Date;
11-
import java.util.HashMap;
1211
import java.util.Iterator;
1312
import java.util.List;
14-
import java.util.Map;
1513
import java.util.Properties;
1614
import java.util.regex.Matcher;
1715
import java.util.regex.Pattern;
@@ -24,11 +22,10 @@
2422
import org.eclipse.jdt.core.dom.CompilationUnit;
2523
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
2624

27-
import net.sf.j2s.core.astvisitors.ASTJ2SMapVisitor;
25+
import net.sf.j2s.core.astvisitors.ASTEmptyVisitor;
2826
import net.sf.j2s.core.astvisitors.ASTScriptVisitor;
2927
import net.sf.j2s.core.astvisitors.ASTVariableVisitor;
3028
import net.sf.j2s.core.astvisitors.DependencyASTVisitor;
31-
import net.sf.j2s.core.astvisitors.NameConvertItem;
3229
import net.sf.j2s.core.astvisitors.SWTDependencyASTVisitor;
3330
import net.sf.j2s.core.astvisitors.SWTScriptVisitor;
3431
import net.sf.j2s.core.builder.SourceFile;
@@ -161,7 +158,8 @@ public void process(ICompilationUnit sourceUnit, IContainer binaryFolder) {
161158
}
162159
}
163160
if (dvisitor == null) {
164-
dvisitor = new SWTDependencyASTVisitor();
161+
// BH - we are done with SWT dvisitor = new SWTDependencyASTVisitor();
162+
dvisitor = new DependencyASTVisitor();
165163
}
166164
}
167165
try {
@@ -206,6 +204,7 @@ public void process(ICompilationUnit sourceUnit, IContainer binaryFolder) {
206204
visitor = new SWTScriptVisitor();
207205
}
208206
}
207+
ASTEmptyVisitor.setNoQualifiedNamePackages(props.getProperty("j2s.compiler.method.overloading"));
209208
boolean ignoreMethodOverloading = !("enable".equals(props.getProperty("j2s.compiler.method.overloading")));
210209
visitor.setSupportsMethodOverloading(!ignoreMethodOverloading);
211210
boolean supportsInterfaceCasting = "enable".equals(props.getProperty("j2s.compiler.interface.casting"));
@@ -215,13 +214,12 @@ public void process(ICompilationUnit sourceUnit, IContainer binaryFolder) {
215214
boolean isDebugging = "debug".equals(props.getProperty("j2s.compiler.mode"));
216215
visitor.setDebugging(isDebugging);
217216
dvisitor.setDebugging(isDebugging);
218-
boolean toCompress = "enable".equals(props.getProperty("j2s.compiler.allow.compression"))
219-
&& "release".equals(props.getProperty("j2s.compiler.mode")); // BH added
217+
boolean toCompress = false; //"enable".equals(props.getProperty("j2s.compiler.allow.compression"))); // BH
220218
((ASTVariableVisitor) visitor.getAdaptable(ASTVariableVisitor.class)).setToCompileVariableName(toCompress);
221219
dvisitor.setToCompileVariableName(toCompress);
222-
if (toCompress) {
223-
updateJ2SMap(prjFolder);
224-
}
220+
// if (toCompress) {
221+
// updateJ2SMap(prjFolder);
222+
// }
225223
errorOccurred = false;
226224
try {
227225
root.accept(visitor);
@@ -248,61 +246,61 @@ public void process(ICompilationUnit sourceUnit, IContainer binaryFolder) {
248246
}
249247
}
250248

251-
public static void updateJ2SMap(String prjFolder) {
252-
File j2sMap = new File(prjFolder, ".j2smap");
253-
if (j2sMap.exists()) {
254-
String mapStr = FileUtil.readSource(j2sMap);
255-
if (mapStr != null) {
256-
String lastClassName = null;
257-
Map<String, NameConvertItem> varList = new HashMap<String, NameConvertItem>();
258-
String[] lines = mapStr.split("\r\n|\r|\n");
259-
for (int j = 0; j < lines.length; j++) {
260-
String line = lines[j].trim();
261-
if (line.length() > 0) {
262-
if (!line.startsWith("#")) {
263-
int index = line.indexOf("=");
264-
if (index != -1) {
265-
String key = line.substring(0, index).trim();
266-
String toVarName = line.substring(index + 1).trim();
267-
boolean isMethod = true;
268-
int idx = key.lastIndexOf('#');
269-
if (idx == -1) {
270-
isMethod = false;
271-
idx = key.lastIndexOf('.');
272-
if (idx == -1) {
273-
continue;
274-
}
275-
}
276-
String className = key.substring(0, idx);
277-
if (className.startsWith("$")) {
278-
if (lastClassName != null) {
279-
className = className.replaceAll("\\$", lastClassName);
280-
// System.out.println(className + "..." + lastClassName);
281-
} else {
282-
className = className.replaceAll("\\$", "");
283-
lastClassName = className;
284-
}
285-
} else {
286-
lastClassName = className;
287-
}
288-
String varName = key.substring(idx + 1);
289-
// System.out.println(className + "." + varName + "->" + toVarName);
290-
if (isMethod) {
291-
key = className + "#" + varName;
292-
} else {
293-
key = className + "." + varName;
294-
}
295-
varList.put(key, new NameConvertItem(className, varName, toVarName, isMethod));
296-
}
297-
}
298-
}
299-
}
300-
ASTJ2SMapVisitor.setJ2SMap(varList);
301-
return ;
302-
}
303-
}
304-
ASTJ2SMapVisitor.setJ2SMap(null);
305-
}
249+
// public static void updateJ2SMap(String prjFolder) {
250+
// File j2sMap = new File(prjFolder, ".j2smap");
251+
// if (j2sMap.exists()) {
252+
// String mapStr = FileUtil.readSource(j2sMap);
253+
// if (mapStr != null) {
254+
// String lastClassName = null;
255+
// Map<String, NameConvertItem> varList = new HashMap<String, NameConvertItem>();
256+
// String[] lines = mapStr.split("\r\n|\r|\n");
257+
// for (int j = 0; j < lines.length; j++) {
258+
// String line = lines[j].trim();
259+
// if (line.length() > 0) {
260+
// if (!line.startsWith("#")) {
261+
// int index = line.indexOf("=");
262+
// if (index != -1) {
263+
// String key = line.substring(0, index).trim();
264+
// String toVarName = line.substring(index + 1).trim();
265+
// boolean isMethod = true;
266+
// int idx = key.lastIndexOf('#');
267+
// if (idx == -1) {
268+
// isMethod = false;
269+
// idx = key.lastIndexOf('.');
270+
// if (idx == -1) {
271+
// continue;
272+
// }
273+
// }
274+
// String className = key.substring(0, idx);
275+
// if (className.startsWith("$")) {
276+
// if (lastClassName != null) {
277+
// className = className.replaceAll("\\$", lastClassName);
278+
//// System.out.println(className + "..." + lastClassName);
279+
// } else {
280+
// className = className.replaceAll("\\$", "");
281+
// lastClassName = className;
282+
// }
283+
// } else {
284+
// lastClassName = className;
285+
// }
286+
// String varName = key.substring(idx + 1);
287+
//// System.out.println(className + "." + varName + "->" + toVarName);
288+
// if (isMethod) {
289+
// key = className + "#" + varName;
290+
// } else {
291+
// key = className + "." + varName;
292+
// }
293+
// varList.put(key, new NameConvertItem(className, varName, toVarName, isMethod));
294+
// }
295+
// }
296+
// }
297+
// }
298+
// ASTJ2SMapVisitor.setJ2SMap(varList);
299+
// return ;
300+
// }
301+
// }
302+
// ASTJ2SMapVisitor.setJ2SMap(null);
303+
// }
306304

307305
public static void outputJavaScript(ASTScriptVisitor visitor, DependencyASTVisitor dvisitor, CompilationUnit fRoot,
308306
String folderPath, Properties props) {

sources/net.sf.j2s.java.core/.j2smap

Lines changed: 0 additions & 90 deletions
This file was deleted.

sources/net.sf.j2s.java.core/src/java/io/File.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,8 @@ public String[] list() {
10471047
* SecurityManager#checkRead(String)} method denies read access to
10481048
* the directory
10491049
*/
1050-
public String[] list(FilenameFilter filter) {
1050+
@SuppressWarnings({ "rawtypes", "unchecked" })
1051+
public String[] list(FilenameFilter filter) {
10511052
String names[] = list();
10521053
if ((names == null) || (filter == null)) {
10531054
return names;

0 commit comments

Comments
 (0)