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/dropins/timestamp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2018_07_22__14_28_50
20180724064133
1 change: 0 additions & 1 deletion sources/net.sf.j2s.core/dist/timestamp

This file was deleted.

Binary file modified sources/net.sf.j2s.java.core/dist/SwingJS-site.zip
Binary file not shown.
56 changes: 45 additions & 11 deletions sources/net.sf.j2s.java.core/src/java/awt/Font.java
Original file line number Diff line number Diff line change
Expand Up @@ -1161,6 +1161,7 @@ public String getFamily() {
return (family == null ? family = JSToolkit.getFontFamily(this) : family);
// return getFamily_NoClientCode();
}

// // NOTE: This method is called by privileged threads.
// // We implement this functionality in a package-private
// // method to insure that it cannot be overridden by client
Expand Down Expand Up @@ -1196,17 +1197,50 @@ public String getFamily() {
// return getFont2D().getFamilyName(l);
// }
//
// /**
// * Returns the postscript name of this <code>Font</code>.
// * Use <code>getFamily</code> to get the family name of the font.
// * Use <code>getFontName</code> to get the font face name of the font.
// * @return a <code>String</code> representing the postscript name of
// * this <code>Font</code>.
// * @since 1.2
// */
// public String getPSName() {
// return getFont2D().getPostscriptName();
// }
/**
* Returns the postscript name of this <code>Font</code>. Use
* <code>getFamily</code> to get the family name of the font. Use
* <code>getFontName</code> to get the font face name of the font.
*
* @return a <code>String</code> representing the postscript name of this
* <code>Font</code>.
* @since 1.2
*/
public String getPSName() {

// Serif Serif.plain Serif.bold Serif.italic
// SansSerif SansSerif.plain SansSerif.bold SansSerif.italic
// TimesRoman Serif.plain Serif.bold Serif.italic
// Helvetica SansSerif.plain SansSerif.bold SansSerif.italic
// Courier Monospaced.plain Monospaced.bold Monospaced.italic
// Monospaced Monospaced.plain Monospaced.bold Monospaced.italic
// Dialog Dialog.plain Dialog.bold Dialog.italic
// DialogInput DialogInput.plain DialogInput.bold DialogInput.italic

switch (name) {
case "TimesRoman":
name = SERIF;
break;
case "Helvetica":
name = SANS_SERIF;
break;
case "Courier":
name = MONOSPACED;
break;
default:
case MONOSPACED:
case SERIF:
case SANS_SERIF:
case DIALOG:
case DIALOG_INPUT:
break;
}
return name + (isPlain()? ".plain"
: "."
+ (isBold() ? "bold" : "")
+ (isItalic() ? "italic" : "")
);
}

/**
* Returns the logical name of this <code>Font</code>.
Expand Down
128 changes: 111 additions & 17 deletions sources/net.sf.j2s.java.core/src/java/lang/Class.java
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,7 @@ public String getName() {

// cache the name to reduce the number of calls into the VM
private transient String name;
private Field[] fields;

private String getName0() {
String code = "";
Expand Down Expand Up @@ -1534,12 +1535,15 @@ public Class<?>[] getClasses() {
* @since JDK1.1
*/
public Field[] getFields() throws SecurityException {
return null;
// // be very careful not to change the stack depth of this
// // checkMemberAccess call for security reasons
// // see java.lang.SecurityManager.checkMemberAccess
//// checkMemberAccess(Member.PUBLIC, ClassLoader.getCallerClassLoader());
// return copyFields(privateGetPublicFields(null));
if (fields != null)
return fields;
fields = new Field[0];
int _static = Modifier.STATIC;
Object cl = /** @j2sNative this.$clazz$ || */null;
Object proto = /** @j2sNative cl.prototype || */null;
addFields(proto, this.fields, 0);
addFields(cl, this.fields, _static);
return fields;
}

/**
Expand Down Expand Up @@ -1686,10 +1690,13 @@ public Constructor<?>[] getConstructors() throws SecurityException {
* @since JDK1.1
*/
public Field getField(String name) throws NoSuchFieldException, SecurityException {
// TODO
{
return null;
getFields();
for (int i = fields.length; --i >= 0;) {
if (fields[i].jsName == name)
return fields[i];
}
throw new NoSuchFieldException("field " + name);

// // be very careful not to change the stack depth of this
// // checkMemberAccess call for security reasons
// // see java.lang.SecurityManager.checkMemberAccess
Expand All @@ -1701,6 +1708,46 @@ public Field getField(String name) throws NoSuchFieldException, SecurityExceptio
// return field;
}

private void addFields(Object c, Field[] f, int modifiers) {
String m = null;
/**
* @j2sNative
*
* for (m in c) {
* if (!modifiers && this.$clazz$[m])
* continue;
* if (this.excludeField$S(m)) continue;
* var o = c[m];
* switch (typeof o) {
* case "object": if (o.__CLASS_NAME__) continue;
* case "number": case "boolean": case "string":
*/

addField(f, m, modifiers);

/**
* @j2sNative
* break;
* }
* }
*/

}

private boolean excludeField(String name) {
return (name == "prototype" || name.startsWith("__"));
}

private void addField(Field[] fields, String m, int modifiers) {

@SuppressWarnings("unused")
Field f = new Field(this, m, modifiers);
/**
* @j2sNative
*
* fields.push(f);
*/
}
/**
* Returns a {@code Method} object that reflects the specified public member
* method of the class or interface represented by this {@code Class}
Expand Down Expand Up @@ -1781,15 +1828,32 @@ public Method getMethod(String name, Class<?>... paramTypes) throws NoSuchMethod
// see java.lang.SecurityManager.checkMemberAccess
// checkMemberAccess(Member.PUBLIC, ClassLoader.getCallerClassLoader());

/**
* @j2sNative
*
* return Clazz.new_(java.lang.reflect.Method.c$$Class$S$ClassA$Class$ClassA$I, [this, name,
* paramTypes, java.lang.Void, [], 0]);
*/
{
return null;
// note that we cannot check the method at this time, as it could be an interface,
// and interfaces will not have elaborated methods.

Method m = new Method(this, name, paramTypes, null, null, 0);
if (!isInterface()) {
Object o = null;
String qname = name + argumentTypesToString(paramTypes);
/**
* @j2sNative
*
* o = this.$clazz$;
* o = o[qname] || o.prototype && o.prototype[qname];
*/
if (o == null)
throw new NoSuchMethodException(getName() + "." + qname);
}
return m;
// /**
// * @j2sNative
// *
// * return Clazz.new_(Clazz.load('java.lang.reflect.Method').c$$Class$S$ClassA$Class$ClassA$I, [this, name,
// * paramTypes, java.lang.Void, [], 0]);
// */
// {
// return null;
// }
//
//
//
Expand Down Expand Up @@ -3094,6 +3158,20 @@ private static boolean arrayContentsEq(Object[] a1, Object[] a2) {
// return buf.toString();
// }

/**
* Java2Script style here
*
* @param parameterTypes
* @return
*/
public static String argumentTypesToString(Class<?>[] parameterTypes) {
String s = "";
if (parameterTypes != null)
for (int i = 0; i < parameterTypes.length; i++)
s += "$" + /** @j2sNative Clazz._getParamCode(parameterTypes[i]) || */null;
return s;
}

// /** use serialVersionUID from JDK 1.1 for interoperability */
private static final long serialVersionUID = 3206093459760846163L;
//
Expand Down Expand Up @@ -3452,4 +3530,20 @@ public boolean equals(Object o) {
*/
return false;
}

/**
* A SwingJS method for Constructor and Method
*
* @param parameterTypes
* @param args
* @return
*/
public static Object[] getArgumentArray(Class<?>[] types, Object[] args, boolean isProxy) {
Object[] a = new Object[args == null ? 0 : args.length];
if (args != null && (types != null || isProxy))
for (int i = args.length; --i >= 0;)
a[i] = (isProxy ? args[i] : /** @j2sNative (types[i].__PRIMITIVE && args[i].valueOf ? args[i].valueOf() : args[i]) || */ null);
return a;
}

}
Loading