Skip to main content
summaryrefslogtreecommitdiffstats
blob: 467c4a04314b0dc61406088ae5f946ff8d1454e9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/**********************************************************************
 * This file is part of "Object Teams Dynamic Runtime Environment"
 *
 * Copyright 2003, 2010 Berlin Institute of Technology, Germany, and others.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Please visit http://www.eclipse.org/objectteams for updates and contact.
 *
 * Contributors:
 *		Berlin Institute of Technology - Initial API and implementation
 **********************************************************************/
package org.objectteams;

/**
 * This exception is thrown by the OT/J infra structure if a role for a given base object
 * was requested during lifting, but a role with an incompatible type was already
 * registered for that base object. Can only happen if a compile time warning occurred.
 * @author Stephan Herrmann
 */
public class WrongRoleException extends RuntimeException {
	/**
	 *
	 */
	private static final long serialVersionUID = 1L;
	private Class<?> clazz;
	private Object base;
	private Object role;

	/**
	 * @param clazz
	 * @param base
	 * @param role
	 */
	public WrongRoleException (Class<?> clazz, Object base, Object role) {
		this.clazz = clazz;
		this.base = base;
		this.role = role;
	}

	@Override
	public String getMessage() {
		String baseClazz = base.getClass().getName();
		String roleClazz = role.getClass().getName();
		return "The compiler has warned you about ambiguous role bindings.\n"
				+ "Now lifting to " + clazz
				+ " fails with the following objects\n"
				+ "(see OT/J language definition para. 2.3.4(d)):\n"
				+ "Provided:\n  Base object: " + base + "\n" + "  Base type:   "
				+ baseClazz + "\n"
				+ "Found in cache:\n  Role object: " + role + "\n"
				+ "  Role type:   " + roleClazz;
	}
}

Back to the top