Reflection Support: Java Reflection Made Easy

Z. Shams, S. Edwards
{"title":"Reflection Support: Java Reflection Made Easy","authors":"Z. Shams, S. Edwards","doi":"10.2174/1874107X20130422001","DOIUrl":null,"url":null,"abstract":"Large software projects often require the ability to load and manage new code assets that were not originally available during system compilation. Moreover, testing tools need to inspect and run code components regardless of their structures. Reflection in Java supports these tasks by providing programmers with facilities to dynamically create objects, invoke methods, access fields, and perform code introspection at runtime. These capabilities come at the cost of reduced readability and writeability, since code written using Java's reflection classes is clunky, bulky and unintuitive. Common tasks such as object creation, method invocation, and field manipulation need to be decomposed into multiple steps that require try-catch blocks to guard against checked exceptions. Type casts and explicit use of class types as parameters make development and maintenance of code difficult, time consuming and error prone. In this paper, we discuss the diffi- culties of using reflection in Java. We also present an open-source library called ReflectionSupport that addresses these problems and makes reflection in Java easier to use. ReflectionSupport provides static helper methods that offer the same reflective capabilities but that encapsulate the overhead of coding with reflection. This paper focuses on improving the us- ability of Java reflection by presenting an API that allows programmers to obtain the benefits of reflection without the hassle.","PeriodicalId":262856,"journal":{"name":"The Open Software Engineering Journal","volume":"4 1","pages":"0"},"PeriodicalIF":0.0000,"publicationDate":"2013-12-13","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"8","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"The Open Software Engineering Journal","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.2174/1874107X20130422001","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 8

Abstract

Large software projects often require the ability to load and manage new code assets that were not originally available during system compilation. Moreover, testing tools need to inspect and run code components regardless of their structures. Reflection in Java supports these tasks by providing programmers with facilities to dynamically create objects, invoke methods, access fields, and perform code introspection at runtime. These capabilities come at the cost of reduced readability and writeability, since code written using Java's reflection classes is clunky, bulky and unintuitive. Common tasks such as object creation, method invocation, and field manipulation need to be decomposed into multiple steps that require try-catch blocks to guard against checked exceptions. Type casts and explicit use of class types as parameters make development and maintenance of code difficult, time consuming and error prone. In this paper, we discuss the diffi- culties of using reflection in Java. We also present an open-source library called ReflectionSupport that addresses these problems and makes reflection in Java easier to use. ReflectionSupport provides static helper methods that offer the same reflective capabilities but that encapsulate the overhead of coding with reflection. This paper focuses on improving the us- ability of Java reflection by presenting an API that allows programmers to obtain the benefits of reflection without the hassle.
反射支持:Java反射变得简单
大型软件项目通常需要加载和管理在系统编译期间最初不可用的新代码资产的能力。此外,测试工具需要检查和运行代码组件,而不管它们的结构如何。Java中的反射通过为程序员提供动态创建对象、调用方法、访问字段和在运行时执行代码自省的工具来支持这些任务。这些功能是以降低可读性和可写性为代价的,因为使用Java反射类编写的代码笨重、庞大且不直观。对象创建、方法调用和字段操作等常见任务需要分解为多个步骤,这些步骤需要try-catch块来防止检查异常。类型强制转换和显式使用类类型作为参数使代码的开发和维护变得困难、耗时且容易出错。在本文中,我们讨论了在Java中使用反射的困难。我们还提供了一个名为ReflectionSupport的开源库来解决这些问题,并使Java中的反射更易于使用。ReflectionSupport提供了静态帮助器方法,这些方法提供了相同的反射功能,但封装了用反射编码的开销。本文的重点是通过提供一个API来提高Java反射的能力,该API允许程序员在没有麻烦的情况下获得反射的好处。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
求助全文
约1分钟内获得全文 求助全文
来源期刊
自引率
0.00%
发文量
0
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
确定
请完成安全验证×
copy
已复制链接
快去分享给好友吧!
我知道了
右上角分享
点击右上角分享
0
联系我们:info@booksci.cn Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。 Copyright © 2023 布克学术 All rights reserved.
京ICP备2023020795号-1
ghs 京公网安备 11010802042870号
Book学术文献互助
Book学术文献互助群
群 号:604180095
Book学术官方微信