Joda wrong offset when using ZoneInfoProvider - java

Using Joda 2.1 in Java:
I have downloaded the latest timezone definitions 2013g, used ZoneInfoCompiler and have compiled those and moved them to my project's classpath.
I then call DateTimeZone.setProvider(new ZoneInfoProvider( "my-path-to-new-compiled-definitions" ) )
then when I try to instantiate new DateTime(DateTimeZone.forID("Asia/Jerusalem")) I get the time 1 hour backwards wrong.
It's as if compiling the new timezone definitions for joda and providing them has done nothing. However to test that it is actually using my new location, I tried executing DateTimeZone.forID("Asia/Khandyga") which did not exist in 2.1 and now retrieves and instantiates properly.
Ideas?

Related

Problem with some LWJGL classes on import (Eclipse)

I downloaded the release build without modifying (https://www.lwjgl.org/customize)
I put all the classes in Eclipse. Some classes are not recognized
The codes that do not need these classes in error, work normally. As in https://www.lwjgl.org/guide
All the classes I put:
joml-1.10.1.jar
joml-1.10.1-javadoc.jar
joml-1.10.1-sources.jar
lwjgl.jar
lwjgl-assimp.jar
lwjgl-assimp-javadoc.jar
lwjgl-assimp-natives-windows.jar
lwjgl-assimp-sources.jar
lwjgl-bgfx.jar
lwjgl-bgfx-javadoc.jar
lwjgl-bgfx-natives-windows.jar
lwjgl-bgfx-sources.jar
lwjgl-cuda.jar
lwjgl-cuda-javadoc.jar
lwjgl-cuda-sources.jar
lwjgl-egl.jar
lwjgl-egl-javadoc.jar
lwjgl-egl-sources.jar
lwjgl-glfw.jar
lwjgl-glfw-javadoc.jar
lwjgl-glfw-natives-windows.jar
lwjgl-glfw-sources.jar
lwjgl-javadoc.jar
lwjgl-jawt.jar
lwjgl-jawt-javadoc.jar
lwjgl-jawt-sources.jar
lwjgl-jemalloc.jar
lwjgl-jemalloc-javadoc.jar
lwjgl-jemalloc-natives-windows.jar
lwjgl-jemalloc-sources.jar
lwjgl-libdivide.jar
lwjgl-libdivide-javadoc.jar
lwjgl-libdivide-natives-windows.jar
lwjgl-libdivide-sources.jar
lwjgl-llvm.jar
lwjgl-llvm-javadoc.jar
lwjgl-llvm-natives-windows.jar
lwjgl-llvm-sources.jar
lwjgl-lmdb.jar
lwjgl-lmdb-javadoc.jar
lwjgl-lmdb-natives-windows.jar
lwjgl-lmdb-sources.jar
lwjgl-lz4.jar
lwjgl-lz4-javadoc.jar
lwjgl-lz4-natives-windows.jar
lwjgl-lz4-sources.jar
lwjgl-meow.jar
lwjgl-meow-javadoc.jar
lwjgl-meow-natives-windows.jar
lwjgl-meow-sources.jar
lwjgl-nanovg.jar
lwjgl-nanovg-javadoc.jar
lwjgl-nanovg-natives-windows.jar
lwjgl-nanovg-sources.jar
lwjgl-natives-windows.jar
lwjgl-nfd.jar
lwjgl-nfd-javadoc.jar
lwjgl-nfd-natives-windows.jar
lwjgl-nfd-sources.jar
lwjgl-nuklear.jar
lwjgl-nuklear-javadoc.jar
lwjgl-nuklear-natives-windows.jar
lwjgl-nuklear-sources.jar
lwjgl-odbc.jar
lwjgl-odbc-javadoc.jar
lwjgl-odbc-sources.jar
lwjgl-openal.jar
lwjgl-openal-javadoc.jar
lwjgl-openal-natives-windows.jar
lwjgl-openal-sources.jar
lwjgl-opencl.jar
lwjgl-opencl-javadoc.jar
lwjgl-opencl-sources.jar
lwjgl-opengl.jar
lwjgl-opengles.jar
lwjgl-opengles-javadoc.jar
lwjgl-opengles-natives-windows.jar
lwjgl-opengles-sources.jar
lwjgl-opengl-javadoc.jar
lwjgl-opengl-natives-windows.jar
lwjgl-opengl-sources.jar
lwjgl-openvr.jar
lwjgl-openvr-javadoc.jar
lwjgl-openvr-natives-windows.jar
lwjgl-openvr-sources.jar
lwjgl-opus.jar
lwjgl-opus-javadoc.jar
lwjgl-opus-natives-windows.jar
lwjgl-opus-sources.jar
lwjgl-ovr.jar
lwjgl-ovr-javadoc.jar
lwjgl-ovr-natives-windows.jar
lwjgl-ovr-sources.jar
lwjgl-par.jar
lwjgl-par-javadoc.jar
lwjgl-par-natives-windows.jar
lwjgl-par-sources.jar
lwjgl-remotery.jar
lwjgl-remotery-javadoc.jar
lwjgl-remotery-natives-windows.jar
lwjgl-remotery-sources.jar
lwjgl-rpmalloc.jar
lwjgl-rpmalloc-javadoc.jar
lwjgl-rpmalloc-natives-windows.jar
lwjgl-rpmalloc-sources.jar
lwjgl-shaderc.jar
lwjgl-shaderc-javadoc.jar
lwjgl-shaderc-natives-windows.jar
lwjgl-shaderc-sources.jar
lwjgl-sources.jar
lwjgl-sse.jar
lwjgl-sse-javadoc.jar
lwjgl-sse-natives-windows.jar
lwjgl-sse-sources.jar
lwjgl-stb.jar
lwjgl-stb-javadoc.jar
lwjgl-stb-natives-windows.jar
lwjgl-stb-sources.jar
lwjgl-tinyexr.jar
lwjgl-tinyexr-javadoc.jar
lwjgl-tinyexr-natives-windows.jar
lwjgl-tinyexr-sources.jar
lwjgl-tinyfd.jar
lwjgl-tinyfd-javadoc.jar
lwjgl-tinyfd-natives-windows.jar
lwjgl-tinyfd-sources.jar
lwjgl-tootle.jar
lwjgl-tootle-javadoc.jar
lwjgl-tootle-natives-windows.jar
lwjgl-tootle-sources.jar
lwjgl-vma.jar
lwjgl-vma-javadoc.jar
lwjgl-vma-natives-windows.jar
lwjgl-vma-sources.jar
lwjgl-vulkan.jar
lwjgl-vulkan-javadoc.jar
lwjgl-vulkan-sources.jar
lwjgl-xxhash.jar
lwjgl-xxhash-javadoc.jar
lwjgl-xxhash-natives-windows.jar
lwjgl-xxhash-sources.jar
lwjgl-yoga.jar
lwjgl-yoga-javadoc.jar
lwjgl-yoga-natives-windows.jar
lwjgl-yoga-sources.jar
lwjgl-zstd.jar
lwjgl-zstd-javadoc.jar
lwjgl-zstd-natives-windows.jar
lwjgl-zstd-sources.jar
You are trying to compile LWJGL 2 code here. All the imports that it cannot find pertain to the verison 2 of LWJGL. The current version that you can get from the mentioned lwjgl site is 3 and version 3 is incompatible with version 2.
Either explicitly download LWJGL 2 from e.g. http://legacy.lwjgl.org/ or rewrite your code to work with LWJGL 3.
If you go the LWJGL 2 route, though, please note that it hasn't been actively maintained anymore for more than 6 years now.

No such field exception while loading "scl" field from Classloader

I am moving my code from JDK 8 to Open JDK 12. While doing so, I am facing following issue :
java.lang.NoSuchFieldException: scl
while trying to call ClassLoader.class.getDeclaredField("scl"). This was working fine in Java 8 but no longer works in newer Java versions.
I did some findings and believe it has got to do with the way working of reflection and use of internal Java packages have changed since Java 8.
Set<URL> classLoaderUrls = computeClassLoaderUrls();
ClassLoader bootstrapClassLoader = ClassLoader.getSystemClassLoader().getParent();
this.classLoader = new URLClassLoader(classLoaderUrls.toArray(new URL[classLoaderUrls.size()]), bootstrapClassLoader);
Field systemClassLoaderField = ClassLoader.class.getDeclaredField("scl");
systemClassLoaderField.setAccessible(true);
this.initialSystemClassLoader = (ClassLoader) systemClassLoaderField.get(null);
systemClassLoaderField.set(null, this.classLoader);
I want to know , if the way to access these classloader and its fields has changed or should I use some other field instead of scl. Thanks

How to tell wsdl2java not insert current timestamp into generated files?

I use wsdl2java to generate DTO Java classes. It adds current timestamp into the comments section of every file generated.
How to disable those timestamps?
Because I'd like to minify changes between two wsdl2java launches (the generated java sources are under RCS).
P.S. Java 7; wsdl2java comes from org.apache.cxf:cxf-codegen-plugin:2.6.16 although version 3 is also considered.
Use option -suppress-generated-date of underlying Apache CXF in wsdl2java configuration.
Fragment of a build.gradle file as an example:
wsdl2java {
...
wsdlsToGenerate = [
[
...
"-suppress-generated-date",
...
]
]
...
}
This option will change these comments in generated classes
/**
* This class was generated by Apache CXF 3.2.7
* 2018-11-23T10:12:12.986+02:00
* Generated source version: 3.2.7
*
*/
to these:
/**
* This class was generated by Apache CXF 3.2.7
* Generated source version: 3.2.7
*
*/
More details: http://cxf.apache.org/docs/wsdl-to-java.html
however, other with CXF 3.5.2 dates as
#Generated(value = "org.apache.cxf.tools.wsdlto.WSDLToJava", date = "2022-09-24T16:22:10.990+02:00")
#Generated(value = "com.sun.tools.xjc.Driver", comments = "JAXB RI v2.3.5", date = "2022-09-24T16:22:10+02:00")
still remain in code.
yes, the file heading comments are away but intention was not to have code cluttered with unwanted changes. the changes are tracked by git normally.
generated dates in code may help with very very old code, but generally they are not desirable. it would be even better to have one comment with date in Service than 20 very same comments spread around in code.
no one follows 20 dates spread around generated code. if no one reads that information, that information has no value and should be avoided.
The changes in WS contract are commonly followed in WSDL file, there is no need to have dates generated in code.
it might be partially useful, if the generated dates would track real changes, that means, it would ONLY update the date where the contents really changed. it is a bad idea to clutter all places with very same date.

No Such method error during transformation to pdf in Java

I have a problem while transforming the xslt to pdf in java, i am following the same process posted in this link
"Java Transformation to PDF".
Error:
`
Caused by: java.lang.NoSuchMethodError: org.apache.xmlgraphics.java2d.GraphicContext.<init>(Lorg/apache/xmlgraphics/java2d/GraphicContext;)V
at org.apache.fop.render.intermediate.IFGraphicContext.<init>(IFGraphicContext.java:50)
at org.apache.fop.render.intermediate.IFGraphicContext.clone(IFGraphicContext.java:56)
at org.apache.fop.render.intermediate.IFRenderer.saveGraphicsState(IFRenderer.java:632)
at org.apache.fop.render.intermediate.IFRenderer.startViewport(IFRenderer.java:885)
at org.apache.fop.render.intermediate.IFRenderer.startVParea(IFRenderer.java:878)
at org.apache.fop.render.AbstractRenderer.renderRegionViewport(AbstractRenderer.java:289)
at org.apache.fop.render.intermediate.IFRenderer.renderRegionViewport(IFRenderer.java:731)
at org.apache.fop.render.AbstractRenderer.renderPageAreas(AbstractRenderer.java:249)
at org.apache.fop.render.AbstractRenderer.renderPage(AbstractRenderer.java:230)
at org.apache.fop.render.intermediate.IFRenderer.renderPage(IFRenderer.java:580)
at org.apache.fop.area.RenderPagesModel.addPage(RenderPagesModel.java:114)
at org.apache.fop.layoutmgr.AbstractPageSequenceLayoutManager.finishPage(AbstractPageSequenceLayoutManager.java:312)
at org.apache.fop.layoutmgr.PageSequenceLayoutManager.finishPage(PageSequenceLayoutManager.java:167)
at org.apache.fop.layoutmgr.PageSequenceLayoutManager.activateLayout(PageSequenceLayoutManager.java:109)
at org.apache.fop.area.AreaTreeHandler.endPageSequence(AreaTreeHandler.java:238)
at org.apache.fop.fo.pagination.PageSequence.endOfNode(PageSequence.java:120)
at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.endElement(FOTreeBuilder.java:349)
at org.apache.fop.fo.FOTreeBuilder.endElement(FOTreeBuilder.java:177)
at net.sf.saxon.event.ContentHandlerProxy.endElement(ContentHandlerProxy.java:391)
at net.sf.saxon.event.ProxyReceiver.endElement(ProxyReceiver.java:174)
at net.sf.saxon.event.NamespaceReducer.endElement(NamespaceReducer.java:213)
at net.sf.saxon.event.ComplexContentOutputter.endElement(ComplexContentOutputter.java:417)
at net.sf.saxon.instruct.ElementCreator.processLeavingTail(ElementCreator.java:301)
at net.sf.saxon.instruct.Block.processLeavingTail(Block.java:409)
at net.sf.saxon.instruct.Instruction.process(Instruction.java:94)
at net.sf.saxon.instruct.ElementCreator.processLeavingTail(ElementCreator.java:298)
at net.sf.saxon.instruct.Template.applyLeavingTail(Template.java:175)
at net.sf.saxon.instruct.ApplyTemplates.applyTemplates(ApplyTemplates.java:343)
at net.sf.saxon.Controller.transformDocument(Controller.java:1736)
at net.sf.saxon.Controller.transform(Controller.java:1560)
at mypackage.v2.business.pdf.XMLtoPDF.convertXMLPDF(XMLtoPDF.java:103)
... 51 more
java.lang.ClassCastException: java.lang.NoSuchMethodError cannot be cast to java.lang.Exception
`
Please let me know what could be the problem.
As described in the documentation
Thrown if an application tries to call a specified method of a class (either static or instance), and that class no longer has a definition of that method.
Here's how this can happen. Imagine you built some code that used a library with a method called foo(). You compiled your project and then later decided to upgrade the library. You do this by overwriting the old jar file with the new one. You don't recompile your code.
But what you didn't know is the new library removed the foo() method. Now if you run your code, it will throw this exception because your compile code calls this method and it's no longer there.
In your specific case, this isn't necessarily your code with the problem. It could be that you have one library that uses another library and the problem is there (for example, Library X uses version 2 of Library Y, but you only have Library Y version 1 in your classpath). If this is happening, you need to make sure the libraries are using the version they expect.
For your specific problem, you need to find the version of the jar that has org.apache.xmlgraphics.java2d.GraphicContext in it and it needs to have a constructor that takes a... list of org/apache/xmlgraphics/java2d/GraphicContext... maybe. I forget what (L...;)V means.

jdk7 RessourceBundle / logging issue

I noticed that the localized message of a Level class from java.util.logging does not work on Java7. Looks like there is an issue with loading RessourceBundle for sun.util.logging.resources.logging
Let's consider following snippet
Locale.setDefault(Locale.GERMANY);
String msg = Level.SEVERE.getLocalizedName();
System.err.println(msg);
On java 6 it prints
SCHWERWIEGEND
On java 7 it prints
SEVERE
I read an article explaing that the Locale class was re-implemented in jdk7. Still, this seems to be werid. I also tried on Java 7 setting
Locale.setDefault(Category.DISPLAY, Locale.GERMANY);
then
Locale.setDefault(Category.FORMAT, Locale.GERMANY);
finally
System.setProperty("sun.locale.formatasdefault", "true");
but neither seem to work.
Is this a bug in the JVM or did I miss something?
This might be related to JDK-8028233. You can change the date format by specifying the a format string through the "java.util.logging.SimpleFormatter.format" system property or LogManager property.

Categories

Resources