This Question is Not Answered

1 "correct" answer available (4 pts) 2 "helpful" answers available (2 pts)
2 Replies Last post: Jun 18, 2012 4:19 PM by Dody Gunawinata  
Dody Gunawinata Novice 140 posts since
Apr 4, 2012
Currently Being Moderated

Jun 18, 2012 3:50 PM

translatingjava static field to Kotlin

I am porting Artemis Entity Framework (game related) to Kotlin and I encounter a problem in trying to replace a java static field to Kotlin equivalent

 

package com.artemis;
 
public class ComponentType {
        private static long nextBit = 1;
        private static int nextId = 0;
        
        private long bit;
        private int id;
        
        public ComponentType() {
                init();
        }
        
        private void init() {
                bit = nextBit;
                nextBit = nextBit << 1;
                id = nextId++;
        }
        
        public long getBit() {
                return bit;
        }
        
        public int getId() {
                return id;
        }
}
 

 

to

 

package artemis
 
private var nextBit : Long = 1
private var nextId : Int = 0
 
public class ComponentType{
    private var bit : Long = 0
    private var id : Int = 0
 
    {
        bit = nextBit
        nextBit = nextBit shl 1
        id = nextId++
    }
 
    public fun getBit(): Long{
        return bit
    }
 
    public fun getId() : Int{
        return id
    }
}
 
 
 
 

 

This will generate runtime error at statement "bit = "nextBit"

Andrey Breslav Apprentice 548 posts since
Jun 11, 2007
Currently Being Moderated
Jun 18, 2012 4:00 PM in response to: Dody Gunawinata
Re: translatingjava static field to Kotlin

Looks like a bug. Could you report it to our isse tracker? Thanks

More Like This

  • Retrieving data ...