Open miguelperezcolom opened 7 years ago
You should not do this way. See how TeaVM port of JDK is built. Please, look at classlib
module. You should follow the same pattern, if you want to add some classes to java.*
package.
Hi Alexey,
thanks a lot for your quick response.
So, should I fork the classlib module and add a org.teavm.classlib.java.time.TLocalDate class?
I have not been able to find where are org.teavm.classlib.xxx classes read from, so I'm not sure if it is enough to add the class. I see the teavm.properties file with content
packagePrefix.java=org.teavm.classlib classPrefix.java=T
but I have not seen any reference to this file.
Also, it seems the classlib project is mainly adding the org.teavm.classlib.impl.JCLPlugin.
In order to leave the classlib dependency as is, would it be possible to add the org.teavm.classlib.java.time.TLocalDate in another artifact, as an independent maven dependency?
Thanks,
Miguel
You can add a separate jar
file to classpath which contains classes in org.teavm.classlib
package and this should work as expected. Another way is to add custom teavm.properties
with corresponding prefixes.
Ok. Perfect.
I will try.
Thanks a lot, Alexey
2017-08-22 10:37 GMT+02:00 Alexey Andreev notifications@github.com:
You can add a separate jar file to classpath which contains classes in org.teavm.classlib package and this should work as expected. Another way is to add custom teavm.properties with corresponding prefixes.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/konsoletyper/teavm/issues/297#issuecomment-323958754, or mute the thread https://github.com/notifications/unsubscribe-auth/ATum0cVAs_UgWkK3VrSkiczqqvjMPWc1ks5sapNhgaJpZM4O39zn .
Hi,
first of all congratulations for your work. I have been working for several years with gwt and I am impressed by your project.
I am using teavm to transpile my ui code to javascript by I have a problem with LocalDate.
I have seen your explanation at JSR 310? #56 and I understand it.
I have written a ClassHolderTransformer to deal with LocalDate but it does not work. In fact, my ClassHolderTransformer is not being asked to transform LocalDate, though I see it is being asked to transform any other class that I use.
This is my code: ``
package io.mateu.ui.teavm.plugin;
import org.teavm.diagnostics.Diagnostics; import org.teavm.model.*; import org.teavm.model.util.ModelUtils;
import java.time.LocalDate; import java.time.LocalDateTime;
/**
Created by miguel on 15/8/17. */ public class MateuTransformer implements ClassHolderTransformer {
public MateuTransformer() {
}
public void transformClass(ClassHolder cls, ClassReaderSource innerSource, Diagnostics diagnostics) {
}
private void substitute(ClassHolder cls, ClassReaderSource classSource, Class clase) { System.out.println("sustituyendo " + cls.getName() + " por " + clase.getName());
} } ``
And this is the output:
[INFO] Building JavaScript file revisando io.mateu.ui.Port revisando java.lang.Object revisando java.lang.Class revisando java.lang.reflect.AnnotatedElement revisando java.lang.String revisando java.io.Serializable revisando java.lang.Comparable revisando java.lang.CharSequence revisando java.lang.Thread ... revisando java.util.regex.UnicodeCategory revisando java.util.regex.UnicodeCategoryScope revisando java.util.regex.IntArrHash [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 11.315 s [INFO] Finished at: 2017-08-15T20:46:09+02:00 [INFO] Final Memory: 33M/598M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.teavm:teavm-maven-plugin:0.5.1:compile (web-client) on project sample-app-core: Unexpected error occured: Error rendering class io.mateu.ui.sample.client.TestDate. See a cause for details: Can't provide name for method as it was not found: java.time.LocalDate.now()Ljava/time/LocalDate; -> [Help 1] [ERROR]
So it seems my classhotldertransformer is being called for any class but for LocalDates :(
Can you please give me any clue of what I am doing wrong? Is there any other way to use LocalDate with teavm?
Thanks and best regards,
Miguel