SWT GTK 64 bit and UBUNTU 11.04 NPE - 64-bit

I'm currently working in an SWT standalone application. We usually work with windows but I'd like to work in Ubuntu.I set up the following environment.
Ubuntu 11.04 64bit
Java 6 update 27 64 bit
Eclipse Java EE 3.5 Galileo 64 bit
I'm using SWT GTK 64 bit
I've got a few classes extending different SWT widgets.
For example
public class MyCombo extends Combo implements CellEditor<Long> {
private Set<ListenerRef> listeners = new HashSet<ListenerRef>();
#Override
public void addListener(int eventType, Listener listener) {
listeners.add(new MyCombo.ListenerRef(eventType, listener));
super.addListener(eventType, listener);
}
#Override
protected void checkSubclass() {
// Do nothing
}
.
.
.
This code works perfectly well in Windows 7 64 bit, running SWT32 bit and java32 bit, from eclipse 32 bit.
In Ubuntu 11.04 I get a NPE (NullPointerException) when trying to add a listener, it seems that the listeners set is null, but it shouldn't cause that set should be initialized as for the code above, and as I say it works in Windows 7
First I had problems running the SWT 32 bit app in Ubuntu64 bit cause there's seem to be a bug when running 32 apps in 64 ubuntu, so I tried to run it with the 64 version, and now I'm getting this error. If I avoid this NPE checking the set, I end up getting a
java.lang.NullPointerException
at org.eclipse.swt.accessibility.Accessible.isValidThread(Unknown Source)
at org.eclipse.swt.accessibility.Accessible.checkWidget(Unknown Source)
at org.eclipse.swt.accessibility.Accessible.addRelation(Unknown Source)
Any ideas of what could be the reason? Are you aware of this problem in previous Ubuntu distrubutions? I don't get this problems in Windows 7, at least running SWT 32 bit
Please let me know if you need more details
Thanks and regards
BTW I forgot, SWT is 3.7 in Linux and 3.6.2 in Windows

Related

GroovyCategorySupport and "system" memory leak

When I run the following JUnit test, the memory of the java process is increasing constantly. After several hours, it uses more than 2go. However, when I look with jvisualvm, the heap and permgen size are stable, I don't see any leak. The test is run with -Xmx32m
public class TestCat {
public static class A { }
#Test
public void testCategory() {
for(;;) {
GroovyCategorySupport.use(A.class, new Closure<Object>(null) {
public Object call() { return null; }
});
}
}
}
I have tested it with Groovy 2.4.7, Windows and a JRE1.7_80, MacOS and JRE1.7_60.
I can't reproduce this bug with MacOS and JRE 1.8.0_91
I suppose it's related to a bug in the JRE1.7, and I am looking for a way to mitigate this issue:
my test is maybe wrong ? How is it possible to leak "system" memory without leaking heap space or permgen space ?
Is it a "known" bug or incompatibility between Groovy and a JRE 1.7 ?
How to use groovy category with a 1.7 jre and without suffering this memory leak ?
EDIT
I can reproduce this bug by calling VMPluginFactory.getPlugin().invalidateCallSites(), which translates with this "pure java" unit test :
public class TestSwitchPoint {
#Test
public void testSP() {
SwitchPoint switchPoint = new SwitchPoint();
for(;;) {
SwitchPoint old = switchPoint;
switchPoint = new SwitchPoint();
SwitchPoint.invalidateAll(new SwitchPoint[]{old});
}
}
}
In fact, only new SwitchPoint() is enough.
Yes, there is a bug in JRE. Native memory leak happens inside JVM at the following place:
(VM)
- os::malloc(unsigned long, unsigned short, unsigned char*)
- CHeapObj<(unsigned short)1792>::operator new(unsigned long, unsigned char*)
- JNIHandleBlock::allocate_block(Thread*)
- JNIHandleBlock::allocate_handle(oopDesc*)
- JNIHandles::make_weak_global(Handle)
- instanceKlass::add_member_name(int, Handle)
- MethodHandles::init_method_MemberName(Handle, methodOopDesc*, bool, KlassHandle)
- MethodHandles::init_method_MemberName(Handle, CallInfo&, Thread*)
- MethodHandles::resolve_MemberName(Handle, KlassHandle, Thread*)
- MHN_resolve_Mem
(JAVA)
- java.lang.invoke.MethodHandleNatives.resolve(MemberName, Class)
- java.lang.invoke.MemberName$Factory.resolve(byte, MemberName, Class)
- java.lang.invoke.MemberName$Factory.resolveOrNull(byte, MemberName, Class)
- java.lang.invoke.DirectMethodHandle.maybeRebind(Object)
- java.lang.invoke.DirectMethodHandle.bindReceiver(Object)
- java.lang.invoke.CallSite.makeDynamicInvoker()
- java.lang.invoke.MutableCallSite.dynamicInvoker()
- java.lang.invoke.SwitchPoint.<init>()
- Test.main(java.lang.String[])
It is a known issue with MemberNameTable: JDK-8152271. Unfortunately, it has been fixed only in JDK 9. By a lucky chance your problem is not seen on JDK 8 because of MethodHandles refactoring done in JDK-8050166. Although MemberNameTable probem remains, SwitchPoint() no longer creates new MemberNames. The latter fix was also backported to JDK 7u91.
Groovy runtime uses MethodHandles if it detects Java 7+. You may workaround this by patching VMPluginFactory to use Java 6 plugin. Here is the patch. If included in classpath before Groovy libraries, it will force Groovy runtime to use Java 6 - compatible VMPlugin.
So, you have the following options to workaround the memory leak:
use JRE 8 (recommended)
use JRE 7u91+
include VMPluginFactory patch in classpath

java.lang.NoSuchMethodError: org.assertj.core.api.Assertions.assertThat(Ljava/util/Map;)Lorg/assertj/core/api/MapAssert;

When running unitTest on AndroidStudio (1.4), my below test fail as per title i.e. java.lang.NoSuchMethodError: org.assertj.core.api.Assertions.assertThat(Ljava/util/Map;)Lorg/assertj/core/api/MapAssert;
#Test
public void mapTest() {
Map<String, String> map = new HashMap<>();
map.put("Key1", "Value1");
map.put("Key2", "Value2");
Assertions.assertThat(map).isNotNull();
}
When I run it from command line using gradlew command, it passed. I'm already pointing my Java to jdk1.8.0_66.jdk. Anyone knows why?
(p/s: I get the latest AndroidStudio 2.0 Preview 5, my test fails massively. So I decided to stay with the older version of Android Studio).
Trying to search for help and found this link https://github.com/joel-costigliola/assertj-core/issues/395. Apparently he also face the same issue on IDE. Any clue what's the cause?
I would double check the classpath.
Use assertj core 1.7.1 - it's a version depending on java 6 whcih I'm sure is Android compatible.
Hope it helps

Combo box issue in Linux KDE environment

I have a RCP application which works well in Linux GNOME environment.But when I tried the Application with Linux KDE environment
I am facing some issues with the combo box.
1.Combo box is not disposing properly.
Also when I tried to debug with eclipse,The entire UI goes to freeze state and I forced to restart my machine.
Is there any library need to be replaced while using Linux KDE environment?.Also combo box is not behaving as expected using the same code.
Please help me to resolve the issues.
I ran into the same issue on Ubuntu. I'm using IBM's Nebula implementation of a TableCombo with slight modifications. If you too, then the following code might help you:
getShell().addShellListener(new ShellAdapter() {
#Override
public void shellDeactivated(ShellEvent e) {
Display.getCurrent().asyncExec(new Runnable() {
#Override
public void run() {
if (Display.getCurrent().getFocusControl() == null) {
dropDown(false);
}
}
});
}
});
Insert this at the end of the createPopup() method.

eclipse indigo - windowbuilder - eclipse doesn't regain focus

I have eclipse 3.7 indigo; I installed gwt plugin and its designer; The problem is (time after time) when I add new widget X to composite the
palette (keeps widget selected)
components (doesn't show the new widget in the tree)
properties (doesn't show the new widget properties)
...so I cannot select another widget unless I resize the whole eclipse application to force its GUI repaint :(
It seems like palette and other managers don't get report "widget was added from windowbuilder" or similar :(
Moreover, I cannot edit widget's text if I have input method as "System" which is the default on btw so the only one input method which works is "X Input Method" but anyways it doesn't solve the mentioned focus regain problem;
That makes eclipse indigo really hard to use; So my question is... how to fix that?
p.s.
eclipse 3.7 (indigo)
gwt plugin - https://dl.google.com/eclipse/plugin/archive/3.6.0/3.7
gwt designer - http://dl.google.com/eclipse/inst/d2gwt/latest/3.7
gwt sdk 2.2
jdk 1.7
jre 1.7
OS Linux x64
Thanks
I had to do my own research concerning the issue; I noticed there is some kind of "jobs order conflict" or similar with the default constructor based code style as :
public class MyTestUI extends Composite {
private FlowPanel flowPanel;
public MyTestUI() {
flowPanel = new FlowPanel();
initWidget(flowPanel);
}
}
...so, as a workaround, I had to play with code generator as;
window -> preferences -> windowbuilder -> gwt
(combobox) method name for new statements : initComponents
variable generation : field
statement generation : flat
just to avoid having in-constructor init as a result I have code generated as :
public class MyTestUI extends Composite {
private FlowPanel flowPanel;
public MyTestUI() {
initComponents();
}
private void initComponents() {
flowPanel = new FlowPanel();
initWidget(flowPanel);
}
}
...btw there is a problem with focus regain if input method is "System" and initComponents() method generated first time; so before starting adding widgets I had to select "X input method" to avoid synch-ed jobs; So "X input method" needs to be the default one, as I can get it :)
EDIT :
The effect I faced very looks like bug 388170; So I tried to modify eclipse.ini argument as
-Djava.awt.headless=true
It seems like the headless helps a bit but anyways eclipse sometimes does hang when using windowbuilder especially DnD :P
Anyways I want to point I faced the mentioned issue first time cause similar windows x32 eclipse indigo version works pretty fine with gwt;
p.s.
The solution is not final (the hang problem still occurs on DnD evens) and I am still looking for a more optimal one; So do comment if you have some helpful tips or ideas;

Crash related to UITableViewController / UISearchDisplayController in MonoTouch/Xamarin.iOS

I'm having problem to find the cause of random crashes in my app. The crashes only occurs when I build in release mode and run on a device like iPhone or iPad. Running in debug on simulator no crashes occurs. My guess is that the problem has something to do with these two lines in the crash log,
6 UIKit 0x34a193d0 -[UISearchDisplayController _destroyManagedTableView] + 68
7 UIKit 0x34a2195a -[UISearchDisplayController dealloc] + 94
I've uploaded the source code of my UITableViewController and the full crash log here, https://gist.github.com/Nordis/6128735
All help to track the cause of the crashes is much appreciated!
Update
I've now crated a bug report, I looked and the thread Rolf suggested in the comments. So I downloaded the test case, applied the fix. But still exactly the same crash and the stack trace is very similar to what mine looks like.
https://bugzilla.xamarin.com/show_bug.cgi?id=13703
The solution provided by Rolf at Xamarin was fairly simple, all I had to do was to move the code from Dispose() to ViewDidDisappear() in my UITableViewController,
public override void ViewDidDisappear (bool animated)
{
searchController.SearchResultsSource = null;
searchController.Delegate = null;
base.ViewDidDisappear (animated);
}

Resources