Catching java.lang.Error - blackberry

I'm developing a Javame framework for J2me and Blackberry. I read the type(bb or j2me) from the device, and then I load the right classes depending on the detected device.
Only I get a java.lang.error when executing the following code. I think that's because I use a blackberry package in the KuixCanvasBB that j2me doesn't support. But is there a way to catch this error?
KuixCanvas canvas;
if(Settings.j2me) {
System.out.println("j2me");
canvas = new KuixCanvasJ2me(this, isFullscreen());
}
else {
System.out.println("BB");
try {
canvas = new KuixCanvasBB(this, isFullscreen());
//canvas = new KuixCanvasJ2me(this, isFullscreen());
}
catch (java.lang.Error e) {
canvas=null;
}
}
I still get an Error when executing the above code:
java.lang.Error: ClassFormatError: 154
- java.lang.Class.invoke_verify(), bci=0
- java.lang.Class.initialize(), bci=117
- java.lang.Class.initialize(), bci=139
- java.lang.Class.forName(), bci=0
Can I catch this error without the app shutting down?

Since many J2ME VMs will verify all code before running anything such code could easily be rejected from even installing on many devices.
A safer solution would probably be to make this a build-time decision, since you'll need separate .jar files for the final build anyway.
The reason you get the error is probably because references to other classes get resolved as soon as the method is entered on the JVM.

Related

Sentry error - IndexSizeError: The index is not in the allowed range

I am getting this error from Sentry repetitively in ios - safari 14.0 in react project.
There is no code trace and no other information than this but it repeats in almost every URL.
I have already searched for the options everywhere. I have tried debugging but I can't replicate it, and so I can't resolve it.
Does anyone know what does this error means? Or how can I add debug information in Sentry?
I have been looking for the solution for a while and couldn't get it. I know it's a bit lack of information to provide but that's why I am asking this. if someone can tell me how to deal with sentry errors if you don't know why it is repeating so often, it will be really helpful.
A similar issue still exists.
Faced this in Safari when Draft.js is updating the editor state.
The error which I see: IndexSizeError: The index is not in the allowed range.
For me, playing around with Paragraph Directioncontext menus items after right-clicking on the Editor selection reproduced the error.
My Solution/hack:
Add it to any JS file executing before the Editor file.
const nativeSelectionExtend = Selection.prototype.extend;
Selection.prototype.extend = function (...args) {
try {
return nativeSelectionExtend.apply(this, args);
} catch (error) {
console.log('Selection error.', error);
}
};
It works properly for me. Maybe will be useful for somebody as well.
Thanks to https://github.com/shpakkdv

Using StorageService in Gluon to analyze how much memory storage is possible - And getting strange result

I have used com.gluonhq.charm.down.plugins.StorageService to look for how much it would be possible to store with a application on windows, mac, iOS and Android seperate devices. I get a strange result on iOS (the rest is as you can expect with windows, mac and Android) - and need help to understand why that is.
According to the StorageSevice I have 5363227164672 (bytes) on my iPhone 6. How is that possible/why such strange result? That is 5365 GB!
File privateStorage = null;
try {
privateStorage = Services.get(StorageService.class).flatMap(StorageService::getPrivateStorage).orElseThrow(() -> new FileNotFoundException("Could not access prrivate storage"));
} catch (FileNotFoundException ex) {
Logger.getLogger(Go.class.getName()).log(Level.SEVERE, null, ex);
}
// a simple print to javafx textArea method:
out("size is " + privateStorage.getFreeSpace());
Here is the documentation for StorageService.
Edit:
With .getUsableSpace() I get 179GB on iPhone6 which is not correct. Using .getUsableSpace() on windows gave the same result as before, (Android and Mac not rechecked with getUsableSpace().

Testing React Native with Appium: how to get past "Permit drawing over other apps"?

In my initial proof of concept for testing a React Native mobile app using Appium, I noticed that when I load the APK to start my test, I am presented with an Android prompt to "Permit drawing over other apps" as I am creating my AndroidDriver driver. If I move the slider manually, then click the back button, all is good -- the app loads fully, and my test proceeds. However, I don't see how to do this with automation using my Appium script because it looks like the driver instantiation will not complete until the slider is moved.
Most people don't see this in Appium testing as it appears to be specific to React Native in dev mode, as seen here...
Here's my code where I've put in conditional code to click the slider, but I never get there because it waits at the "driver = ..." line:
AndroidDriver driver = null;
#Before
public void setUp() throws Exception {
// < defining capabilities (emulator6p) up here...>
// initialize driver object
try {
driver = new AndroidDriver<WebElement>(new URL("http://127.0.0.1:4723/wd/hub"), emulator6p);
} catch (MalformedURLException e) {
System.out.println(e.getMessage());
}
}
#Test
public void test1() throws Exception {
By BY_slider_permitDrawing = By.id("android:id/switchWidget");
boolean present = (driver.findElements(BY_slider_permitDrawing).size() == 1);
if (present) {
driver.findElement(BY_slider_permitDrawing).click();
driver.navigate().back();
}
WebElement button_begin = driver.findElementByAccessibilityId("button-lets-begin");
button_begin.click();
}
I definitely hear plenty of people say that Appium is a viable solution for React Native testing, and really need to get over this hump.
Thanks in advance for any suggestions!
jph
p.s. In case it wasn't really clear, the test does NOT hang at the "driver = " line if I am not loading the APK from scratch, but I will need to do that for CI testing in the future.
Setting right capabilities helped me to run Appium tests in Debug mode on Android:
{
...
"appWaitPackage": "com.android.settings, com.yourPackage",
"appWaitActivity": "com.android.settings.Settings$AppDrawOverlaySettingsActivity, com.yourPackage.MainActivity",
}
Replace yourPackage with your real package name used in Android app. Some docs here: https://appium.io/docs/en/writing-running-appium/caps/#android-only

MonoTouch JIT Error in Release mode on Linq Method

I currently have some code as shown below that uses Linq to organize some IEnumerables for me. When executing this code on the device in release mode (iOS 5.0.1, MonoTouch 5.0.1, Mono 2.10.6.1) I get the exception
Attempting to JIT compile method 'System.Linq.OrderedEnumerable`1:GetEnumerator()' while running with --aot-only.
The code that generates this error is
// List<IncidentDocument> documents is passed in
List<LibraryTableViewItemGroup> groups = new List<LibraryTableViewItemGroup>();
List<DocumentObjectType> categories = documents.Select(d=>d.Type).Distinct().OrderBy(s=>s.ToString()).ToList();
foreach(DocumentObjectType cat in categories)
{
List<IncidentDocument> catDocs = documents.Where(d => d.Type == cat).OrderBy(d => d.Name).ToList();
List<LibraryTableViewItem> catDocsTableItems = catDocs.ConvertAll(d => { return new LibraryTableViewItem{ Image = GetImageForDocument(d.Type), Title = d.Name, SubTitle = d.Description}; });
LibraryTableViewItemGroup catGroup = new LibraryTableViewItemGroup{ Name = GetCatName(cat), Footer = null, Items = catDocsTableItems };
groups.Add (catGroup);
}
This error doesn't happen in the simulator for Release|Debug configurations, or on the device for the Debug configuration. I've seen a couple of similar threads on SO here and here, but I'm not sure I understand how they apply to me on this particular issue.
It could be a few things.
There are some limitations when using full AOT to build iOS applications, i.e. ensuring that nothing will be JITted at runtime (an Apple restriction). Each one is different even if the message looks identical (i.e. many causes will lead to this). However there are generally easy workarounds we can suggest for them;
It could also be a (known) regression in 5.0.1 (which is fixed in 5.0.2). This produced a few extra AOT failures that are normally not issues (or already fixed issues).
I suggest you to update to MonoTouch 5.0.2 to see if it compiles correctly your application. If not then please fill a bug report on http;//bugzilla.xamarin.com and include a small, self-contained, test case to duplicate the issue (the above is not complete enough). It seems an interesting test case if it works when debugging is enabled.

How to do iPad flash app debugging on Windows? [duplicate]

This question already has an answer here:
Closed 11 years ago.
Possible Duplicate:
Debugging iOS/AIR content on the device
I'm porting my Air app to iPad. I compiled it with:
adt -package -target ipa-ad-hoc -storetype pkcs12 -keystore store.p12 -storepass ****** -provisioning-profile profile.mobileprovision app.ipa app.xml app.swf
App was deployed on device through iTunes. When I launch app on iPad I get a black screen. Looks like some exception is thrown or something like that. How can I see that exception? Or if to be more general, how do you guys debug iOS app on Windows?
As far as my knowledge goes there is no remote debugging with AIR and iOS possible. So you have to revert to creating a scrolling text field somewhere and show log/debug texts there.
Edit: See Debugging iOS/AIR content on the device.
Edit2: Short tutorial video on debugging on iOS via Flash Prof CS5.5: http://www.youtube.com/watch?v=DanNBN89uhs
You can use the uncaughtErrorEvents property (found in your main documents loaderInfo property) to catch any unhandled error and show it also in the text field (see http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/LoaderInfo.html#uncaughtErrorEvents)
There is also the possibility to define compiler constants to enclose debug log statements within actionscript so you can easily turn them on and off.
I normally also test first the application on my windows before creating an iPad version of it.
Final tip: remember that only your main swf can contain actionscript.
Edit:
Here is a example, try to add this code before any other actionscript is executed:
import flash.events.UncaughtErrorEvent;
import flash.events.Event;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.TextFieldType;
// ...
// textLog contains errors
var textLog: TextField;
// make sure there is a uncaughtErrorEvents property (in case of older player)
if (this.loaderInfo.hasOwnProperty('uncaughtErrorEvents'))
{
// listen for uncaught error events
this.loaderInfo['uncaughtErrorEvents'].addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, handleUncaughtError);
// make sure text field stays on top
this.addEventListener(Event.ENTER_FRAME, handleEnterFrame);
// create TextField at bottom using 1/5th of stage height
textLog = new TextField();
textLog.width = this.stage.stageWidth;
textLog.height = Math.floor(0.20 * this.stage.stageHeight);
textLog.y = this.stage.stageHeight - textLog.height;
textLog.multiline = true;
textLog.wordWrap = true;
textLog.defaultTextFormat = new TextFormat('_sans', 10);
textLog.type = TextFieldType.DYNAMIC;
textLog.background = true;
textLog.backgroundColor = 0xCCCCCC;
this.addChild(textLog);
textLog.appendText('Catching errors\n');
}
// show error and scroll to bottom line
function handleUncaughtError(anEvent: UncaughtErrorEvent): void
{
textLog.appendText(anEvent.error + '\n');
textLog.scrollV = textLog.maxScrollV;
}
// make sure textLog stays on top of all other children
function handleEnterFrame(anEvent: Event): void
{
if (this.getChildIndex(this.textLog) != this.numChildren - 1)
{
this.addChild(this.textLog);
}
}
Are you using Air 2.7 or 3.0? I had this issue when I was using a library built with alchemy. For some reason using the alchemy library caused a blank screen. Remote debugging didn't help me either because it was before everything. I fixed it by not including the alchemy library (the library was for fast JSON parsing)

Resources