standards-compliance

Java reflection: Is the order of class fields and methods standardized?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-26 08:20:33
问题 Using reflection on Java classes to access all field, methods, and so on: Is there a standardized order of these elements (which is specified in some standard)? Of course, I could check it empirically, but I need to know if it\'s always the same. EDIT: I waited for the question: What I need the order for ;) Long story short: I have JAXB-annotated classes, and want no represent these classes visually. While the order of XML attributes is neither relevant for the XML standard, nor for JAXB, I

Is the compiler allowed to recycle freed pointer variables?

僤鯓⒐⒋嵵緔 提交于 2019-11-26 07:43:34
问题 It has been claimed that a compiler is free to reuse the pointer variable for some other purpose after the realloc being freed , so you have no guarantee that it has the same value as it did before ie void *p = malloc(42); uintptr_t address = (uintptr_t)p; free(p); // [...] stuff unrelated to p or address assert((uintptr_t)p == address); might fail. C11 annex J.2 reads The value of a pointer that refers to space deallocated by a call to the free or realloc function is used (7.22.3) [ is

Does a dot have to be escaped in a character class (square brackets) of a regular expression?

流过昼夜 提交于 2019-11-26 06:00:48
问题 A dot . in a regular expression matches any single character. In order for regex to match a dot, the dot has to be escaped: \\. It has been pointed out to me that inside square brackets [] a dot does not have to be escaped. For example, the expression: [.]{3} would match ... string. Doesn\'t it, really? And if so, is it true for all regex standards? 回答1: In a character class (square brackets) any character except ^ , - , ] or \ is a literal. This website is a brilliant reference and has lots

Is main() really start of a C++ program?

和自甴很熟 提交于 2019-11-26 03:27:58
问题 The section $3.6.1/1 from the C++ Standard reads, A program shall contain a global function called main , which is the designated start of the program. Now consider this code, int square(int i) { return i*i; } int user_main() { for ( int i = 0 ; i < 10 ; ++i ) std::cout << square(i) << endl; return 0; } int main_ret= user_main(); int main() { return main_ret; } This sample code does what I intend it to do, i.e printing the square of integers from 0 to 9, before entering into the main()

Why does MySQL allow “group by” queries WITHOUT aggregate functions?

和自甴很熟 提交于 2019-11-26 02:37:55
问题 Surprise -- this is a perfectly valid query in MySQL: select X, Y from someTable group by X If you tried this query in Oracle or SQL Server, you’d get the natural error message: Column \'Y\' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. So how does MySQL determine which Y to show for each X? It just picks one. From what I can tell, it just picks the first Y it finds. The rationale being, if Y is neither an aggregate function

Do the JSON keys have to be surrounded by quotes?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-26 01:27:34
问题 Example: Is the following code valid against the JSON Spec? { precision: \"zip\" } Or should I always use the following syntax? (And if so, why?) { \"precision\": \"zip\" } I haven\'t really found something about this in the JSON specifications. Although they use quotes around their keys in their examples. 回答1: Yes, you need quotation marks. This is to make it simpler and to avoid having to have another escape method for javascript reserved keywords, ie {for:"foo"} . 回答2: You are correct to

RegEx to parse or validate Base64 data

风格不统一 提交于 2019-11-26 00:33:23
问题 Is it possible to use a RegEx to validate, or sanitize Base64 data? That\'s the simple question, but the factors that drive this question are what make it difficult. I have a Base64 decoder that can not fully rely on the input data to follow the RFC specs. So, the issues I face are issues like perhaps Base64 data that may not be broken up into 78 (I think it\'s 78, I\'d have to double check the RFC, so don\'t ding me if the exact number is wrong) character lines, or that the lines may not end

C++ new int[0] — will it allocate memory?

最后都变了- 提交于 2019-11-26 00:13:12
问题 A simple test app: cout << new int[0] << endl; outputs: 0x876c0b8 So it looks like it works. What does the standard say about this? Is it always legal to \"allocate\" empty block of memory? 回答1: From 5.3.4/7 When the value of the expression in a direct-new-declarator is zero, the allocation function is called to allocate an array with no elements. From 3.7.3.1/2 The effect of dereferencing a pointer returned as a request for zero size is undefined. Also Even if the size of the space requested

Can an html element have multiple ids?

∥☆過路亽.° 提交于 2019-11-25 23:25:00
问题 I understand that an id must be unique within an HTML/XHTML page. My question is, for a given element, can I assign multiple ids to it? <div id=\"nested_element_123 task_123\"></div> I realize I have an easy solution with simply using a class. I\'m just curious about using ids in this manner. 回答1: No. From the XHTML 1.0 Spec In XML, fragment identifiers are of type ID, and there can only be a single attribute of type ID per element. Therefore, in XHTML 1.0 the id attribute is defined to be of

Is it valid to have a html form inside another html form?

做~自己de王妃 提交于 2019-11-25 22:47:31
问题 Is it valid html to have the following: <form action=\"a\"> <input.../> <form action=\"b\"> <input.../> <input.../> <input.../> </form> <input.../> </form> So when you submit \"b\" you only get the fields within the inner form. When you submit \"a\" you get all fields minus those within \"b\". If it isn\'t possible, what workarounds for this situation are available? 回答1: A. It is not valid HTML nor XHTML In the official W3C XHTML specification, Section B. "Element Prohibitions", states that: