awt package not annotated
In the following code:
import javax.swing.* ; import java.awt.* ; import java.awt.event.* ; class cardTest implements ActionListener { JFrame fr; JPanel pnl1;
JButton b1,b2,b3,b4;
Icon ic1,ic2,ic3,ic4;
CardLayout card;
cardTest()
{
ic1=new ImageIcon("img3.jpg");
ic2=new ImageIcon("img4.jpg");
ic3=new ImageIcon("img2.png");
ic4=new ImageIcon("img1.jpg");
fr=new JFrame("Menu Test");
pnl1=new JPanel();
fr.add(pnl1);
b3=new JButton(ic3);
b4=new JButton(ic4);
b1=new JButton(ic1);
b2=new JButton(ic2);
card=new CardLayout();
pnl1.setLayout(card);
pnl1.add(b1);
b1.addActionListener(this);
pnl1.add(b2);
b2.addActionListener(this);
pnl1.add(b3);
b3.addActionListener(this);
pnl1.add(b4);
b4.addActionListener(this);
fr.setSize(500,500);
fr.setVisible(true);
}
public void actionPerformed(ActionEvent ed)
{
card.next(pnl1);
}
public static void main(String []args)
{
new cardTest();
}
}
If we compile this code with command javac cardTest.java It will work properly
But by using javac -processor NullnessChecker cardTest.java It is showing error in ActionListener(this) It is not getting (this)
output:

The code you pasted in does not compile. Your bug report needs to be more specific than "It is not getting (this)."
I think it compiles properly. Please check once again @mernst
In ActionListener(this) this keyword is not working
The addActionListener method takes the current class object as a parameter. The "this" keyword simply means "this object I'm working in right now"
I hope now I defined it properly. @mernst
What do you mean by "this keyword is not working"? A bug report should say what happened, and also what you expected to happen (and why).
this referes to the current instance of object.
say your class A implements the ActionListener. then from your class if you add the listener then you can use this , as for inheritance rule your class is also a listener.
class A implements ActionListener{ Button b; A(){ b1 = new Button(); b1.addActionListener(this); } } Here this is used because the currentobject is also a action listener
How is this related to the error message that was issued by the checker?
Sir actually i mean to say that it is not getting this keyword.. i.e. this keyword is not working in this code
The errors are related to the Initialization Checker: https://checkerframework.org/manual/#initialization-checker
The Checker Framework doesn't come with annotations for addActionListener so at the moment we require a fully initialized object.
In your example, you pass this during construction to this method. You should think whether addActionListener is specified to accept partially initialized objects as argument. If so, we can update the specification for that method.
okk
I think adding annotation for actionListener would be a good idea
I've marked this as low priority because the AWT package is deprecated and annotating the whole thing seems like a lot of work. It would definitely improve the Checker Framework, though, and we would welcome a contribution of the annotations.
Sir I think we have to improve this issue as most of the users use checker framework for checking large software source codes and i think if we improve this we will surely make it mote successful and it definately improve this.
If you want i can take this issue as my gsoc project
That would be fine.
Ok Sir Then I am making a new project proposal on this project