KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > aspectj > compiler > base > ast > NullType


1 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2  *
3  * This file is part of the compiler and core tools for the AspectJ(tm)
4  * programming language; see http://aspectj.org
5  *
6  * The contents of this file are subject to the Mozilla Public License
7  * Version 1.1 (the "License"); you may not use this file except in
8  * compliance with the License. You may obtain a copy of the License at
9  * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
10  *
11  * Software distributed under the License is distributed on an "AS IS" basis,
12  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13  * for the specific language governing rights and limitations under the
14  * License.
15  *
16  * The Original Code is AspectJ.
17  *
18  * The Initial Developer of the Original Code is Xerox Corporation. Portions
19  * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation.
20  * All Rights Reserved.
21  *
22  * Contributor(s):
23  */

24
25 package org.aspectj.compiler.base.ast;
26
27 import org.aspectj.compiler.base.bcg.CodeBuilder;
28 import org.aspectj.compiler.base.JavaCompiler;
29
30 public class NullType extends RefType {
31     public NullType(JavaCompiler compiler) {
32         super(compiler);
33     }
34
35     // ??? This is subtly wrong in the model, but it shouldn't lead to
36
// problems. In actuality, the null type is assignable to all
37
// reference types.
38
public boolean isSubtypeOf(Type other) {
39         return (other instanceof RefType);
40     }
41
42     public boolean isAssignableFrom(Type other) {
43         //JJH - I believe that NullType is never assignable from anything
44
//EH - but it's useful to me to be assignable from the NullType
45
return other instanceof NullType;
46         //return false;
47
//return other.isReferenceType();
48
}
49
50     public boolean isMethodConvertableTo(Type other) {
51         return other.isReferenceType();
52     }
53     
54     public boolean isCoercableTo(Type other) {
55         return true;
56     }
57
58     protected void showNotFoundError(String JavaDoc id, ASTObject fromWhere, String JavaDoc kind) {
59         getCompiler().showError(fromWhere, "no " + kind + "s on null");
60     }
61
62     public boolean isAnyType() {
63         return false;
64     }
65
66     public String JavaDoc getString() {
67         return "null";
68     }
69
70     public String JavaDoc toShortString() {
71         return "null";
72     }
73
74     // vm internals
75
public String JavaDoc getDescriptor() {
76         throw new RuntimeException JavaDoc("No bytecode type descriptor for Null type");
77     }
78
79 }
80
Popular Tags