How to force use of StringBuffer instead of StringBuilder by default in javac? - javac

I am trying to compile the CLDC with kvm on linux, I get an error
cannot access java.lang.StringBuilder class file for java.lang.StringBuilder not found
at the statement:
return getClass().getName() + "#" + Integer.toHexString(hashCode());
I think that is because this uses its own bootclasspath which contains StringBuffer but not StringBuilder. Now, how do I force javac to use StringBuffer instead of default StringBuilder?
My dev environment is:
Ubuntu 10.04.2 LTS + javac 1.6.0_24 (sun-java6-jdk)

You could try setting the source and object levels to 1.3 or whatever versin was the last one without StringBuilder.

After googling around a bit more, I found that one can set the target jsr specification with '-target' option to javac. To fix my problem , I had to go back to jsr14 to emit StringBuffer instead of StringBuilder.
javac -target jsr14 *.java
More about this here: http://twit88.com/blog/2008/08/26/java-understanding-jsr14/

Related

Xamarin.Android binding generation giving "Type X was not found" errors for classes new in JDK 1.8

I'm trying to get Xamarin.Android to generate bindings for a library supplied as an AAR. JAR2XML is giving me a lot of "can't find type" errors, so I thought I'd try class-parse, but in addition to some library references I'm trying to track down, I'm getting a couple of these:
1> Error while processing '[Method] java.time.temporal.Temporal adjustInto(java.time.temporal.Temporal temporal, long newValue)' in '[Class] java.time.temporal.ChronoField': Type 'java.time.temporal.Temporal' was not found. (TaskId:69)
1> Error while processing '[Method] java.time.temporal.Temporal addTo(java.time.temporal.Temporal temporal, long amount)' in '[Class] java.time.temporal.ChronoUnit': Type 'java.time.temporal.Temporal' was not found. (TaskId:69)
Now, java.time.temporal.Temporal is a new type in JDK 1.8, so I'm wondering if maybe that's part of my problem here (ie. maybe the types that can't load are using other new-in-1.8 types). Running bin\javac -version in the path specified in Options-Xamarin-Android Settings says I'm using "1.8.0_172". My project is targeting "Android 8.1 (Oreo)" - ie. api level 27. Is there some other option I need to set to make sure I'm using 1.8?

Cant' build OpenCV 3.2.0 (Mingw32)

I know... Another one of this... But no one else's error is the same as mine and I've been trying to build opencv with mingw32 for days now.
When building OpenCV with mingw the command mingw32-make fails at some point trying to compile sources\modules\ts\src\ts_gtest.cpp with error pic bellow:
I've tried following several tutorials, but none work cleanly and this is the best I could get stuff to work.
What I did:
Installed Mingw and added C:\Mingw\bin\ to PATH environment variable.
Installed CMake and added it too to PATH.
Extracted OpenCV to C:\ and created forlder C:\opencv\mingwBuild\
In CMake-GUI I define source folder as C:\opencv\sources\ and build folder as C:\opencv\mingwBuild\.
Hit Configure and select Mingw Makefiles, with 'Use default native compilers' (have also specified compilers explicitly and the result is the same.).
Hit Generate, which creates the Makefile.
I open C:\Mingw\msys\1.0\msys.bat to have a console with all variables loaded (have also tried directly from a simple cmd.exe, given that PATH is set for mingw, but I get the same error in compilation). Navigate to C:\opencv\mingwBuild\ and run mingw32-make.
And that's where the error shows up after a while. Any ideas?
Turns ou gTest was not compiling in Mingw for some reason.
As I don't intend to test my code (for now) I removed opencv_ts from instalation (by deselecting it in Cmake, after configuring and before generating).
Someone mentions, in the first link #Dan Masek refers, that GTest has this issue with type conversion under mingw. They say that you can edit ts_gtest.cpp to apply the correct conversion, according to error message. That may be a solution if you need this module.
Another comment in #Dan Masek's second link mentions that gcc's version 5 surpasses the issue, which version 4 has. So, getting a hold of such distro may also be a solution.
For me it seems to be fixed by applying this fix: https://github.com/msk-repo01/opencv/commit/9a1835ce6676836ce278d723da4ff55a8f900ff1
(Also see: https://github.com/opencv/opencv/issues/8105)
The fix basically replaces the "_RTL_CRITICAL_SECTION" by "_CRITICAL_SECTION" for MingW compilers in modules/ts/include/opencv2/ts/ts_gtest.h in the following way:
The lines
// assuming CRITICAL_SECTION is a typedef of _RTL_CRITICAL_SECTION.
// This assumption is verified by
// WindowsTypesTest.CRITICAL_SECTIONIs_RTL_CRITICAL_SECTION.
struct _RTL_CRITICAL_SECTION;
(around line 723 in OpenCV 3.2.0 release from Dec. 2016) are replaced by
# if GTEST_OS_WINDOWS_MINGW
// MinGW defined _CRITICAL_SECTION and _RTL_CRITICAL_SECTION as two
// separate (equivalent) structs, instead of using typedef
typedef struct _CRITICAL_SECTION GTEST_CRITICAL_SECTION;
# else
// assuming CRITICAL_SECTION is a typedef of _RTL_CRITICAL_SECTION.
// This assumption is verified by
// WindowsTypesTest.CRITICAL_SECTIONIs_RTL_CRITICAL_SECTION.
typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
# endif
and
_RTL_CRITICAL_SECTION* critical_section_;
is replaced by
GTEST_CRITICAL_SECTION* critical_section_;

Rejecting re-init on previously failed class error when loading a Class with dalvikvm

I am trying to use Terminal IDE on Lollipop 5.1.1. Using a Samsung E7 device, a mod version of Terminal IDE is provided by someone on XDA
here:
http://forum.xda-developers.com/showthread.php?t=1340852&page=7
I tried to use javac script in that mod but it gave an unsatisfied link error, saying that:
$ javac
java.lang.UnsatisfiedLinkError: org.apache.harmony.security.fortress.Services
at org.apache.harmony.security.fortress.Engine.getServices(Engine.java:158)
at org.apache.harmony.security.fortress.Engine.getInstance(Engine.java:137)
at java.security.cert.CertificateFactory.getInstance(CertificateFactory.java:90)
at
org.apache.harmony.security.utils.JarUtils.verifySignature(JarUtils.java:83)
at java.util.jar.JarVerifier.verifyCertificate(JarVerifier.java:294)
at java.util.jar.JarVerifier.readCertificates(JarVerifier.java:268)
at java.util.jar.JarFile.getInputStream(JarFile.java:380)
at libcore.net.url.JarURLConnectionImpl.getInputStream(JarURLConnectionImpl.java:222)
at java.net.URL.openStream(URL.java:470)
at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:444)
at java.util.ResourceBundle.handleGetBundle(ResourceBundle.java:515)
at java.util.ResourceBundle.handleGetBundle(ResourceBundle.java:542)
at java.util.ResourceBundle.handleGetBundle(ResourceBundle.java:542)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:228)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:139)
at com.sun.tools.javac.main.JavaCompiler.version(JavaCompiler.java:112)
at com.sun.tools.javac.main.JavaCompiler.version(JavaCompiler.java:97)
at com.sun.tools.javac.main.Main.bugMessage(Main.java:434)
at com.sun.tools.javac.main.Main.compile(Main.java:421)
at com.sun.tools.javac.main.Main.compile(Main.java:308)
at com.sun.tools.javac.main.Main.compile(Main.java:299)
at com.sun.tools.javac.Main.compile(Main.java:82)
at com.spartacusrex.spartacuside.external.javac.main(javac.java:13)
$
It is strange that there is a UnsatisfiedLinkError , because it doesn't say that VM cannot find xyz.so library or cannot find xyz method.
I tried using logcat command right after using Terminal IDE's javac script on Device, the odd thing I found from there is :
I/art ( 6558) : rejecting re-init on previously-failed class java.lang.Class<org.apache.harmony.security.fortress.Services>
I couldn't understand why this happened,
The javac script uses android's dalvikvm command to load
com.spartacusrex.spartacuside.external.javac
class. People have faced this rejecting re-init issue on sdk version 20+ but it's not clear to me why this info message uccurs and how to solve it.
I copied /system/lib/libjavacrypto.so to Terminal IDE's ~/system/lib folder and now javac and dx tools are working.
It seems like Google messed up with things in /system/lib which resulted in errors.
Answering so someone else might find it useful.

Compiling jabber-net in Xamarin Studio

I am trying to compile jabber-net in Xamarin Studio so I can use it in a Xamarin.iOS app.
From other searches I have done I am told I need to recompile the source.
From command line I can build the dll, but I have no idea what version of .NET/Mono this is targeting.
This makes a jabber-net.dll and a jabber-net.dll.mdb.
If I add jabber-net.dll to my project, add the reqiured
using jabber.client;
...
...
...
JabberClient client = new JabberClient ();
and try to compile I am told.
/Users/brad/Projects/XMPPChat/XMPPChat/AppDelegate.cs(37,47): error CS0584: Internal compiler error: Could not import type jabber.client.JabberClient' fromjabber-net, Version=2.1.0.702, Culture=neutral, PublicKeyToken=924c5b18328d6f09'
/Users/brad/Projects/XMPPChat/XMPPChat/AppDelegate.cs(37,38): error CS0584: Internal compiler error: Could not import type jabber.client.JabberClient' fromjabber-net, Version=2.1.0.702, Culture=neutral, PublicKeyToken=924c5b18328d6f09'
/Users/brad/Projects/XMPPChat/XMPPChat/AppDelegate.cs(37,38): error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement
I got no idea what is going on here...
When I try to open any of the .sln's (or include any of the existing projects, even the mono specific project) that came with jabber-net into my solution it will either hang trying to convert the project, or will tell me
The file '/Users/brad/Projects/XMPPChat/JabberNet-2.1.0.710/mono-jabber-net.csproj' could not be loaded.
and will spit out this error.
Any idea where to go from here? :|
Start a new solution from scratch, and add all of the .cs files except those in the test and examples directories. Also make sure you don't have an old version of the .dll around somewhere.

FsLex changed with latest PowerPack?

I've been working on a compiler for a while but after changing to PowerPack 1.9.9.9 and the release version of VS2010 I'm no unable to compile the following line:
let lexbuf = Lexing.from_string text
I get the following two error:
"The value, constructor, namespace or type 'from_string' is not defined" pretty obviopus what it's trying to tell me but what's the resolution?
My quick guess is that this function has been renamed to fromString (because, in general, functions with underscores such as of_seq are now written in camelCase).
Lexing.LexBuffer<_>.FromString ?

Resources