Skip to content

IOS miscompilation, results in nullPointerException #3108

@ddyer0

Description

@ddyer0

The attached program does some simple arithmetic (with no pointers) and
encounters a nullPointerException on IOS only. The key point that induces
the error seems to be the chained assignment found in the function init()


package com.boardspace.dtest;

// 
// demonstrates broken clipping region on the simulator
// issue 3106
//
import com.codename1.ui.Display;
import com.codename1.ui.Form;
import com.codename1.ui.Label;
import com.codename1.ui.Stroke;
import com.codename1.ui.geom.GeneralPath;
import com.codename1.ui.geom.Rectangle;
import com.codename1.ui.plaf.UIManager;
import com.codename1.ui.util.Resources;
import com.codename1.ui.Graphics;
import com.codename1.ui.Image;
import com.codename1.ui.layouts.BorderLayout;


public class Dtest {

private Form current;
@SuppressWarnings("unused")
private Resources theme;

public void init(Object context) {
    theme = UIManager.initFirstTheme("/theme");
    // Pro only feature, uncomment if you have a pro subscription
    // Log.bindCrashProtection(true);
}
private int initialBoardScaleIndex = 3;
private double boardScaleIndex = initialBoardScaleIndex;
private double newBoardScaleIndex = boardScaleIndex;
private double boardScales[] = {1.0,2.0,3.0,4.0};
private int numBoardScales = boardScales.length;
public double SCALE = 1.5;
public void init()
{

	double isi = boardScaleIndex;
	double tableScale = SCALE;
	isi*=tableScale;
	boardScaleIndex = newBoardScaleIndex = Math.min(numBoardScales-1,(int)(isi*SCALE));
 		
}
public void start() {
    if(current != null){
        current.show();
    }
    Form hi = new Form("Hi >>0 World");
     current = hi;
    hi.setLayout(new BorderLayout());
    hi.addComponent(BorderLayout.CENTER, new Label("Hi Overlay World 2") {
        @Override
        public void paint(Graphics gc) {
         	int w = getWidth();
        	int h = getHeight();
         	gc.setColor(0x909090);	// gray rectangle
        	gc.fillRect(0,0,w,h);
           	try {
           	init();
    		gc.setColor(0);
     		gc.drawString("no problem "+boardScaleIndex+" "+newBoardScaleIndex,100,100);
           	}
           	catch(Throwable err)
           	{
           		gc.setColor(0);
           		gc.drawString("error "+err,100,100);
           	}
        }
        
    });
    hi.show();
	Runnable rr = new Runnable (){ 
		public void run() {
			System.out.println("running");
		while(true) 
		{ 
		  hi.repaint();
		  try {
			  Thread.sleep(10); 
			  }
		  
		  catch (InterruptedException e) {};
		}}};
	new Thread(rr).start();
}
public void stop() {
    current = Display.getInstance().getCurrent();
}

public void destroy() {
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions