Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sources/net.sf.j2s.core/dist/build-core.xml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@

<target name="call-core" id="call-core">
<echo>......Creating core${call-core.name}.js</echo>
<concat destfile="${site.path}/js/core/tmp.js">
<concat destfile="${site.path}/js/core/tmp.js" fixlastline="yes">
<filelist dir="${site.path}/j2s" files="${call-core.list}" />
</concat>

Expand Down
Binary file modified sources/net.sf.j2s.core/dist/swingjs/SwingJS-site.zip
Binary file not shown.
Binary file modified sources/net.sf.j2s.core/dist/swingjs/net.sf.j2s.core.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion sources/net.sf.j2s.core/dist/swingjs/timestamp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20200125163539
20200201153353
Binary file modified sources/net.sf.j2s.core/dist/swingjs/ver/3.2.7/SwingJS-site.zip
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion sources/net.sf.j2s.core/dist/swingjs/ver/3.2.7/timestamp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20200125163539
20200201153353
5 changes: 4 additions & 1 deletion sources/net.sf.j2s.core/src/net/sf/j2s/core/CorePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ public class CorePlugin extends Plugin {
* "net.sf.j2s.core.jar" not "net.sf.j2s.core.3.2.5"
*
*/
public static String VERSION = "3.2.7-v3";
public static String VERSION = "3.2.7-v5";
// BH 2020.01.31 -- 3.2.7-v5 'L' used instead of 'J' in $fields$
// BH 2020.01.31 -- 3.2.7-v5 java.lang.reflect.* should not be truncated to reflect.* in parameters
// BH 2020.01.16 -- 3.2.7-v4 replaces extends java.awt.Component and javax.swing.JComponent
// BH 2020.01.12 -- 3.2.7-v3 fixes JAXB annotation marshalling for 3.2.7
// BH 2020.01.11 -- 3.2.7-v3 corrects and rewrites synthetic bridge creation with much cleaner heap usage
// BH 2020.01.09 -- 3.2.7-v2 introduces @j2sAlias as a way of adding a custom method name, as in exports.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@

// TODO: superclass inheritance for JAXB XmlAccessorType

//BH 2020.01.31 -- 3.2.7-v5 'L' used instead of 'J' in $fields$
//BH 2020.01.31 -- 3.2.7-v5 java.lang.reflect.* should not be truncated to reflect.*
//BH 2020.01.16 -- 3.2.7-v4 replaces extends java.awt.Component and javax.swing.JComponent
//BH 2020.01.12 -- 3.2.7-v3 fixes JAXB annotation marshalling for 3.2.7
//BH 2020.01.11 -- 3.2.7-v3 corrects and rewrites synthetic bridge creation with much cleaner heap usage
Expand Down Expand Up @@ -535,7 +537,7 @@ private char getLastCharInBuffer() {

// order above can be changed, but typeCode order must then be adapted

private final static String typeCodes = "ZBCDFILHSO";
private final static String typeCodes = "ZBCDFIJHSO";

private class FieldInfo {
@SuppressWarnings("unchecked")
Expand Down Expand Up @@ -2656,7 +2658,6 @@ private void addEnumConstants(EnumDeclaration e, List<EnumConstantDeclaration> e
*
*
* @param field the field being declared
* @param fields
* @param isStatic
* @return true if anything was written to the buffer
*/
Expand Down Expand Up @@ -4831,9 +4832,12 @@ private String getMyJavaClassNameLambda(boolean andIncrement) {

static String stripJavaLang(String name) {
// shorten java.lang.XXX.YYY but not java.lang.xxx.YYY
String s = (!name.startsWith("java.lang.") || name.equals("java.lang.Object")
|| name.length() > 10 && !Character.isUpperCase(name.charAt(10)) ? name : name.substring(10));
return s;
return (
!name.startsWith("java.lang.")
|| name.equals("java.lang.Object")
|| name.length() > 10 && !Character.isUpperCase(name.charAt(10)) ?
name :
name.substring(10));
}

/**
Expand Down Expand Up @@ -5563,7 +5567,7 @@ private String j2sGetParamCode(ITypeBinding binding) {
name = "S";
break;
default:
name = NameMapper.checkClassReplacement(name).replace("java.lang.", "").replace('.', '_');
name = stripJavaLang(NameMapper.checkClassReplacement(name)).replace('.', '_');
break;
}
if (arrays != null) {
Expand Down
2 changes: 1 addition & 1 deletion sources/net.sf.j2s.java.core/build-core-applet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

<target name="call-core" id="call-core">
<echo>......Creating core${call-core.name}.js</echo>
<concat destfile="${site.path}/js/core/tmp.js">
<concat destfile="${site.path}/js/core/tmp.js" fixlastline="yes">
<filelist dir="${site.path}/j2s" files="${call-core.list}" />
</concat>

Expand Down
Binary file modified sources/net.sf.j2s.java.core/dist/SwingJS-site.zip
Binary file not shown.
7 changes: 7 additions & 0 deletions sources/net.sf.j2s.java.core/doc/numberOfClasses.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
3131 SwingJS
1484 Jalview
641 Physlets
1135 Jmol
79 CIFtools
6674 VBRC
1197 MathePrisma
36 changes: 25 additions & 11 deletions sources/net.sf.j2s.java.core/src/java/lang/Class.java
Original file line number Diff line number Diff line change
Expand Up @@ -723,12 +723,15 @@ private String getName0() {
case "B":
code = "Byte";
break;
case "L":
case "J":
code = "Long";
break;
case "C":
code = "Character";
break;
case "O":
code = "Object";
break;
default:
return null;
}
Expand Down Expand Up @@ -1725,7 +1728,7 @@ public Map<String,Object[]> getFieldAnnMap(Object cl) {
* @since JDK1.1
*/
public Method[] getMethods() throws SecurityException {
return /*copyMethods*/(privateGetPublicMethods());
return /*copyMethods*/(privateGetPublicMethods(true));
}

/**
Expand Down Expand Up @@ -2169,7 +2172,7 @@ public Field[] getDeclaredFields() throws SecurityException {
* @since JDK1.1
*/
public Method[] getDeclaredMethods() throws SecurityException {
return getMethods();
return /*copyMethods*/(privateGetPublicMethods(false));
// // be very careful not to change the stack depth of this
// // checkMemberAccess call for security reasons
// // see java.lang.SecurityManager.checkMemberAccess
Expand Down Expand Up @@ -2630,7 +2633,7 @@ public static Class<?> getPrimitiveOrStringClass(String name) {
case "I":
case "int":
return Integer.TYPE;
case "L":
case "J":
case "long":
return Long.TYPE;
case "F":
Expand All @@ -2639,6 +2642,8 @@ public static Class<?> getPrimitiveOrStringClass(String name) {
case "D":
case "double":
return Double.TYPE;
case "O":
return Object.class;
default:
return null;
}
Expand Down Expand Up @@ -3034,7 +3039,7 @@ Method[] getArray() {
// Returns an array of "root" methods. These Method objects must NOT
// be propagated to the outside world, but must instead be copied
// via ReflectionFactory.copyMethod.
private Method[] privateGetPublicMethods() {
private Method[] privateGetPublicMethods(boolean isAll) {
if (isAnnotation()) {
if ($members$ == null) {
$members$ = AnnotationParser.JSAnnotationObject.createMethods((Class<? extends Annotation>) this);
Expand Down Expand Up @@ -3062,9 +3067,14 @@ private Method[] privateGetPublicMethods() {
*
* var p = this.$clazz$.prototype;
*
* for (attr in p) { o = p[attr]; if (typeof o == "function" &&
* o.exName && !o.__CLASS_NAME__ && o != this.$clazz$[attr] &&
* o.exClazz == this.$clazz$) { // there are polynormical methods.
* for (attr in p) { o = p[attr]; if (
* typeof o == "function"
* && o.exName
* && !o.__CLASS_NAME__
* && o != this.$clazz$[attr]
* && (isAll || o.exClazz == this.$clazz$)
* && !o.exName.startsWith("c$")
* ) { // there are polynormical methods.
*/

Method m = new Method(this, attr, UNKNOWN_PARAMETERS, Void.class, NO_PARAMETERS, Modifier.PUBLIC);
Expand All @@ -3076,9 +3086,13 @@ private Method[] privateGetPublicMethods() {
* ms.push(m);
* }}
* p = this.$clazz$;
* for (attr in p) { o = p[attr];if (typeof o ==
* "function" && o.exName && !o.__CLASS_NAME__ &&
* o.exClazz == this.$clazz$) {
* for (attr in p) { o = p[attr];if (
* typeof o == "function"
* && o.exName && !o.__CLASS_NAME__
* && (isAll || o.exClazz == this.$clazz$)
* && o.exName.indexOf("$") != 0
* && !o.exName.startsWith("c$")
* ) {
*/
m = new Method(this, attr, UNKNOWN_PARAMETERS, Void.class, NO_PARAMETERS, Modifier.PUBLIC);
m._setJSMethod(o, Modifier.STATIC);
Expand Down
11 changes: 8 additions & 3 deletions sources/net.sf.j2s.java.core/src/java/lang/reflect/Method.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public final class Method extends AccessibleObject implements GenericDeclaration
private Class<?> returnType;
private Class<?>[] parameterTypes;
private Class<?>[] exceptionTypes;
private int modifiers = Member.PUBLIC;
private int modifiers = PUBLIC;
boolean isProxy;

// private Annotation[] annotations;
Expand All @@ -57,7 +57,8 @@ public final class Method extends AccessibleObject implements GenericDeclaration
public Method(Class<?> declaringClass, String name, Class<?>[] paramTypes, Class<?> returnType,
Class<?>[] checkedExceptions, int modifiers) {
this.Class_ = declaringClass;
this.name = name;
int pt = name.indexOf("$");
this.name = (pt >= 0 ? name.substring(0, pt) : name);
this.parameterTypes = (paramTypes == null ? Class.NO_PARAMETERS : paramTypes);
this.returnType = returnType;
this.exceptionTypes = checkedExceptions;
Expand Down Expand Up @@ -396,7 +397,11 @@ public Class<?> getReturnType() {
}


// @Override
/**
* SwingJS method to retrieve actual JavaScript name.
*
* @return
*/
public String getSignature() {
return (String) signature;
}
Expand Down
9 changes: 4 additions & 5 deletions sources/net.sf.j2s.java.core/src/java/lang/reflect/Proxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -660,14 +660,13 @@ private static Class<?> defineClass0(ClassLoader loader, String name, Class<?>[]
*
* cl$.$clinit$ = 1;
* Clazz.newMeth(cl$, '$init$', function () {}, 1);
* Clazz.newMeth(cl$, "c$$reflect_InvocationHandler", function(h) {
* cl$.superclazz.c$$reflect_InvocationHandler.apply(this, [h]);
* Clazz.newMeth(cl$, "c$$java_lang_reflect_InvocationHandler", function(h) {
* cl$.superclazz.c$$java_lang_reflect_InvocationHandler.apply(this, [h]);
* cl$.$init$.apply(this);
* }, 1);
*
*
*/
{}
for (int i = 0; i < interfaces.length; i++) {
Method[] methods = interfaces[i].getDeclaredMethods();
for (int j = 0; j < methods.length; j++) {
Expand All @@ -681,7 +680,7 @@ private static Class<?> defineClass0(ClassLoader loader, String name, Class<?>[]

@SuppressWarnings("unused")
private static void setJSPrototype(Class<?> cl, Method m, boolean add$) {
String mname = m.getName();
String mname = m.getSignature();

// SwingJS transfers the invocation to a temporary method, then invokes it
/**
Expand All @@ -692,7 +691,7 @@ private static void setJSPrototype(Class<?> cl, Method m, boolean add$) {
* cl.$clazz$.prototype[mname] = cl.$clazz$.prototype[mname1] =
* function() { var args = new Array(arguments.length); for (var k =
* arguments.length; --k >= 0;)args[k] = arguments[k];
* return(this.h.invoke$O$reflect_Method$OA(this, m, args)); }
* return(this.h.invoke$O$java_lang_reflect_Method$OA(this, m, args)); }
*/
}
}
Loading