ABAP和Java的tag(marker) interface

简介: ABAP和Java的tag(marker) interface

In my previous blog How many fat interfaces are there in SAP system I introduce the concept of “fat interface”. In this blog let’s explore the concept of tag interface.

There is definition for tag interface in ABAP help:


“Specific predefined global interface. By integrating the tag interface, classes or other interfaces stand out against the ABAP runtime environment. A tag interface generally does not contain its own interface components, but instead assigns a particular task to the integrating classes or interfaces and changes the way they are handled by the ABAP Compiler.“

And in fact this is not a specific concept of ABAP, but exists in many other language as well.


ABAP tag interface

One of the most famous tag interface in ABAP is if_serializable_object.image.pngI used it in my blog Singleton bypass – ABAP and Java.


An object instance of class which implements this tag interface could be serialized to an XML String.


The actual serialization and deserialization is done in the kernel.


Another tag interface IF_BADI_INTERFACE

In you BAdI definition, it is impossible to use an interface without including this tag interface.

image.pngEven if you bypass this check via tricks like debugging in ABAP layer, there is still kernel check in the runtime as last defense.


Tag interface in Java

As I mentioned the tag interface is a generic concept which is available in many other language like Java. See more generic definition in Wikipedia.


The tag/ marker interface pattern is a design pattern in computer science, used with languages that provide run-time type information about objects. It provides a means to associate metadata with a class where the language does not have explicit support for such metadata.


Java Serialization

Still use serialization for example. Java has its own tag interface for serialization, Serializable. ( just exactly the same logic as if_serializable_object in ABAP ).image.pngimage.pngimage.pngimage.pngimage.pngimage.pngimage.pngimage.pngFurther reading

I have written a series of blogs which compare the language feature among ABAP, JavaScript and Java. You can find a list of them below:


Lazy Loading, Singleton and Bridge design pattern in JavaScript and in ABAP

Functional programming – Simulate Curry in ABAP

Functional Programming – Try Reduce in JavaScript and in ABAP

Simulate Mockito in ABAP

A simulation of Java Spring dependency injection annotation @Inject in ABAP

Singleton bypass – ABAP and Java

Weak reference in ABAP and Java

Fibonacci Sequence in ES5, ES6 and ABAP

Java byte code and ABAP Load

How to write a correct program rejected by compiler: Exception handling in Java and in ABAP

An small example to learn Garbage collection in Java and in ABAP

String Template in ABAP, ES6, Angular and React

Try to access static private attribute via ABAP RTTI and Java Reflection

Local class in ABAP, Java and JavaScript

Integer in ABAP, Java and JavaScript

Covariance in Java and simulation in ABAP

Various Proxy Design Pattern implementation variants in Java and ABAP

Tag(Marker) Interface in ABAP and Java

Bitwise operation ( OR, AND, XOR ) on ABAP Integer

ABAP ICF handler and Java Servlet



相关文章
|
4月前
|
Java
Java(二十一)interface接口
Java(二十一)interface接口
28 0
|
5月前
|
Java
JAVA 抽象类(Abstract Class) 和 接口(Interface) 的区别
对于面向对象编程来说,抽象是它的一大特征之一。在 Java 中,可以通过两种形式来体现 OOP 的抽象:接口和抽象类。这两者有太多相似的地方,又有太多不同的地方。今天我们就一起来学习一下Java中的接口和抽象类抽象类不能用于实例化对象,抽象类往往用来表示抽象概念。举个例子,中国人(Chinese 类)和美国人(American 类)都有“吃饭”这个行为,因此可以先定义一个 Person 类,然后让 Chinese 和 American 都继承这个类。但如何在父类 Person 中定义“吃饭”这个方法呢?一般
74 0
|
6月前
|
存储 Java BI
如何使用 Java 程序通过 SAP Java Connector 调用 ABAP 系统的函数试读版
如何使用 Java 程序通过 SAP Java Connector 调用 ABAP 系统的函数试读版
50 0
|
2月前
|
SQL 开发框架 数据库
聊聊 SAP ABAP 系统里的胖接口(Fat Interface)
聊聊 SAP ABAP 系统里的胖接口(Fat Interface)
28 0
|
4月前
|
人工智能 Java API
【Java 接口】接口(Interface)的定义,implements关键字,接口实现方法案例
【Java 接口】接口(Interface)的定义,implements关键字,接口实现方法案例
|
6月前
|
前端开发 Java jenkins
Jenkins+Gitlab+Nginx+SonarQube+Maven编译Java项目自动发布与基于tag版本回退
Jenkins+Gitlab+Nginx+SonarQube+Maven编译Java项目自动发布与基于tag版本回退
250 0
|
6月前
|
Java jenkins 应用服务中间件
Jenkins+Gitlab+Nginx+Maven编译Java项目自动发布与基于tag版本回退(重复构建问题已解决)
Jenkins+Gitlab+Nginx+Maven编译Java项目自动发布与基于tag版本回退(重复构建问题已解决)
|
8月前
|
Java
Java面向对象 接口(interface)的详解
Java面向对象 接口(interface)的详解
52 0
|
8月前
|
Java
Java 接口协议(interface)
Java 接口协议(interface)
61 0
|
1月前
|
存储 数据处理 开发者
ABAP 如何把 unicode 代码点转换成字符
ABAP 如何把 unicode 代码点转换成字符
19 0