From edd01816d151f9e7acc0de12924408a14f1e36ca Mon Sep 17 00:00:00 2001 From: updjx Date: Fri, 16 Nov 2018 09:38:08 +0100 Subject: [PATCH] trying to fix disscusion comments --- semantic/AttributeKill.valid.java | 14 ++++++-------- semantic/NoParameterDeclaration.invalid.mj | 5 ++++- ...riteAttributeWithUndeclaredVariable.invalid.mj | 15 ++++++++++----- semantic/RightVariable.valid.java | 10 +++++----- 4 files changed, 25 insertions(+), 19 deletions(-) diff --git a/semantic/AttributeKill.valid.java b/semantic/AttributeKill.valid.java index 9933566..6e9d3c8 100644 --- a/semantic/AttributeKill.valid.java +++ b/semantic/AttributeKill.valid.java @@ -2,28 +2,26 @@ class AttributeKill { public A objectA; - public static void main(String[] args) { + /* create and construct object A*/ A objectA = new A(); objectA.init(); + /* set object to null*/ objectA = null; - - int a = objectA.atr; + /* calling uninitiated attribute of null object*/ + int a = objectA.atr; } - - } class A { + public int atr; /* pseudo constructor */ - public void init () { - + public void init() { atr = 2; } - } \ No newline at end of file diff --git a/semantic/NoParameterDeclaration.invalid.mj b/semantic/NoParameterDeclaration.invalid.mj index d11606d..8ccf443 100644 --- a/semantic/NoParameterDeclaration.invalid.mj +++ b/semantic/NoParameterDeclaration.invalid.mj @@ -4,13 +4,16 @@ */ class NoParameterDeclaration { + public int a; public static void main(String[] args) { + + NoParameterDeclaration testObj = new NoParameterDeclaration(); /*there is no parameter given here*/ testObj.test(); } - public void test (int i) { + public void test(int i) { int a = i; } diff --git a/semantic/OverwriteAttributeWithUndeclaredVariable.invalid.mj b/semantic/OverwriteAttributeWithUndeclaredVariable.invalid.mj index 75bcbaf..faa0b2d 100644 --- a/semantic/OverwriteAttributeWithUndeclaredVariable.invalid.mj +++ b/semantic/OverwriteAttributeWithUndeclaredVariable.invalid.mj @@ -1,17 +1,22 @@ class OverwriteAttributeWithUndeclaredVariable { - public static void main(String[] args) {} public String a; - public void test () { - /*should break here because of undeclared unknown variable*/ - int a = i; + public static void main(String[] args) { + + OverwriteAttributeWithUndeclaredVariable obj = new OverwriteAttributeWithUndeclaredVariable(); + obj.test(); } + public void test() { + /*should break here because of undeclared unknown variable*/ + a = i; + } } -class String {} +class String { +} diff --git a/semantic/RightVariable.valid.java b/semantic/RightVariable.valid.java index 075df93..3a0f089 100644 --- a/semantic/RightVariable.valid.java +++ b/semantic/RightVariable.valid.java @@ -3,7 +3,8 @@ */ class RightVariable { - public static void main(String[] args) {} + public static void main(String[] args) { + } public int Test; @@ -27,20 +28,19 @@ class RightVariable { /*Overwrite test attribute with RightVariable class Attribute*/ test.Test = Test; - /*call local method with test*/ + /*call class RightVariable method Test, with the test object declared in the current method*/ Test(test); /*Overwrite class Test with with local method Test, with itself given as an obj ref..*/ test = Test(test); } - - } class Test { public int Test; - public void Test() {} + public void Test() { + } } \ No newline at end of file -- GitLab