8074319: barrier_set_cast defined via friend injection

Changed the in-class definition to a friend declaration and move the definition to namespace scope

Reviewed-by: jwilhelm, simonis
This commit is contained in:
Kim Barrett 2015-03-04 02:23:38 +01:00 committed by Jesper Wilhelmsson
parent 25c5065b89
commit 0401cdb946

View file

@ -68,11 +68,7 @@ private:
// Downcast argument to a derived barrier set type.
// The cast is checked in a debug build.
// T must have a specialization for BarrierSet::GetName<T>.
template<typename T>
friend T* barrier_set_cast(BarrierSet* bs) {
assert(bs->is_a(BarrierSet::GetName<T>::value), "wrong type of barrier set");
return static_cast<T*>(bs);
}
template<typename T> friend T* barrier_set_cast(BarrierSet* bs);
public:
// Note: This is not presently the Name corresponding to the
@ -216,4 +212,10 @@ public:
virtual void print_on(outputStream* st) const = 0;
};
template<typename T>
inline T* barrier_set_cast(BarrierSet* bs) {
assert(bs->is_a(BarrierSet::GetName<T>::value), "wrong type of barrier set");
return static_cast<T*>(bs);
}
#endif // SHARE_VM_MEMORY_BARRIERSET_HPP